nm

11483 Reputation

20 Badges

13 years, 83 days

MaplePrimes Activity


These are replies submitted by nm

@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

@Thomas Richard 

The error is simply due to sign change. Compare this below. This is clearly a bug. It is no problem if odetest can't verify it. This is not the issue.

The big problem is that Maple generates an exception that can not be even cought by the user. This brings down the whole application when this happens and there is no workaround. 

restart;

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

@tomleslie 

Sure. I know I can use value() to evaluate the inert integral.

when it appears to be convenient not to evaluate

But that is really what I am asking. How does it decide when it is "not convenient"

if I want to duplicate Maple's result, I can not write

  If not  integral_result::convenient   then
     return inert_version_of_integral
 else
    return integral_result
 fi;

I wish I could.

So it must have some rules it decided what is and what is not  convenient and I am asking what are these rules/measures it uses as I would like to be able to do the same and also to learn something on how dsolve does these things.

@ecterrab 

Hello Edgardo

I seem not to have good job explaining the problem. I did not mean dsolve itself returns mixed c__i and _Ci. But that it seems only _C1 and _C2 are automatically translated to c__1 and c__2 and _C3 and _C4 remain the same. So when I build my own solution manually, I get mixed constants. Here is one more example

(having problem uploading worksheet, will try screen shot)

Download problem_with_C_2.mw

restart;
dsolve(diff(y(x),x)=1,arbitraryconstants=subscripted);
pdsolve(diff(psi(x,t),x$2)=0,arbitraryfunctions=subscripted);
_C1;_C2;_C3;_C4
mysoluiton:= y(x)=_C1*y1(x)+_C2*y1(x)+_C3*y1(x)+_C4*y1(x);

THis is the output

 

My question is simply, why only _C1 and _C2 are translated and not higher ones? My understading is that once the arbitraryconstants=subscripted is used once, it now automatically translate each _Ci to c__i for any i.

But may be this  is not how it works and I misunderstood it.

@Preben Alsholm 

Yes, infinity is not a real number. But you do agree that -infinity satisfies the equation in the question. Therefore it is a solution.

In addition, in differential equations, having an +- infinity as constant of integration is a valid value and allowed. So my question is, does Maple have methods to find these non finite value solutions or must one find them manually using limit and trial and error? which is what I do now.

@Athar Kharal 

fyi, updated answer. I changed both to select member. I do not know if "has" is slower or faster than "member" or "in" commands. You could do your own timing and decide which is faster. I changed the first one to also use "member" instead of "has".

@Carl Love 

I just realized I was causing all these trouble with signum myself. Sometimes when simplifying an expression using the assumption real, these signum now show up in the result. The result is not much simpler anyway, but I get some signums showing up.

I should not using simplify with real much anymore. I have to be careful when to use it. Here is an example

r:=(x^2-6)^(1/2)/(x^2-4)^(1/4)*(x+(x^2-4)^(1/2))^(1/(x^2-4)^(3/2)*((x^2-4)^3)^(1/2)*3^(1/2))*exp(-1/2*((x^2-4)^3)^(1/2)*(arctanh(1/2*(2^(1/2)*3^(1/2)*x-4)*2^(1/2)/(x^2-4)^(1/2))+arctanh(1/2*(4+2^(1/2)*3^(1/2)*x)*2^(1/2)/(x^2-4)^(1/2)))/(x^2-4)^(3/2));

Now

simplify(r) assuming real

having signums there causes odetest to fail in many cases. So the fix is not to using simplify with real assumption before.

So now I do not have to do anything to get rid of signum since it no longer shows up in the first place.

I also noticed using simplify with the size option does not cause this problem even when using real (even though in this example, the size does not change, but at least no signums show up)

simplify(r,size) assuming real

 

I do not know why simplify thinks that having signum() show up is considered "simpler" than before. (may be due to removing the sqrt at the cost of replacing it by signum). I prefer to see the sqrt than signum.  I did not notice this before.

someone who knows where to look in the code could probably find out for sure, but my guess it does both. May be it stores Pi for million digits or 1000 digits. But if more digits are needed, there are algorithms that quicky find Pi for any number of digits needed, such as Spigot_algorithm

Same for Euler constant.

@Joe Riel 

we must be using different Maple or I do not understand what you meant. If I use eq:=_self:-A^2;  then the warning comes back., If I use eq:= A^2;  then the warning goes away, yes. But you are saying warning should not show up in both cases?

I tried also commenting out the USE_SELF inside the foo proc, but it made no difference.

kernelopts('assertlevel'=2):

$ifdef MINTONLY
$define USE_SELF _self;
$else
$define USE_SELF
$endif


A_class:=module()
option object;
local A :: integer :=0;
export
    ModuleCopy :: static := proc( _self, proto :: A_class,m::integer:= proto:-A)
        USE_SELF
        _self:-A := m; #initialize object private variable
end proc;

export foo :: static := proc(_self,$)
local eq;
    USE_SELF;
    eq := _self:-A^2;
    return eq;
end proc;

end module:


a := Object(A_class, 23):
foo(a);

Now

>"C:\Program Files\Maple 2022\bin.X86_64_WINDOWS\mint.exe" -i 2 A.mpl

Module A_class() on lines 10 to 26
  These local variables were assigned a value, but otherwise unused:
      A::integer

What exactly did you mean then by it is independent of whether you use _self:-A or A in the code.

Thanks

@Joe Riel 

Thanks. But I do not think I will use this workaround. The reason is, I actually prefer to write  inside a proc

          eq :=  _self:-A

vs. just

          eq :=  A

Why? Because when looking at the code, I can see that A in the first case is a variable of the object.

While in the second case, I have no idea if A is a local variable to the proc itself, or variable for the object itself which this proc is function memeber of, or even if A is global variable.

So   _self:-A is like self documenting the code. It tells the reader where A lives and this is useful for me, otherwise all variables will now look the same in terms of reference to them. I would not know looking at the code, where A came from without having each time to go look around all the code.Rigth now, if there is no _self:- then I know the variable is local to the proc right away without having to check.

I think mint should be fixed instead.

But thanks again for  the suggestion.

 

@Joe Riel 

The A:- are not required in foo.  Without them, mint is clean. 

I am afraid this did not solve the problem.  Yes mint is clean now. but code now gives a errors when I run it using

interface(warnlevel=4);
kernelopts('assertlevel'=2):

Which I have on all the time.  I run all my code with the above setting.

So  removing A:- made mint clean, but code does not run any more. So it is either mint is wrong, or kernelopts('assertlevel'=2): is wrong.

So I had to put these all back and live with mint warnings.

Here is worksheet so you can see for your self. It looks like mint needs a major update by Maplesoft.
 

interface(version);

`Standard Worksheet Interface, Maple 2022.1, Windows 10, May 26 2022 Build ID 1619613`

#######################################
#Mint complain about B but code runs !
restart;

interface(warnlevel=4);
kernelopts('assertlevel'=2):
A:=module()
   local B:=module()
         option object;
         export n::integer:=1;
   end module;

   export foo:=proc()
      local a::A:-B;  #mint complains that A is global not declared!
      a:=Object(A:-B);
      a:-n:=2;
   end proc;
end module;

3

_m2560568340448

maplemint(A)

Nested Anonymous Module module() on lines 1 to 2
  These exported variables were never used:  n::integer
Module A()
  These local variables were assigned a value, but otherwise unused:  B

A:-foo();

2

##################################
# removed A:- mint now does not complain, but code no longer runs
restart;

interface(warnlevel=4);
kernelopts('assertlevel'=2):
A:=module()
   local B:=module()
         option object;
         export n::integer:=1;
   end module;

   export foo:=proc()
      local a::B;  #mint does not now complain
      a:=Object(B);
      a:-n:=2;
   end proc;
end module;

3

_m2560568340448

maplemint(A)

Nested Anonymous Module module() on lines 1 to 2
  These exported variables were never used:  n::integer

A:-foo()

Error, (in foo) type `B` does not exist

 


 

Download mint_msg_oct_18_2022.mw

 

 

 

 

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