nm

5646 Reputation

17 Badges

8 years, 277 days

MaplePrimes Activity


These are questions asked by nm

I need to find and remove any abs that shows up only inside ln anywhere in an expression.

I used to do this in multiple steps before, by using loop and subs. But I am now learning evalindet which is powerful command. I should use it more. 

I wanted to see if it is possible to do this in one call to evalindent. Both finding and replacing.

Here is an example. Given

expr:=sin(x)+ln(abs(x))+ln(x+abs(y)/sqrt(abs(x+3)))+ln(x^3)+cos(abs(x));

The goal is to change it to the following

This is what I ended up with

restart;
expr:=sin(x)+ln(abs(x))+ln(x+abs(y)/sqrt(abs(x+3)))+ln(x^3)+cos(abs(x));
expr:=evalindets(expr,
          'specfunc( satisfies(u->has(u,abs)),  ln)',
          f->evalindets(f,'specfunc(anything,abs)',f->op(1,f))
          )

My question is: Is there a more optimal or better way to do this? I had to use evalindets inside the transformer to remove the abs. At first I did not know if it will work, but it did work.

Any place for improvement?

Maple 2020.2

Given an expression, I want to obtain list of all functions in it, that contains as argument, anywhere another function.  

I can do this now using 2 steps. I was wondering if there is a way to do it in one call.

Here is an example.

expr:=sin(x)+ln(abs(x))+ln(x+1/sqrt(abs(x+3)))+ln(x^3);

The goal is to find all ln functions, with abs inside them. Now, I do this

restart;
expr:=sin(x)+ln(abs(x))+ln(x+1/sqrt(abs(x+3)))+ln(x^3);
lis:=indets(expr,'specfunc(anything,ln)');
select(Z->has(Z,abs),lis)

I could not find a way to do it in one call, If I do this

indets(expr,'specfunc(abs(anything),ln)');

it only finds

Which overlooked the other one, since abs there is elsewhere in side ln.

I looked at help Definition of a Structured Type in Maple but do not know yet if there is an option there to do this. 

Is it possible to do this on one call?  Just wondering, that is all. The above works OK for me now.

 

Maple 2020.2

Is there one place which summarizes major difference between using solve vs. PDEtools:-Solve to solve equation? (ofcourse can one read help for both commands, and try to figure the differences this way, but this is not as easy as it sounds. I was looking more for a short basic summary type list. So I am making one myself in my maple cheat sheet).

I am trying to switch to PDEtools:-Solve from solve, but I keep noticing strange differences. Here is an example

example A

restart;
ode:=(x+1)*diff(y(x),x)+y(x)^(1/2) = 0;
ic:=y(0) = 1;
sol:=dsolve([ode,ic],y(x));
check:=odetest(sol,ode);
PDEtools:-Solve(check=0,x) assuming x>-1,x<6

Error, (in assuming) when calling 'PDEtools:-Solve'. Received: 'not a system with respect to the unknowns {x}'

Compare to 

restart;
ode:=(x+1)*diff(y(x),x)+y(x)^(1/2) = 0;
ic:=y(0) = 1;
sol:=dsolve([ode,ic],y(x));
check:=odetest(sol,ode);
solve(check=0,x) assuming x>-1,x<6;

                               x

Now, back to first example above using Solve. I moved the assuming inside, and now the error went away

Example B

restart;
ode:=(x+1)*diff(y(x),x)+y(x)^(1/2) = 0;
ic:=y(0) = 1;
sol:=dsolve([ode,ic],y(x));
check:=odetest(sol,ode);
PDEtools:-Solve(check=0,x,assume=[x>-1,x<6]);

But I noticed I can not do the same with solve. i.e. move the assuming inside solve, it now gives an error

restart;
ode:=(x+1)*diff(y(x),x)+y(x)^(1/2) = 0;
ic:=y(0) = 1;
sol:=dsolve([ode,ic],y(x));
check:=odetest(sol,ode);
solve(check=0,x,assume=[x>-1,x<6]);

Error, invalid input: too many and/or wrong type of arguments passed to solve; first unused argument is assume = [-1 < x, x < 6]

So first difference is that one can use assume= inside Solve, but not inside solve. Which is fine.

But I still not sure why first example A above gives error with Solve but not with solve. Any idea why that is?  Notice that example A gives an error with Solve, only when adding x<6 to the assumption. So this works

restart;
ode:=(x+1)*diff(y(x),x)+y(x)^(1/2) = 0;
ic:=y(0) = 1;
sol:=dsolve([ode,ic],y(x));
check:=odetest(sol,ode);
PDEtools:-Solve(check=0,x) assuming x>-1

No error, and now it gives

But was trying to find why it failed when adding x<6

Maple 2020.2 on windows 10.


 

This ode

restart;
ode:=(x+1)*diff(y(x),x)+y(x)^(1/2) = 0;
ic:=y(0) = 1;
sol:=dsolve([ode,ic],y(x))

Direct use of odetest does not give zero.

res:=odetest(sol,ode)

When asking Solve for possible values of x which makes the above zero, it only gave the upper bound

PDEtools:-Solve(res=0,x)

The actual range which makes res=0 is actually -1<x<exp(2)-1

res:=odetest(sol,ode) assuming -1<x,x<exp(2)-1

How could one using Maple obtain this range -1<x<exp(2)-1? 

Mathematica gives the answer using Reduce:

res=Log[Sqrt[x+1]]-1+Sign[Log[(x+1)]-2]*Log[Sqrt[x+1]]-Sign[Log[x+1]-2];
Reduce[res==0,x,Reals]

Is it possible to obtain such result in Maple, since Solve did not give complete answer.

Maple 2020.2

I do not underand why these two gives different results

restart;
mysol:= exp(sqrt( y(x)^2/x^2+1)) = _C1*x;
ode:=diff(y(x),x) = (y(x)^2+(x^2+y(x)^2)^(1/2)*x)/x/y(x);

And now case A:

simplify(odetest(mysol,ode)) assuming x>0;

                  0

But case B

res:=odetest(mysol,ode):
simplify(res) assuming x>0;

      #does not give zero

 

Why is putting the result in a variable first makes it give a different result?

What should one do so both case A and B give 0 ?

It looks like scoping issue of assuming. But this is really confusing, I did not expect that putting an intermediate result in a variable first will make a difference.

Maple 2020.2, Physis 897

4 5 6 7 8 9 10 Last Page 6 of 114