Preben Alsholm

13005 Reputation

22 Badges

18 years, 180 days

MaplePrimes Activity

These are replies submitted by Preben Alsholm

Is the vector you give named gln so that gln[i], i = 1..2 are its components?

@tomleslie dsolve, events works in Maple 12, thus also in Maple 13.

Your suggestion [[ gln[1]^2+gln[2]^2, halt]]  should work in principle, but I would like to see the actual system.
Will gln[1]^2+gln[2]^2 ever be found equal to zero, problem being that it is >=0 always?

The solution to that is the obvious: Replace gln[1]^2+gln[2]^2 by gln[1]^2+gln[2]^2-epsilon, where epsilon could be e.g. 1e-7.

There is a dog chasing jogger example in the help page for stop_cond in Maple 8. stop_cond has been superseded by events.

For your worksheet to run without error you need kernelopts(floatPi=true).
This option exists in Maple 2015, but is not documented. It doesn't exist in earlier versions. I believe the default is false in 2015.
The option is documented in Maple 2016 and later versions and the default is true.
I found out since I have kernelopts(floatPi=false) in my maple.ini file.

If a univariate polynomial has a multiple root then that root is given as many times as its multiplicity.

I suppose that if in the solving process for you equation a univariate polynomial turns up this could create the situation you describe.

Try solving with infolevel[solve]:=3.
In the lines you will see polynomials mentioned. At the end a confusing message saying:
Main: Exiting solver returning 1 solution

@ogunmiloro Which Maple release/version are you using?
More importantly, what is your response to mmcdara's question about the fact that C__f has 110 members and 'times'  has only 20? Should the members in C__f be grouped in 20 groups of varying size and so how?

I haven't as yet found a description of the meaning of the procedure _pexports.

But it appears to be short for package exports and works this way:

M:=module() option package; export _pexports,a,b,c;
              [op({exports(M)} minus {':-c', ':-_pexports'})]
   end proc;
   a:=proc(x) 8*x end proc;
   b:=proc(x) x^2 end proc;
   c:=proc(x) sin(x) end proc;
end module;
with(M); # Notice that only [a,b] is returned
c(8); # unevaluated
M:-c(8); # the long form works.

It most likely goes back to the introduction of modules in Maple (Maple 6 I believe). The code above certainly works in Maple 8 and later versions.
A neat facility which makes it possible to make a useful but "nerdy" procedure available to the programmer in other contexts than within M. I'm somewhat embarrassed that I haven't noticed this before (or maybe I have, but forgot).

@dharr Yes, this extra semicolon is allowed in Maple 2019 and 2020, but not before.
Trying in those two Maple versions:
p:=proc(x); local y; y:=x; y end proc;
we notice that the parser removes the semicolon.

Here is a variant where T is defined as a procedure with option remember and returning unevaluated if t is 0 or just the global name t..


ode2 := diff(varphi(t), t, t) + omega^2*sin(varphi(t));
p0 := evalf(10/180*Pi);
event2 := [[diff(varphi(t), t), T(t)=t]];
T:=proc(t) option remember; 
  if t::identical(':-t') or t=0 then 
  end if
end proc;
ld2 := dsolve([eval(ode2, omega = 2*Pi), varphi(0) = p0, D(varphi)(0) = 0,T(0)=0], numeric,
               discrete_variables=[T(t)::float], events = event2,abserr=1e-12,relerr=1e-9);

op(4,eval(T)); # So far the only members of the remember table
plot(T(t),t=0..te); # Creates many members
{entries(op(4,eval(T)),nolist)} minus {T(0),T(t)};

The last line returns
{0., 0.5009535940730963, 1.0019071881466945, 1.5028607822207958, 2.0038143762954004, 2.504767970370508, 3.0057215644461186, 3.506675158522232, 4.0076287525988485, 4.508582346675968, 5.009535940753591, 5.510489534831716}

This one works as is in Maple 12 too.

I ran your interesting worksheet in Maple 2020.1.

It produced an error when coming to the statement

global liste_triangles:
The error was:

Error, global declaration unexpected outside procedure or module

Trying in a fresh worksheet in Maple 2015.2 and in Maple 2020.1 the followingt:

global liste_triangles;

I get the output _global(liste_triangles) in Maple 2015.2, but the error shown above in Maple 2020.1.

Just commenting out this attempt to declare liste_triangles makes your worksheet work fine in Maple 2020.1.


@brian bovril Since by gamma you most likely don't mean Euler's constant, you should either replace it by some other name or start your session with local gamma;  after restart.
Secondly, just replace gamma by beta or vice versa.

local gamma;
ode := x^2*diff(z(x), x, x) + (1 + gamma + beta)*x*diff(z(x), x) + gamma*beta*z(x) - cos(ln(x));
sol:=dsolve({ode1, z(1) = 1, D(z)(1) = -1});

If x is known to be positive then this will shorten the answer considerably:
simplify(evalc(sol)) assuming x>0;

@Hnx I strongly recommend using worksheet mode and 1D math input (aka Maple input):

Go to Tools/Options/Display/Input display: Choose Maple Notation.

After that and without leaving the window that is open go to the menu Interface/Default format for new worksheets: Choose Worksheet.
Then press the button at the bottom labelled Apply Globally. Don't worry about the word "Globally"; these changes can just as easily be reverted.
Any new worksheet that you open will use the chosen format. Old worksheets or worksheets from other people won't change if brought into your copy of Maple.

Personally I never use 2D math input or document mode. I find it frustrating to work with as it seems to be for you.
Here is your code slightly modified (irrelevant though) in 1d-input and worksheet mode (and no equation labels: my personal preference).

@acer The difference in your procedures is seen before the call if they are assigned to a name:

M:=module() option package;
  export e,f,g,h;
  e := overload([
         proc(x::positive) option overload; x^2; end proc,
         proc(x::negative) option overload; x; end proc ]);
  f := overload([
         proc(x::positive) option overload; x^2; end proc,
         proc(x::negative) x; end proc ]);
  g := overload([
         proc(x::positive) option overload; x^2; end proc ]);
  h := overload([
         proc(x::positive) option overload; x^2; end proc,
         proc(x::odd) option overload; x^3; end proc,
         proc(x::negative) x; end proc ]);
end module:
pe:=proc() uses M; e(3); end proc;

pf:=proc() uses M; f(3); end proc;

pg:=proc() uses M; g(3); end proc;

ph:=proc() uses M; h(3); end proc;

We see from the printed ouput that inside the procedures pf and ph f and h are replaced by M:-f and M:-h, respectively.

This doesn't happen with pe and pg.
If with(M) is placed after the definitions of the procedures pe,pf,pg, and pg then there is no problem.
Thus if one's own package makes use of 'uses LinearAlgebra' and that package is loaded before using with(LinearAlgebra) in a worksheet, there should be no problem.

Note: After M is defined and after with(M)  then eval(e) returns just:
overload([e = M:-e])
which doesn't make any sense to me (although e works).
To get the print above use standard typesetting, otherwise the output prints as overload([e = e]) (!!)

In contrast eval(f) evaluates to

overload([proc (x::positive) option overload; x^2 end proc, proc (x::negative) x end proc])
as expected.


@Hnx What odeplot does is to issue a warning, but the plot is fine.
If you want to know the value of tmax before the plot you can simply do:

phi1_numeric := dsolve({deq_numeric, ics_numeric}, numeric, events = [[phi1(t) = phi1_end, halt]],maxfun=0);
res:=phi1_numeric(0.5); # warning only and expected since you asked for a stop.

If you don't even want to see a warning you can turn warnings off (only do this temporarily, not a good idea in general):

@Hnx I added maxfun=0, which really means maxfun = infinity, i.e. no upper bound for the number of function evaluations.

phi1_numeric := dsolve({deq_numeric, ics_numeric}, numeric, events = [[phi1(t) = phi1_end, halt]],abserr = 0.1*10^(-8), relerr = 0.1*10^(-7),maxfun=0);

Then try:

t_max := 0.354;
odeplot(phi1_numeric, [t, phi1(t)], t = 0 .. t_max + 0.1);

You will see that the event occurs.

@Hnx You say that you know the point of singularity in the form of a constant. Is that constant the value of t or of y(t) or y'(t) or what?

Here is a very simple example, where we know in advance that the solution y(x) has a singularity at x = 1.

#Singularity at x = 1.
res(1.1); # Error message is good
eps:=1e-9: # Value dependent on Digits and abserr/relerr
resE:=dsolve({ode,ic},numeric, events=[[x=1-eps,halt]], abserr=1e-9,relerr=1e-8);


First 16 17 18 19 20 21 22 Last Page 18 of 218