Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Symbolic simplification differences between Sage and Maxima

I ran into some problems trying to do some symbolic manipulations in the standard sage interface versus maxima. I wan't to ask is there some way to get sage to behave the same, or do I have rely on maxima to get this substitution to work.

here my code for the sage notebook gui directly calling maxima:

x = maxima('x')

y = maxima('y:(t0*s+a0*t0)/((s^2+s*a)*(s+r1)+s0*s+s1)');

dyds0= maxima('dyds0: diff(y,s0)');

ans = maxima.ratsubst(x,y,dyds0);

the answer as expected is:

ans = -s*x/(s1+s*s0+s^3+(r1+a)*s^2+a*r1*s)

Here is the sage code from the sage notebook not calling maxima directly:

s,r1,s1,s0,t0,a,a0,y,deds0,x = var('s,r1,s1,s0,t0,a,a0,y,deds0,x')

y = (t0*s+a0*t0)/((s^2+s*a)*(s+r1)+s0*s+s1); y

d = (t0*s+a0*t0)

dyds0 = diff(y,s0);

ans = dyds0.substitute(y == x);

ans1 = dyds0.substitute(d == x);

trying to substitute in x for the expression y in the result doesn't work as the result is:

ans  =  (-(a0*t0 + s*t0)*s/((a*s + s^2)*(r1 + s) + s*s0 + s1)^2

However I try to substitute x for only the numerator in the y expressions (d), it works and the correct result is:

ans1 =  -s*x/((a*s + s^2)*(r1 + s) + s*s0 + s1)^2)

as another example:

This works as expected

Q,q,w,e = var('Q,q,w,e')
Q = q/(q+w)
Q.substitute(1/(q+w)==e)

But this doesn't

Q,q,w,e = var('Q,q,w,e')
Q = q/(q+w)^2
Q.substitute(1/(q+w)==e)

again maxima has no problem doing the substitution using ratsubst

click to hide/show revision 2
retagged

Symbolic simplification differences between Sage and Maxima

I ran into some problems trying to do some symbolic manipulations in the standard sage interface versus maxima. I wan't to ask is there some way to get sage to behave the same, or do I have rely on maxima to get this substitution to work.

here my code for the sage notebook gui directly calling maxima:

x = maxima('x')

y = maxima('y:(t0*s+a0*t0)/((s^2+s*a)*(s+r1)+s0*s+s1)');

dyds0= maxima('dyds0: diff(y,s0)');

ans = maxima.ratsubst(x,y,dyds0);

the answer as expected is:

ans = -s*x/(s1+s*s0+s^3+(r1+a)*s^2+a*r1*s)

Here is the sage code from the sage notebook not calling maxima directly:

s,r1,s1,s0,t0,a,a0,y,deds0,x = var('s,r1,s1,s0,t0,a,a0,y,deds0,x')

y = (t0*s+a0*t0)/((s^2+s*a)*(s+r1)+s0*s+s1); y

d = (t0*s+a0*t0)

dyds0 = diff(y,s0);

ans = dyds0.substitute(y == x);

ans1 = dyds0.substitute(d == x);

trying to substitute in x for the expression y in the result doesn't work as the result is:

ans  =  (-(a0*t0 + s*t0)*s/((a*s + s^2)*(r1 + s) + s*s0 + s1)^2

However I try to substitute x for only the numerator in the y expressions (d), it works and the correct result is:

ans1 =  -s*x/((a*s + s^2)*(r1 + s) + s*s0 + s1)^2)

as another example:

This works as expected

Q,q,w,e = var('Q,q,w,e')
Q = q/(q+w)
Q.substitute(1/(q+w)==e)

But this doesn't

Q,q,w,e = var('Q,q,w,e')
Q = q/(q+w)^2
Q.substitute(1/(q+w)==e)

again maxima has no problem doing the substitution using ratsubst