C_R

2340 Reputation

19 Badges

4 years, 302 days

MaplePrimes Activity


These are questions asked by C_R

This is a simplified case from a colleague who could not get has to work.

While this

I/sqrt(a);
has(%, sqrt(a));
                               I   
                             ------
                              (1/2)
                             a     

                             false

is a technically correct output from Maple, false is mathematically an incorrect statement (IMO).

I think new users cannot find the explanation for that on their own because in other instances the output is true

has(I/(1 - sqrt(a)), sqrt(a))
                              

                              true

Are there better ways than

I/sqrt(a);
has(%, sqrt(a))or has(%,1/sqrt(a));
                               I   
                             ------
                              (1/2)
                             a     

                              true

Its a bit complicated to include allways the inverse of an expression to capture all instances of an expression.

Should has do this an give a warning that also the inverse is present?

I was about to verify two solutions of dsolve from here but could not find an agreement for negative values. This makes me wonder if all values are computed.

There is also a different behaviour that I do not understand when allvalues is given a RootOf expression or an equation containing a RootOf expression.
 

dsolve without method

ode:=diff(y(x), x) = (3*x - y(x) + 1)/(3*y(x) - x + 5);
ic:=y(0)=0;
dsolve({ode,ic});
plot(rhs(%),x=-10..10,numpoints=10);
evalf(subs(x=3,%%));
evalf(subs(x=-3,%%%));

diff(y(x), x) = (3*x-y(x)+1)/(3*y(x)-x+5)

 

y(0) = 0

 

y(x) = -(-(1/36)*(x+1)^2*((-324+12*(96*x^3+288*x^2+288*x+825)^(1/2))^(2/3)-24*x-24)^2/(-324+12*(96*x^3+288*x^2+288*x+825)^(1/2))^(2/3)-x^3-x^2+x+1)/(x+1)^2

 

 

y(3) = 2.135964164

 

y(-3) = -2.302775638+0.4883358175e-9*I

(1)

dsolve with a particular method

sol:=dsolve([ode,ic],[dAlembert]);
odetest(sol,[ode,ic]);

y(x) = RootOf(-6*((x+_Z+3)/(5+3*_Z-x))^(2/3)*(-4*(-x+_Z+1)/(5+3*_Z-x))^(1/3)*_Z+2*((x+_Z+3)/(5+3*_Z-x))^(2/3)*(-4*(-x+_Z+1)/(5+3*_Z-x))^(1/3)*x+2*(-4)^(1/3)*3^(2/3)-10*((x+_Z+3)/(5+3*_Z-x))^(2/3)*(-4*(-x+_Z+1)/(5+3*_Z-x))^(1/3))

 

[0, 0]

(2)

Since allvalues fails on this expression for real valued x, rational and integer values are tried for punctual comaprision

subs(x=3,sol);
allvalues(%);
evalf(%)

y(3) = RootOf(-6*((6+_Z)/(2+3*_Z))^(2/3)*(-4*(-2+_Z)/(2+3*_Z))^(1/3)*_Z-4*((6+_Z)/(2+3*_Z))^(2/3)*(-4*(-2+_Z)/(2+3*_Z))^(1/3)+2*(-4)^(1/3)*3^(2/3))

 

y(3) = (6873/256)*(-(4/6873)*(20994724+82476*6873^(1/2))^(1/3)-(128/3)/(20994724+82476*6873^(1/2))^(1/3)+1/3-((1/2)*I)*3^(1/2)*((8/6873)*(20994724+82476*6873^(1/2))^(1/3)-(256/3)/(20994724+82476*6873^(1/2))^(1/3)))^2+(1/96)*(20994724+82476*6873^(1/2))^(1/3)+(2291/3)/(20994724+82476*6873^(1/2))^(1/3)-8947/768+((2291/256)*I)*3^(1/2)*((8/6873)*(20994724+82476*6873^(1/2))^(1/3)-(256/3)/(20994724+82476*6873^(1/2))^(1/3)), y(3) = (6873/256)*((8/6873)*(20994724+82476*6873^(1/2))^(1/3)+(256/3)/(20994724+82476*6873^(1/2))^(1/3)+1/3)^2-(1/48)*(20994724+82476*6873^(1/2))^(1/3)-(4582/3)/(20994724+82476*6873^(1/2))^(1/3)-8947/768, y(3) = (6873/256)*((8/6873)*(20994724+82476*6873^(1/2))^(1/3)+(256/3)/(20994724+82476*6873^(1/2))^(1/3)+1/3)^2-(1/48)*(20994724+82476*6873^(1/2))^(1/3)-(4582/3)/(20994724+82476*6873^(1/2))^(1/3)-8947/768

 

y(3) = -6.067982077+1.049560864*I, y(3) = 2.13596417, y(3) = 2.13596417

(3)

Two roots match the dsolve solution without method. However doing the same only on the right hand side produces different output. For some reason allvalues produces 3 RootOf expressions with a numerical root selector.

subs(x=3,rhs(sol));
allvalues(%);
evalf(%)

RootOf(-6*((6+_Z)/(2+3*_Z))^(2/3)*(-4*(-2+_Z)/(2+3*_Z))^(1/3)*_Z-4*((6+_Z)/(2+3*_Z))^(2/3)*(-4*(-2+_Z)/(2+3*_Z))^(1/3)+2*(-4)^(1/3)*3^(2/3))

 

RootOf((3*I)*3^(1/6)*2^(2/3)+2^(2/3)*3^(2/3)-6*((6+_Z)/(2+3*_Z))^(2/3)*(-4*(-2+_Z)/(2+3*_Z))^(1/3)*_Z-4*((6+_Z)/(2+3*_Z))^(2/3)*(-4*(-2+_Z)/(2+3*_Z))^(1/3), -6.067982082+1.049560860*I), RootOf((3*I)*3^(1/6)*2^(2/3)+2^(2/3)*3^(2/3)-6*((6+_Z)/(2+3*_Z))^(2/3)*(-4*(-2+_Z)/(2+3*_Z))^(1/3)*_Z-4*((6+_Z)/(2+3*_Z))^(2/3)*(-4*(-2+_Z)/(2+3*_Z))^(1/3), 2.135964164), RootOf((3*I)*3^(1/6)*2^(2/3)+2^(2/3)*3^(2/3)-6*((6+_Z)/(2+3*_Z))^(2/3)*(-4*(-2+_Z)/(2+3*_Z))^(1/3)*_Z-4*((6+_Z)/(2+3*_Z))^(2/3)*(-4*(-2+_Z)/(2+3*_Z))^(1/3), 2.135964164-0.*I)

 

-6.067982082+1.049560860*I, 2.135964164, -6.067982082+1.049560860*I

(4)

Why this change?
Now the same with a negative value. Now the root does not match the solution of the dsolve call without method.

subs(x=-3,sol);
allvalues(%);
evalf(%)

y(-3) = RootOf(-6*(_Z/(8+3*_Z))^(2/3)*(-4*(4+_Z)/(8+3*_Z))^(1/3)*_Z-16*(_Z/(8+3*_Z))^(2/3)*(-4*(4+_Z)/(8+3*_Z))^(1/3)+2*(-4)^(1/3)*3^(2/3))

 

y(-3) = -1/2+(1/2)*13^(1/2)

 

y(-3) = 1.302775638

(5)

subs(x = -3, rhs(sol));
allvalues(%);
evalf(%);

RootOf(-6*(_Z/(8+3*_Z))^(2/3)*(-4*(4+_Z)/(8+3*_Z))^(1/3)*_Z-16*(_Z/(8+3*_Z))^(2/3)*(-4*(4+_Z)/(8+3*_Z))^(1/3)+2*(-4)^(1/3)*3^(2/3))

 

RootOf((3*I)*3^(1/6)*2^(2/3)-6*(_Z/(8+3*_Z))^(2/3)*(-4*(4+_Z)/(8+3*_Z))^(1/3)*_Z+2^(2/3)*3^(2/3)-16*(_Z/(8+3*_Z))^(2/3)*(-4*(4+_Z)/(8+3*_Z))^(1/3), 1.302775638+0.*I)

 

1.302775638

(6)

NULL

 

NULL


 

Download allvalues.mw

Maple formats output depending on typesetting options "extened" and "standard" for the GUI (or interface). An example taken from

restart;
ts_standard:=proc(k::anything)
     interface(typesetting=standard):
     print(k);
     interface(typesetting=extended): 
     NULL;
end proc:
k:=3/8*ln(55/52)+sin(x)+3/4*exp(x);
                    3   /55\            3       
               k := - ln|--| + sin(x) + - exp(x)
                    8   \52/            4       

ts_standard(k);
                               

Why is the input two times returned and why one time as a list?
Somehow the first interface statement is responsible for that.

I am only interested in the reformated input inside the list.
Is it possible to fix the code?

Other observation with typesetting=standard:

restart;
interface(typesetting=standard);
expr:=cos(x)^2;
((x->x)=combine[trig])(expr);
                      

((x->x)=combine[trig])(expr);#subsequent call
                          2   1            1
                    cos(x)  = - cos(2 x) + -
                              2            2

(with Maple 2024.1 this only accurs in Math-1D)
but

restart;
expr:=cos(x)^2;
interface(typesetting=standard);
((x->x)=combine[trig])(expr);
                                      2
                        expr := cos(x) 

                            extended

                          2   1            1
                    cos(x)  = - cos(2 x) + -
                              2            2

GUI state after interupting with :

After switching to untitled 17 and back to test_timeout:

Sometimes it is necessary to switch back and forth twice.

Does this mean that the kernel did not receive the interupt?

For the legend in the image below I would have expected a black image and not a white

 

 

1 2 3 4 5 6 7 Last Page 1 of 29