C_R

3412 Reputation

21 Badges

5 years, 314 days

MaplePrimes Activity


These are questions asked by C_R

Recently there have been some questions about the unit packages. I would like to add another one that has been on my desk for a while.

The Simple environement overloads the command frem and piecewise. The "most powerful" (can we say so?) environement Standard does not

{with(Units:-Simple)[]} minus {with(Units:-Standard)[]}
                       {frem, piecewise}

For example calculating the remainder of a length in mm does not work in the Standard environment

restart;
with(Units:-Simple):
convert(frem(1.234*Unit(m),Unit(cm)),units,mm);
                      4.000000000 Unit(mm)

restart;
with(Units:-Standard):
convert(frem(1.234*Unit(m),Unit(cm)),units,mm)
Error, invalid input: frem received 1.234*Units:-Unit(m), which is not valid for its 1st argument, x

Why is that?

I am looking for commands that extract from a product the value and the unit.
For example:
How to get 1.65 and m/s^2 from

g_moon := 1.635000000*Unit(('m')/'s'^2)

I was probably looking in the wrong place in Maples unit documentation.
I am not interested in lowlevel commands like op(g_moon)[1]. Something more self-explaining like GetUnit.

Is the a print or plot function that can generate from an expression an expression tree

and/or the corresponding expression DAG

 

Taken from ?ProgrammingGuide,Chapter02

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

First 13 14 15 16 17 18 19 Last Page 15 of 44