nm

8552 Reputation

19 Badges

13 years, 36 days

MaplePrimes Activity


These are questions asked by nm

I gave up. Spend 40 minutes trying everything and can't figure the right syntax. 

I need to use indets to obtain all occurrences of specific function in expression. Such as sin() or cos() or ln(), etc...

The indets commands has the form indets(expression, type).

But what is the type of ln ? It is of function type. But this picks up all other functions in the expression. I tried specfun and could not make it work. For example

expr:=x+sin(x)+ln(y)+10+ln(x+y)^2;

I want  to obtain  {ln(y),ln(x+y)^2}

I tried

indets(expr,function); 
indets(expr,specfun(ln));

and many more. Since indets needs a name of a type in the second argument, then what is the type name for ln or sin or cos, etc... I can't use indential, it did not work, since it is not a symbol I am looking for. I could use patmatch, but I am trying to learn indets for all these things.

Do I need to use subsindets for this? I still do not know how to use subsindets.

Maple 2019.1

I like using Record in Maple. It allows me to collect related variables to pass around inside one object. (Like with Pascal or Ada records or C struct).

But I find myself copying the record definition over and over everywhere I want to use the same specific record layout.

Is there a way to define specific record layout somewhere, may be as a type and give it a name, and then in each proc I want to make a variable of this record type, just tell Maple that this variable is a record of that type so I do not have to explicity define the record there each time? 

Here is a simple example to make it more clear

foo:=proc() #some proc that uses same Record layout
   local S;
   S:=Record('name','age');   
   S:-name:="joe doe 1";
   S:-age:=99;
   return S;
end proc:

boo:=proc() #another proc that wants to use same Record layout
   local S;
   S:=Record('name','age');   
   S:-name:="joe doe 2";
   S:-age:=80;
   return S;
end proc:

S1:=foo();
S2:=boo();

These proc's can be anywhere, such as inside package or module, either local or exported.

I just want to avoid having to type   S:=Record('name','age');   Each time. I want to tell Maple that a local variable is of this specific Record layout, without having to type the layout explicitly.

This way, when I add new field to this Record,  I just have to do it in one place and not in 10 places in the code. 

I think I need to add a new type? But do not know how to do this.  I hope the question is clear. If not, will add more information.

 

This ODE turns out to be a simple separable ODE. With one solution, if the ODE is rewritten.

But in its original form, Maple dsolve gives 6 complicated looking solutions with complex numbers in some of them. Even though all 6 solutions are valid.

Any one knows why Maple did that and not give the one simple solution instead? 

I used isolate to solve for y' from the original ODE. Verfiied that only one solution exist.  The ODE then became y'(x)= 3*y(x)/(2*x). Which by uniqueness theorem, should have one unique solution in some region in the RHS or in some region in the LHS that does not inculde x=0 ?

Just wondering what is going on, and why Maple did not give same simpler solution, so I can learn something new. That is all.

restart;

Typesetting:-Settings(typesetprime=true):

ode:= 1/2*(2*x^(5/2)-3*y(x)^(5/3))/x^(5/2)/y(x)^(2/3)+1/3*(-2*x^(5/2)+3*y(x)^(5/3))*diff(y(x),x)/x^(3/2)/y(x)^(5/3) = 0;

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

DEtools:-odeadvisor(ode);

[[_1st_order, _with_linear_symmetries], _exact, _rational]

maple_sol:=dsolve(ode);

y(x) = (1/3)*2^(3/5)*3^(2/5)*(x^(5/2))^(3/5), y(x) = (1/3)*(-(1/4)*5^(1/2)-1/4-((1/4)*I)*2^(1/2)*(5-5^(1/2))^(1/2))^3*2^(3/5)*3^(2/5)*(x^(5/2))^(3/5), y(x) = (1/3)*(-(1/4)*5^(1/2)-1/4+((1/4)*I)*2^(1/2)*(5-5^(1/2))^(1/2))^3*2^(3/5)*3^(2/5)*(x^(5/2))^(3/5), y(x) = (1/3)*((1/4)*5^(1/2)-1/4-((1/4)*I)*2^(1/2)*(5+5^(1/2))^(1/2))^3*2^(3/5)*3^(2/5)*(x^(5/2))^(3/5), y(x) = (1/3)*((1/4)*5^(1/2)-1/4+((1/4)*I)*2^(1/2)*(5+5^(1/2))^(1/2))^3*2^(3/5)*3^(2/5)*(x^(5/2))^(3/5), x/y(x)^(2/3)+y(x)/x^(3/2)+_C1 = 0

map(x->odetest(x,ode),[maple_sol])

[0, 0, 0, 0, 0, 0]

solve(ode,diff(y(x),x),AllSolutions)

(3/2)*y(x)/x

ode2:=isolate(ode,diff(y(x),x)); #solve for y' first

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

ode2:=simplify(ode2)

diff(y(x), x) = (3/2)*y(x)/x

DEtools:-odeadvisor(ode2);

[_separable]

sol:=dsolve(ode2)

y(x) = _C1*x^(3/2)

odetest(sol,ode2)

0

 

Download strange_ode_answer.mw

Maple 2019.1

Physics 395

This is an ode from text book.  The little tricky part on this is the right hand has abs on the dependent variable, otherwise it is trivial.

restart;
ode:=diff(y(x),x) = abs(y(x))+1;
sol:=dsolve(ode,y(x))

Gives

I am not able to get odetest to give zero on either of the two solutions.  

odetest(sol[1],ode);
odetest(sol[2],ode);

None give zero. I tried assumptions on x>0, x<0 and tried simplify(...,symbolic), nothing gives zero.

Now the book gives the solutions without constant of integration, which is strange. This is what the book gives as solution

                 y(x) = exp(x)-1   x>=0
                 y(x) = 1-exp(-x) x<0

Which is the same as Maple's solution, but without the constant of integration! So when I removed _C1 from both solutions and added the assumptions on x, then I got zero

odetest(subs(_C1=1,sol[1]),ode) assuming x<0;
                      0

odetest(subs(_C1=1,sol[2]),ode) assuming x>=0
                      0

I solved this by hand, and got same solution as Maple actually (may be I made the same mistake as Maple? :) 

But the above shows these solution are not correct? I do not now know what happend to the constant of integration in the book solution since it only shows final solution. It looks like book just used C=1 for the constant of integration. But Maple also thinks the book solution is correct.

fyi, the implicit solution by Maple does verify with no problem:

ode:=diff(y(x),x)=abs(y(x))+1;
sol:=dsolve(ode,y(x),'implicit');
odetest(sol,ode)

             0

Any one can shed some light what is going on? Is Maple solution correct? If so, why it does not verify? Should Maple have given the book solution?

this is problem 9, page 15, "Elementary differential equations" by William F. Trench, 2001

Maple 2019.1

given an expression such as expr:=-1/2*x*(y^2-1) which in tree form will be

I can get -1/2 using op(1,expr).   I need command to return the "rest" of the right side of the tree, all of it, not matter how big.

I tried op(2..nops(expr),expr) and that returns x, y^2 - 1 

Is there a way to return directly x*(y^2-1)*etc....  so I do not have to play around with the above expression sequence?  Another option is to type

           expr/op(1,expr)

to get the right side of the tree. But this seems like a hack. Do not like to divide. worry about zero.

The same thing if the type was `+`, I want to get  the whole right side in one command.

Again, I can do  expr-op(1,expr) to get the whole right side. But this also seems like  a hack, altought not as bad as with  the case above

Any hints on how to best do these things?

Maple 2019.1

 

 

 

First 101 102 103 104 105 106 107 Last Page 103 of 164