nm

10219 Reputation

19 Badges

12 years, 147 days

MaplePrimes Activity


These are questions asked by nm

I can't figure this out. Same exact patmatch works in global worksheet. But fails inside a proc.

I am using same exact code. In proc, I am doing    a::anything where `a` is now local symbol ofcourse. In worksheet, it is global ofcourse. I make sure I clear `a` in worksheet each time also.

So why it pathmatch fail in the proc? I must be doing something wrong but do not see it.,
 

26148

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

restart;

26148

a:='a':
stat:=0^n:

if patmatch(stat,0^a::anything) then
     0;
  else
     stat;
  fi;

0

foo:=proc(stat)
  local a;
  if patmatch(stat,0^a::anything) then
     0;
  else
     stat;
  fi;
end proc:

#why this does not return zero as expected?
foo(stat)

0^n

 


Here is screen shot in debugger showing patmatch failed inside the proc

 

Very strange. What do I need to change in the proc to make it work as in worksheet? 

Download patmatch_in_proc.mw

Is the following valid result from odetest? is returns 0^n when 0 was expected.

Is this a bug or valid result? Maple solution is correct, so I expected 0 only not 0^n as result.

25748

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1756 and is the same as the version installed in this computer, created 2024, June 5, 19:39 hours Pacific Time.`

ode:=diff(y(x), x)^n = 0

(diff(y(x), x))^n = 0

sol:=dsolve(ode)

y(x) = c__1

odetest(sol,ode)

0^n

odetest(sol,ode) assuming n::real

0^n

odetest(sol,ode) assuming n>0

0^n

 

 

Download strange_odetest_result_june_6_2024.mw

Update

Until this bug is fixed, I added the following to my code which checks for odetest result. it looks for 0^anything and changes it to 0. 

ode:=diff(y(x), x)^n= 0;
sol:=dsolve(ode);
stat:=odetest(sol,ode);
if patmatch(stat,0^a::anything) then 0; else stat; fi

gives    0

I found this problem when using odetest to check mysolution for this ode and was not getting 0 as expected,.

 

These two expressions are the same

e1:=-sqrt(-(exp(-2 + 2*x) - 2)*exp(-2 + 2*x))/(exp(-2 + 2*x) - 2);
e2:=1/sqrt(2*exp(-2*x)*exp(2) - 1);

Is there an automated way to simplify e1 to e2? Below are my attempts. The closest I got is 

simplify(e1) assuming real;

But that still does not give same as e2. I can do it by "hand" as shown. But I like to find automated way since this is done in code without looking at expression. So I can't use the "hand" method there.

We can assume everything in real domain.


 

15244

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

e1:=-sqrt(-(exp(-2 + 2*x) - 2)*exp(-2 + 2*x))/(exp(-2 + 2*x) - 2);
e2:=1/sqrt(2*exp(-2*x)*exp(2) - 1);
plot([e1,e2],x=-3..3)

-(-(exp(-2+2*x)-2)*exp(-2+2*x))^(1/2)/(exp(-2+2*x)-2)

1/(2*exp(-2*x)*exp(2)-1)^(1/2)

simplify(e1,size);
simplify(e1,symbolic);
simplify(e1) assuming real; #closest but still no cigar
 

-(-(exp(-2+2*x)-2)*exp(-2+2*x))^(1/2)/(exp(-2+2*x)-2)

-I*exp(-1+x)/(exp(-2+2*x)-2)^(1/2)

exp(-1+x)/(-exp(-2+2*x)+2)^(1/2)

#can do it "by hand" by dividing upstairs and downstrais by numerator
A:=exp(-1 + x);
B:=-exp(-2 + 2*x) + 2;
e3:=1/sqrt( simplify(expand(B/A^2)))

exp(-1+x)

-exp(-2+2*x)+2

1/(-1+2*exp(2-2*x))^(1/2)

#verify
plot([e3,e2],x=-3..3)

 

 


Download simplification_june_6_2024.mw

We see that this ode (x + y(x))*(1+diff(y(x),x)) = 0  has 2 solutions, One when (x + y(x))=0 and one when (1+diff(y(x),x))=0. Maple gives 3 solutions. They are correct but why?

Also when changing (1+diff(y(x),x)) to (a+diff(y(x),x)) now it gives only two solution.

Why does this happen? Should it not just return 2 solutions in both cases? and more strange one

(x + y(x))^2 *(1+diff(y(x), x))=0; now it gives 4 solutions. But this is no different. We also have 2 solutions. One when (x + y(x))=0 and one when (1+diff(y(x), x))=0. This time the extra two solutions are complex. 

17168

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1754 and is the same as the version installed in this computer, created 2024, June 3, 20:39 hours Pacific Time.`

ode:=(x + y(x))*(a+diff(y(x),x)) = 0;
dsolve(ode);
map(X->odetest(X,ode),[%])

(x+y(x))*(a+diff(y(x), x)) = 0

y(x) = -x, y(x) = -a*x+c__1

[0, 0]

ode:=(x + y(x))*(1+diff(y(x),x)) = 0;
dsolve(ode);
map(X->odetest(X,ode),[%])

(x+y(x))*(1+diff(y(x), x)) = 0

y(x) = -x, y(x) = -x-c__1, y(x) = -x+c__1

[0, 0, 0]

ode:= (x + y(x))^2 *(1+diff(y(x), x))=0;
dsolve(ode);
map(X->odetest(X,ode),[%])

 

(x+y(x))^2*(1+diff(y(x), x)) = 0

y(x) = -x, y(x) = -x+c__1, y(x) = -(1/2)*c__1-((1/2)*I)*3^(1/2)*c__1-x, y(x) = -(1/2)*c__1+((1/2)*I)*3^(1/2)*c__1-x

[0, 0, 0, 0]

 

 

Download why_extra_solution_from_dsolve_june_5_2024.mw

Any idea why this sometimes happens? odeadvisor says ode is quadrature but when asking it to solve it using quadrature sometimes it works and sometimes not.

Am I doing something wrong?

22020

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1754 and is the same as the version installed in this computer, created 2024, June 3, 20:39 hours Pacific Time.`

restart;

18368

Example 1 that does not work

 

ode:=diff(y(x),x)=-1;
DEtools:-odeadvisor(ode);

diff(y(x), x) = -1

[_quadrature]

sol:=dsolve(ode,y(x),['quadrature']);

"sol := "

Example 2 that works

 

ode:=diff(y(x),x)=x;
DEtools:-odeadvisor(ode);

diff(y(x), x) = x

[_quadrature]

sol:=dsolve(ode,y(x),['quadrature']);

y(x) = (1/2)*x^2+c__1

 

 

Download sometimes_dsolve_works_on_quadrature_june_5_2024.mw

First 15 16 17 18 19 20 21 Last Page 17 of 186