nm

11643 Reputation

20 Badges

13 years, 144 days

MaplePrimes Activity


These are replies submitted by nm

@acer 

Yes this is much simpler. For Pi/2<x and x<Pi only it differentiates back to 1/sqrt(sin(x))

anti:=-sqrt(2)*EllipticF(sqrt(2)*sqrt(sin(x)/(1 + sin(x))), sqrt(2)/2);
simplify(diff(anti,x)) assuming Pi/2<x and x<Pi

But Mathematica's anti seems to be valid for all x according to it:

@Carl Love 

yes, I thought it was strange that solve gives duplicate solutions also, that is why I put it in set. But I did not mention it, as I thought this could happen, even though I have not seen it before myself.

This came about when I was looking at integration of 1/sqrt(sin(x)) trying to see why can't get same solution as Mathematica's which is much simpler but I gave up

int(1/sqrt(sin(x)),x)

 

Integrate[1/Sqrt[Sin[x]], x]

Doing some checking, I do not think Mathematica's EllipticF and Maples' EllipticF are defined the same way. 

But at the end I  could not find a way to make Maple's solution as simple as Mathematica's.

I did not know one can use (*  and *) in Maple to comment out multiline code. This must have been added to Maple in recent versions.

What I do is simply add  `if false then` before the code to be commented out and add `fi;` at the end.

if false then 
   lots of code here
   lots of code here
fi;

As long as code inside is valid Maple code, this has same effect as commenting it out.

@segfault 

You could try to submit a bug report on this to Maplesoft customer support.

May be no one have asked officially for this change before.

I can't imagine it will be hard to add an option to change the length of recent files to display.

@C_R 

If I change the unkowns to a set instead of a list in the first attachement, in both cases an empty result is returned.

Not for me.

I actually had used set initially, changed to list when copying the example from my code. 

You must be using something else other than V 2024 Maple?  Here is worksheet showing that with set. It still hangs when using c__1,c__2 if dsolve(diff(y(x),x$9)=1,arbitraryconstants=subscripted); is issued first. 

It would be more buggy if using SET vs. LIST made difference I would think?

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 1744 and is the same as the version installed in this computer, created 2024, April 17, 19:33 hours Pacific Time.`

restart;

19628

dsolve(diff(y(x),x$9)=1,arbitraryconstants=subscripted);

y(x) = (1/362880)*x^9+(1/40320)*c__1*x^8+(1/5040)*c__2*x^7+(1/720)*c__3*x^6+(1/120)*c__4*x^5+(1/24)*c__5*x^4+(1/6)*c__6*x^3+(1/2)*c__7*x^2+c__8*x+c__9

eqs:=[-1/2*arctanh(1/2*sqrt(1 + 2*c__1)*sqrt(2)/sqrt(c__1))*sqrt(2)/sqrt(c__1) = c__2, 1 = (-exp(2*c__2*sqrt(c__1)*sqrt(2)) + 1)*sqrt(c__1)*sqrt(2)/(exp(2*c__2*sqrt(c__1)*sqrt(2)) + 1)];
unknowns:={c__1,c__2};
time();
C_sol:=[timelimit(60,solve(eqs,unknowns))];
time()

[-(1/2)*arctanh((1/2)*(1+2*c__1)^(1/2)*2^(1/2)/c__1^(1/2))*2^(1/2)/c__1^(1/2) = c__2, 1 = (-exp(2*c__2*c__1^(1/2)*2^(1/2))+1)*c__1^(1/2)*2^(1/2)/(exp(2*c__2*c__1^(1/2)*2^(1/2))+1)]

{c__1, c__2}

159.625

Error, (in fsolve) time expired

229.375

restart; #try again but do not do the arbitraryconstants=subscripted now.

19628

eqs:=[-1/2*arctanh(1/2*sqrt(1 + 2*c__1)*sqrt(2)/sqrt(c__1))*sqrt(2)/sqrt(c__1) = c__2, 1 = (-exp(2*c__2*sqrt(c__1)*sqrt(2)) + 1)*sqrt(c__1)*sqrt(2)/(exp(2*c__2*sqrt(c__1)*sqrt(2)) + 1)];
unknowns:={c__1,c__2};
time();
C_sol:=[timelimit(90,solve(eqs,unknowns))];
time()

[-(1/2)*arctanh((1/2)*(1+2*c__1)^(1/2)*2^(1/2)/c__1^(1/2))*2^(1/2)/c__1^(1/2) = c__2, 1 = (-exp(2*c__2*c__1^(1/2)*2^(1/2))+1)*c__1^(1/2)*2^(1/2)/(exp(2*c__2*c__1^(1/2)*2^(1/2))+1)]

{c__1, c__2}

229.421

[]

229.562

#see? it finished instantly now.

 

 

Download why_solve_hangs_with_subscripted_SET_version_may_15_2024.mw

@Preben Alsholm 

Number 7, however, certainly shows a weakness that should be handled.

I think just adding a check for `+` is all is needed. I removed none differential equations from the tests. Now it passes all.

q:=proc(eq::equation,yx::function) 
  local res,T; 
  T:=(lhs-rhs)(eq);
  if not has(eq,diff) or not T::`+` then return eq end if;
  res:=selectremove(has,T,yx);
  res[1]=-res[2]  
end proc:

test_cases := [
   y(x) + diff(y(x),x) + cos(x) + g(y(x)) + diff(f(x),x) + 1/x = sin(x),
   diff(f(x),x) + 1/x = sin(x),  
   x*diff(y(x),x) + x = y(x) + diff(y(x),x$2),
   x^2 + 1/y(x) + diff(y(x),x) + sin(x) = y(x)^2,
   diff(y(x),x)= 0,
   diff(y(x),x$2)= 0,
   diff(y(x),x$2)+1= 0,
   1/diff(y(x),x$2)+1= 0,
   1/diff(y(x),x$2)= 0,
   diff(y(x),x$2) = y(x) - x];

Now

convert(map(X->[X,q(X,y(x))],test_cases),Matrix)

gives

 

 

@Preben Alsholm 

Yes, passing the undetermined function (say y(x) ) is what I would also do. This simplifies things. But I am afraid your updated function still fails on some cases.

q:=proc(eq::equation,yx::function) local res;
  if not has(eq,diff) then return eq end if;
  res:=selectremove(has,(lhs-rhs)(eq),yx);
  res[1]=-res[2]  
end proc:

test_cases := [
   y(x) + diff(y(x),x) + cos(x) + g(y(x)) + diff(f(x),x) + 1/x = sin(x),
   diff(f(x),x) + 1/x = sin(x),
   y(x) + x = 0,
   x*diff(y(x),x) + x = y(x) + diff(y(x),x$2),
   x^2 + 1/y(x) + diff(y(x),x) + sin(x) = y(x)^2,
   1 + x = 0,
   diff(y(x),x)= 0,
   diff(y(x),x$2) = y(x) - x,
   sin(x)+y(x)=0];

Now

convert(map(X->[X,q(X,y(x))],test_cases),Matrix)

Gives

@Preben Alsholm 

You have a sign error

 

p(diff(y(x),x)+x=0)

gives

Should be   -x on the RHS. I think you should have res[1]=-res[2] instead.  But I have not tried it on more examples.

I also tricked your function a little, and now it fails with 

ode:=y(x)+diff(y(x),x$2)+diff(f(x),x)=sin(x);
p(ode);

Error, (in p) invalid input: has expects 2 arguments, but received 3

 

 

@Kitonum 

Does not quit work.

P(y(x)+diff(y(x),x$2)+x=sin(x))

gives

The y(x) should be on the left side. OP said

and all source terms to be moved to the right side 

Which implies any terms without the dependent variable or its derivative.

 

@Joe Riel 

I consider this a bug and have previously reported it as such.

fyi, here we are, 2 years later and it is still not fixed in Maple 2024.

Btw, Is Maplesoft still doing enhancements and additions to the object oriented features in Maple or has work on this stopped may be due to lack of resources?

@Joe Riel 

Thanks. this helps. Do you know how to make it replace all such occurances in the string and not just the last one? Something similiar to

StringTools:-SubstituteAll

But for regular expression? For example given this input

s:="\\textrm{A} {test} ":

Your code works fine

s:="\\textrm{A} {test} ":
S := StringTools:-RegSubs("(.*)\\\\textrm\\{([^}]*)\\}(.*)" = "\\1\\begin{minipage}{\\linewidth}\\textrm{\\2}\\end{minipage}\\3", s);

But with this input

s:="\\textrm{A} \\textrm{B} {test} ":

It only changed the second one

s:="\\textrm{A} \\textrm{B} {test} ":
S := StringTools:-RegSubs("(.*)\\\\textrm\\{([^}]*)\\}(.*)" = "\\1\\begin{minipage}{\\linewidth}\\textrm{\\2}\\end{minipage}\\3", s);

I want all matching regular expressions to change, just like substituteall. Can this still be done using regular expression in Maple? The strange thing is that help page says

command replaces each occurrence of a substring matching the left-hand side

Notice the word "each" above. So I expected it to work as is.

@sursumCorda 

Thanks. Unfortunately this does not work all the time. Here is an example

s:="A& {test} & \\textrm{The fundamental matrix has } &C & {test} ":

StringTools:-RegSubs("(.*)\\\\textrm\\{(.*)\\}(.*)" = "\\1\\begin{minipage}{\\linewidth}\\textrm{\\2}\\end{minipage}\\3", s);

It gives

It did not match the first closing }.   

May be this is what you meant by the follow up you had where you said there is a problem.  

I need to do this inside Maple. So using Python afterwords will not really work for my workflow.

 

@ecterrab 

Ok, that is fair enough for this one example 

ode:=diff(y(x),x)=(y(x)-3)^2;  

But then why did Maple then say y=3 is singular solution when using Lie method?

Also for the second example I shown

ode:=diff(y(x),x)=2*x*sqrt(1-y(x)^2);

with y=1, y=-1. These can not be obtained from the general solution for any value of c. 

I have dozens more examples I can show if you like where 

'singsol'=all

does not produce singular solutions. So I am not sure now if one needs to use Lie method always to see singular solution or not. I also have examples where Maple gives singular solution without the option 'singsol' at all. Here is one

dsolve(ode,y(x))
dsolve(ode,y(x),'singsol'=all)
dsolve(ode,'Lie','singsol'=all)

All the above produce singular solutions y=r, y=-r. So the first command should not have produced these, since the option singsol was not used.

It is not possible to obtain y=r,y=-r from general solution for any value of c.

So for me, it is just confusing how and when singsol is supposed to work in Maple.

@vv 

I do not understand. if do as you suggested, I get wrong solution like I did before

ode:=x*y(x)*diff(y(x), x) = (x + 1)*(y(x) + 1);
ic:=y(1) = 1;
sol_no_IC:=dsolve(ode,'implicit');
eq:= eval(sol_no_IC,[y(x)=1,x=1]);
PDEtools:-Solve(eq,c__1);
eval(sol_no_IC,%);
PDEtools:-Solve(%,y(x));
odetest(%,[ode,ic])

 

I am looking for an algorithmic approach, not trial and error. I know Maple used -1 branch when plugging in the constant of integration. I just do not know how to decide to use -1 or 1 or 0 for LambertW after finding the constant of integration and before plugging the constant back into the generate solution. i.e. Why Maple decided to use -1 branch when doing so?

well, Maple is made of the front end process and the engine process. These are completely separate processes. They communicate using interprocess communication. The engine is what server.exe is. The memory shown on the botton of the worksheet is for the frontend (how much ram used for content of the worksheet itself and for the front end process itself).  

So these ofcourse will be different memory as they are different processes. In the windows task manger, the front end process is the one that has the little Java icon next to it. The engine is called server.exe. If you have many worksheets open and have set the option to use separate engine for each, then you will see many server.exe's running but one front end process.

First 18 19 20 21 22 23 24 Last Page 20 of 90