nm

3646 Reputation

17 Badges

7 years, 362 days

MaplePrimes Activity


These are questions asked by nm

Given some expression, I want to replace each exp(.....) in it with something else.

This is what I currently do. First I find all the exp() terms, then using a loop and use subs  like this

restart;
expr:=1/exp(z)*arcsinh(x*exp(C[1]))+x*sin(exp(x))+3*exp(C[1]*y)*sqrt(sin(exp(3*h)));

#find all exp terms
s:=select(x->has(x,exp),indets(expr));
s:=select(x->op(0,x)='exp',s)

Now, lets says I want to replace each with Z

I tried to use but that did not work.

So now I am doing this

for item in s do
    expr:=subs(item=Z,expr);
od:
expr

is it possible do this without a loop? could not do it using ~

With map, I can do this map(x->subs(x=Z,expr),s) but this does not replace it inside expr where I want. 

Assignment is not allowed inside the above so I can not do  this map(x->expr:=subs(x=Z,expr),s)

And if I do expr:=map(x->subs(x=Z,expr),s)  it does not work either. it gives

 

How to do the replacement without using a do loop? 

 

 

 

This is the Maple code

restart;
result:=int(1/tanh(u),u)

simplify(result,size) ;
simplify(result,symbolic);
simplify(result,ln);
simplify(result,trig);

Any suggestions?

 

 

I can't figure out how Maple obtained this solution and looking for some ideas to try.

It is first order non-linear ode in y(x), which is separable.

ode:=diff(y(x),x)=x*ln(y(x));
dsolve([ode,y(1)=1],y(x))

But the general solution is

sol:=dsolve(ode)

Setting up manually an equation using the given condition in order to solve for _C1, produces no solution. 

eq:=subs([y(x)=1,x=1],sol);
solve(eq,_C1)

Warning, solutions may have been lost
 

Also 

coulditbe(exp(RootOf(1 + 2*Ei(1, -_Z) + 2*_C1))=1)

   FAIL

So how did Maple solve for the constant of integration which results in particular solution y(x)=1 that is supposed to satisfy the condition y(1)=1?  

It is clear that y(x)=1 satisfies the ODE itself. But I am asking about how it also satisfies y(1)=1

(odetst says it does satisfy the ODE and condition as well. So Maple must have done something very smart under the cover)

Next I tried

ode:=diff(y(x),x)=x*ln(y(x));
sol:=dsolve(ode,y(x));
sol:=DEtools:-remove_RootOf(sol);
sol:=subs([y(x)=1,x=1],sol)

And now

solve(sol,_C1)

Error, (in Ei) numeric exception: division by zero
 

Just wondering how did Maple decide that y(x)=1 satisfies y(1)=1? I do not see it.

Using Maple 2020.1. But same result on Maple 2019

From help, it says

coulditbe routine returns true if there is a possible value of x1 that satisfies prop1

my question is, how to find out this condition/possible values that Maple found?  This infomration is very useful, but now I do not see how to obtain it. All what coulditbe retuirn is true or false.

Context of why I am asking:  Sometimes odetest do not verify its own solutions. And coulditbe can help in finding under what conditions the solution can satisfy the ode. Here is an example

restart;
ode:=diff(y(x),x) = abs(y(x))+1;
solExplicit:=dsolve(ode);
offset := odetest~([solExplicit],ode)

gives

[exp(-x)/_C1 - abs((-exp(-x) + _C1)/_C1) - 1, exp(x)*_C1 - abs(exp(x)*_C1 - 1) - 1]

Both solution fail odetest. 

coulditbe~(offset,0)

gives true

So there are assumptions/conditions which makes the solution satisfy the ODE. In this case, by inspection one can see what these conditions are. They are, for one solution:

(-exp(-x) + _C1)/_C1  >0

and for the other, the condition is

exp(x)*_C1 - 1 >0

Under these assumptions, odetest would have given 0 for each odetest.

And it is this information I wanted to obtain automatically from coulditbe.

In Mathematica, Reduce is used for this. Reduce gives conditions under which something is satisfied. For example, 

Reduce[ C[1] Exp[x] - Abs[C[1] Exp[x] - 1] - 1 == 0, {x, C[1]}, Reals]

Gives

C[1] >= Exp[-x]


While the above in  Maple

coulditbe( C[1]*exp(x)- abs( C[1]*exp(x)-1)-1 = 0)

gives true  only, but without the important information, true under what conditions.

Is there a different command in Maple which could give this information?

 

restart;
sub:=x/C;
expr:=1/2*x*(p^2+a)/p;

And now

subs(p = sub, expr)

But

algsubs(p = sub,expr)

Notice one "p" is still not replaced. 

This is very annoying. I looked at help and did not see anything about this. I could have missed it. It looks like it does not replace "p" when it is in denominator:

algsubs(p = x,1/p)

Remains 1/p but 

subs(p = x,1/p)

gives 1/x as expected.

May be this is documented somewhere? But why it does this?

3 4 5 6 7 8 9 Last Page 5 of 82