nm

11353 Reputation

20 Badges

13 years, 12 days

MaplePrimes Activity


These are replies submitted by nm

@acer 

thanks. It works. But debugging it, I am not able to figure how the recursive calls happen untill all terms f(a)+f(b) are exhausted in the input.

For example

expr:=sin(x)+f(A)+f(B)+10*exp(x)/13+cos(x)+1/(f(C)+f(10*C))+g/(f(h)+f(n));
R(expr)

In the debugger, first time u := selectremove(type,ee,specfunc(f)); is called, I see u[1]=f(C)+f(10*C), and u[2]=0. Then it does f(subsindets(u[1],specfunc(f),op) which returns f(11C) but now on the next step in the debugegr, I see it calling proc(ee) again and doing u := selectremove(type,ee,specfunc(f)); which now gives u[1]=f(h)+f(n), and u[2]=0 and it jeep doing this until it hits u[1]=0.

My question is, how is proc(ee) being called repeatedly like this? I do not see anywhere an explict recusive call.  

Is the original expr -> subsindets(expr,`+`, causing this to happen automatically ? 

It looks like magic to me how it is done. But it works very well. Just trying to understand how it works. i.e. how is causing the recursive calls to happen so I can extend it to other uses I wanted.

@Hullzie16 

What variable are you trying to solve for?

from help

If you do not specify the variables parameter, Maple solves for all the variables that appear in equations, that is, indets(equations, name).

Example

restart;
expr := exp(a)+b+c+3*d;
sol:=solve(expr = 0,  useassumptions,allsolutions) assuming nonnegative;


   sol := {b = -exp(a) - c - 3*d, 0 <= a, 0 <= c, 0 <= d}

I want to output to 1/6. it outputs to sqrt(9)/18 

That is not what I get. it gives 1/6 not sqrt(9)/18

restart;
expr:= (sqrt(1+x)-3)/(x-8);
limit(expr,x=8)

 

Maple 2022.2

@mz6687 

 'Error, cannot determine if this expression is true or false:'

that is a common error. see this page

I had no idea Maple had elseif  

I've only used elif for the compund if statement. Where is this documented? I searched help and did not find it.

However, in actual.mw I may have a bunch of data that I don't want to wipe out with a restart. 

If you have spend a lot of time to generate the data, why not save it to a file? This way you can do restart, and later read it and continue from there. see the save comand on how to save variables to disk.

@ecterrab 

thanks for the fix. 

Those unnecessary parentheses got removed from the typesetting of expressions

May be everyone sees it differently, but to my eyes, the way it was before looks more pleasing and more clear than the current way. i.e. I find 

better looking and more clear than

But may be it is just me. At least now it compiles OK and that is the important part.

@acer 

using x::numeric makes the function accept  1/2 as input.

So now NC(1, 1/2); returns 1. 

But  1/2 is 0.5 and the only digit is

NC(1, 0.5);  returns correctly.

That is why I used 

the_num::{integer,float}

@emendes 

In the example you sent my old mac had no problem to run the code: "Time out ok" in 120.736 (quite close to twice the estipulated time)

Could you please try with higher timeouts? try 200 seconds for example, then 300 seconds? Does it freez after that? As I mentioned the time could be different depending on the PC/memory and other factors.

I am using Maple 2022.2 on windows.

@dharr 

Thanks for trying. If I understand you right, you did get it to freeze, but at longer timeout. It depends on the PC and how fast it is to get solve or timelimit into the code path where it hangs. I have fast PC so with me 60 seconds was enough.

The issue with using task manager to kill the server is secondary. For me, I had to do that as (!) click did not do it. It does turn gray, but the server.exe remains running at high CPU. So (!) did not kill the server.

The main issue is that depending on what timelimit is used, it can cause a freeze. So it is all non-determinstic. It is not possible to do large scale development in Maple this way.

Note I am not talking about timelimit taking a little longer to timeout than asked. This is not the issue. It is actual freezing, or taking 10 hrs when the timeout is 30 seconds. This is the main problem that Maplesoft seems unable to fix for 30 years now.

@Carl Love 

You are correct., According to definition it should be degree 2. Corrected the tests so they all now pass

tests:=[[diff(y(x),x)=y(x)^(1/2),1],
[diff(y(x),x$2)+diff(y(x),x)^(1/2)=y(x),2],
[(1+diff(y(x),x)^2)^(3/2)=diff(y(x),x$2),2],
[3*y(x)^2*diff( y(x),x)^3- diff(y(x),x$2)=sin(x^2),1],
[sqrt(1+ diff(y(x),x)^2)=y(x)*diff(y(x),x$3),2],
[sqrt(1+ diff(y(x),x)^2)=y(x)*diff(y(x),x$3),2],
[sin(diff(y(x),x))+ diff(y(x),x$2)+3*x,FAIL],
[exp(diff(y(x),x$2))+sin(x)*diff(y(x),x)=1,FAIL],
[k*diff(y(x),x$2)^2=(1+ diff(y(x),x$2)^2)^3,6],
[x*diff(y(x),x$2)^3*diff(y(x),x)-5*exp(x)*diff(y(x),x$2)+y(x)*ln(y(x)),3],
[2*ln(x)*diff(y(x),x)^2+7*cos(x)*diff(y(x),x$2)^4*diff(y(x),x)^7+x*y(x)=0,4],
[y(x)-x*diff(y(x),x)-1/2/diff(y(x),x)^2=0,3],
[diff(y(x), x, x) - a*(c + b*x + y(x))*(diff(y(x), x)^2 + 1)^(3/2) = 0,2]]:

for i from 1 to nops(tests) do 
  deg := ODE_degree(tests[i,1]);
  if deg <> tests[i,2] then
     print("Failed on ",tests[i,1]," .Expected degree ",tests[i,2]," got ",deg);
  else
     print("Passed on ",tests[i,1]," .Expected degree ",tests[i,2]," got ",deg);
   fi;
od:

 

@Carl Love 

Hello. I found a bug. Added it to tests.

For the following ode

Which clearly has degree 1 by just looking at it, since the highest derivative has degree 1.  But ODE_degree gives 2. I think this happens because the ODE_degree tries to normalize all powers to integers, so it squares the ode, resulting in (y'')^2 ? 

 

#see https://www.mapleprimes.com/questions/227477-Finding-Order-And-Degree-Of-ODE-In-Maple
ODE_degree:=proc(e::{algebraic, `=`(algebraic)})
 try
      (e-> degree(
         e, 
         indets(
            e, 
            'typefunc'(
               (O-> `if`(O>1, 'typefunc'('`@@`'(identical(D),O)), specfunc(D)))
                  (PDEtools:-difforder(e))
            )
         )
      ))
         (
            ((e::satisfies(e-> degree(e, indets(e, specfunc(Diff)))::posint))-> 
               convert(e,D)
            ) 
               (frontend(
                  numer@evala@':-Norm',
                  [convert((numer@`if`(e::`=`, lhs-rhs, x->x))(e), Diff)], 
                  [
                     {
                         specfunc(Diff), `+`, `*`, 
                         'satisfies'(e-> hastype(e, specfunc(Diff)))^rational
                     }, 
                     {}
                  ]
               ))
         )
   catch:
     FAIL;
   end try;
end proc;   

And

ode:=diff(diff(y(x),x),x)-a*(c+b*x+y(x))*(diff(y(x),x)^2+1)^(3/2) = 0;
ODE_degree(ode)

                          2

 

Here is the updated tests

tests:=[[diff(y(x),x)=y(x)^(1/2),1],
[diff(y(x),x$2)+diff(y(x),x)^(1/2)=y(x),2],
[(1+diff(y(x),x)^2)^(3/2)=diff(y(x),x$2),2],
[3*y(x)^2*diff( y(x),x)^3- diff(y(x),x$2)=sin(x^2),1],
[sqrt(1+ diff(y(x),x)^2)=y(x)*diff(y(x),x$3),2],
[sqrt(1+ diff(y(x),x)^2)=y(x)*diff(y(x),x$3),2],
[sin(diff(y(x),x))+ diff(y(x),x$2)+3*x,FAIL],
[exp(diff(y(x),x$2))+sin(x)*diff(y(x),x)=1,FAIL],
[k*diff(y(x),x$2)^2=(1+ diff(y(x),x$2)^2)^3,6],
[x*diff(y(x),x$2)^3*diff(y(x),x)-5*exp(x)*diff(y(x),x$2)+y(x)*ln(y(x)),3],
[2*ln(x)*diff(y(x),x)^2+7*cos(x)*diff(y(x),x$2)^4*diff(y(x),x)^7+x*y(x)=0,4],
[y(x)-x*diff(y(x),x)-1/2/diff(y(x),x)^2=0,3],
[diff(y(x), x, x) - a*(c + b*x + y(x))*(diff(y(x), x)^2 + 1)^(3/2) = 0,1]]:

for i from 1 to nops(tests) do 
  deg := ODE_degree(tests[i,1]);
  if deg <> tests[i,2] then
     print("Failed on ",tests[i,1]," .Expected degree ",tests[i,2]," got ",deg);
  else
     print("Passed on ",tests[i,1]," .Expected degree ",tests[i,2]," got ",deg);
   fi;
od:

All pass except the last one.

fyi, in Mathematica it is `Sin` and not `sin`

You could try the Mma translator also. But it does not know how to translate this to maple

MmaTranslator:-FromMma(`Cases[{Sin[x]/(Sin[2-x]+1)-12,Sin[x/2]^2},Sin[_],Infinity]`)

Warning, there is no Maple equivalent to Cases

So manual translation is needed in this case.

@ecterrab 

Sorry, but I have no idea what a TTY Maple is.

I open new worksheet and issue the command Physics:-Version(latest); and this always used to work. It gives a message that I need to close Maple and restart after that.

Recently this no longer works. But I tried the icon method and that worked now. So I will use that instead from now on.

Is the command Physics:-Version(latest); issued from a worksheet no longer supported? Here is a smal movie.

@ecterrab 

Thanks for the fix, I was going to try it, but I am still not able to update the Physics package. Is the server still down?

I closed all of Maple and restarted it 3 times, and each time I get

Error, (in Physics:-Version) unable to determine the Physics Updates version, could you please report the problem to support@maplesoft.com

Should I wait and try again some other time? Here is the worksheet attached so you can see. I am on windows 10

interface(version);

`Standard Worksheet Interface, Maple 2022.2, Windows 10, October 23 2022 Build ID 1657361`

Physics:-Version(latest);

Error, (in Physics:-Version) unable to determine the Physics Updates version, could you please report the problem to support@maplesoft.com

interface(version);

`Standard Worksheet Interface, Maple 2022.2, Windows 10, October 23 2022 Build ID 1657361`

ode:=exp(y(x))+cos(x)*y(x)+(exp(y(x))*x+sin(x))*diff(y(x),x) = 0;
sol1:=y(x) = -LambertW(x/(sin(x)*exp(_C1/sin(x)))) - _C1/sin(x);
sol2:=y(x) = -LambertW(x/(sin(x)*exp(_C1/sin(x)))) + _C1/sin(x);

exp(y(x))+cos(x)*y(x)+(exp(y(x))*x+sin(x))*(diff(y(x), x)) = 0

y(x) = -LambertW(x/(sin(x)*exp(_C1/sin(x))))-_C1/sin(x)

y(x) = -LambertW(x/(sin(x)*exp(_C1/sin(x))))+_C1/sin(x)

odetest( sol1,ode)

0

odetest( sol2,ode)

Error, (in tools/map) too many levels of recursion

 

Download sign.mw

First 27 28 29 30 31 32 33 Last Page 29 of 91