nm

11353 Reputation

20 Badges

13 years, 20 days

MaplePrimes Activity


These are questions asked by nm

inside my module, I create types to be used by only procs, and other sub modules inside the main one package I have.

but TypeTools:-AddType invoked inside my package, adds the type to system. So a user after loading the package can still see it and use this type.

Adding local before TypeTools:-AddType is not supported.

How to make the type only visible inside the package? Here is example

restart;
kernelopts('assertlevel'=2):
my_pkg:=module()
 option package;
 TypeTools:-AddType(age_type,t->evalb(t::nonnegint and t<150));
 export foo:=proc()
    local age::age_type:=20;
    print("age=",age);
 end proc;
end module;

with(my_pkg);

And now a user can do this

x::age_type:=30;

It worked, since age_type is now in the system. This can also cause a problem, since loading this package, could overwrite a type name allready set there by another package the user happened to load before.

If I can make it at least such that the user has to do 

x::my_pkg:-age_type:=200;

That would be better. But the best solution is to make the type name completely not visible from outside the package. i.e. private type to the package only.

I looked at Extension Mechanisms under typetools in help, but do not see how to use that for what I want.

 

Maple 2020.1

Any idea why Maple can simplify this expression only when multiplied by -1 but not otherwise?

expr:=sqrt(-2 + 2*I*sqrt(3));
simplify(expr)

But now

simplify(-1*expr)

Multiplying by -1 should not have mattered. Becuase -2 + 2*I*sqrt(3)=(1+I*sqrt(3))^2  Therefore sqrt(-2 + 2*I*sqrt(3)) is the same as 1+I*sqrt(3) and Maple knows this:

simplify((1 + sqrt(3)*I)-expr) gives zero.

But Maple only simplifies -expr  and not +expr.

Just wondering is someone can suggest why that is and if this is considered OK?

Maple 2020.1, Physics 724

From another question I asked, I learned that parse("string") returns an unevaluated Maple expression. 

But in interactive mode (in worksheet), the result looks the same as normal evaluated expression. That is why I did not know this. For example

ode1:= :-parse("diff(y(x),x$2)=0");
ode2:= diff(y(x),x$2)=0;

it gives

There is no difference when looking at it.  That is why when I was in Maple debugger, I could not see why Maple was complaining about it. An eval  was needed.

I looked at the types to see if there is something like type(variable,`unevaluated`) or such, and could not find one.

If Maple can at least display unevaluated expression with different color, or different notations when in the worksheet interface,  I would have noticed that parse returns unevaluated expression.

In Mathematica, these things are done using wrappers, (called Hold or Inactive) but these are visible in the notebook and use different color shading or Hold is present and had to expliclity removed,  and so looking at them, one can see the differerence between the expressions. 

How can one in Maple distinguish between unevaluated expression such as ode1 above and evaluated one such as ode2 above?  This can be useful to use inside a proc for example.  Is there an option in the GUI itself to tell Maple may be to color each differently?

 

I can't figure why dsolve and odeadvisor fail to process ode when it is parsed from string and only inside a proc, but works ok in global space.

This works OK:

restart;
ode  :=  :-parse("diff(y(x),x$2)=0"):
func := :-parse("y(x)"):

dsolve(ode);
DEtools:-odeadvisor(ode,func);

But the same code, when inside a proc, fail

restart;
foo:=proc()
  local ode,func;  
  local x,y; #adding this did not  help

  ode  :=  :-parse("diff(y(x),x$2)=0");
  func :=  :-parse("y(x)");

  dsolve(ode);
  try
     DEtools:-odeadvisor(ode,func);
  catch:
     error lastexception;
  end try;

end proc;

foo()

It seems to have with name scoping, but I do not see what is the problem. :-parse works fine.

How to resolve this? Since I must use :-parse as I am reading the ode as string from database with Maple as string from inside a proc inside a module and the above is just a simple example that shows the problem.

Maple 2020.1 with Physics 724

According to Wikipedia, Abel's first order odes have general analytical solutions, due to "Panayotounakos, Dimitrios E.; Zarmpoutis, Theodoros I. (2011)" where the claim is that, if I understand it right, all Abel ode's can be solved analytically.

https://en.wikipedia.org/wiki/Abel_equation_of_the_first_kind

"Construction of Exact Parametric or Closed Form Solutions of Some Unsolvable Classes of Nonlinear ODEs (Abel's Nonlinear ODEs of the First Kind and Relative Degenerate Equations)"

Maple is very good on solving ODE's, but some Abel ode's it can not solve. For example

restart;
ode:=diff(y(t),t)= y(t)^3+exp(-5*t);#_Abel
ode:=diff(y(x),x) = (1+x^3*y(x))*y(x)^2;#_Abel
ode:=diff(y(x),x) = y(x)^2-a*x*(1-x^(n-1))*y(x)^3;#_Abel
ode:=diff(y(x),x) = a*y(x)^2+x*y(x)^3*(b+c*x^(n-1));#_Abel
ode:=diff(y(x),x) = f0(x)+f1(x)*y(x)+f2(x)*y(x)^2+f3(x)*y(x)^3;#_Abel
ode:=(tan(x)*sec(x)-2*y(x))*diff(y(x),x)+sec(x)*(1+2*y(x)*sin(x)) = 0;#_Abel, `2nd type`, `class A`
ode:=x*(a+y(x))*diff(y(x),x)+b*x+c*y(x) = 0; #[_Abel, `2nd type`, `class B`]
ode:=(g0(x)+y(x)*g1(x))*diff(y(x),x) = f0(x)+f1(x)*y(x)+f2(x)*y(x)^2+f3(x)*y(x)^3;#_Abel, `2nd type`, `class C`

etc..

All the above Abel ode's are from Book: Ordinary differential equations and their solutions. By George Moseley Murphy. 1960

I am just asking what is the status of this. Is it true there is now a method to solve all these exactly and may be Maple's implementation is not in yet for this? 

btw, I found the description of solution methods in https://fr.maplesoft.com/support/help/Maple/view.aspx?path=odeadvisor/Abel much easier to follow to learn how to solve Abel ode's. That paper mentioned on Wikipeida, I had hard time following after the 3rd page. (need more time to study it).

Could someone please comment on the status of solving Abel's first order ODE's in Maple and if it possible now to solve them all analytically?

 

 

 

 

 

First 118 119 120 121 122 123 124 Last Page 120 of 199