acer

33171 Reputation

29 Badges

20 years, 194 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@janhardo I don't know whether the OP really wants to cover any expression, but you might be interested that there some things which act differently than your code expects:

restart;

 

toPrefix := e -> `if`(type(e,atomic), e,[op(0,e), seq(toPrefix(op(i,e)), i=1..nops(e))]):

Warning, (in toPrefix) `i` is implicitly declared local

 

table([f=a,q=s]);

table( [( f ) = a, ( q ) = s ] )

 

toPrefix( table([f=a,q=s]) );

Error, (in toPrefix) invalid input: toPrefix uses a 1st argument, e, which is missing

 

type( table([f=a,q=s]), atomic );

false

op( table([f=a,q=s]) );

[f = a, q = s]

nops( table([f=a,q=s]) );

2

op(1, table([f=a,q=s]) ); # NULL


Download table_vs_op_nops.mw 

It seems like a mistake to me, to have recursive code act on expressions for which the conditional (say, being not type atomic) is not always correctly supported by the ensuing tranformation (using op, nops, etc). Not only could you get an unexpected error (see example above), but in a worse case it might get into an untrappable infinite recursion.

@dharr For me the following works, without assumptions, in versions back to at least Maple 16.02 (2012).

> inttrans[laplace](FresnelS(t), t, p);

     (-1+LommelS2(1,1/2,1/2*p^2/Pi))/Pi


note. It's unclear why the OP tried putting an assumption on a, for an example not containing that name. It might help if the OP uploaded an actual worksheet.

@Roy Hughes 

You should upload (and attach) your worksheet using the green up-arrow in the menubar of the Mapleprimes Reply editor.

@sursumCorda I don't think that you've misunderstood. It seems more a weakness in simplify/constant.


ps. As an aside, this seems mere luck here:
    simplify(convert(f,compose,arcsin,ln));

@nm How's this:

restart;

kernelopts(version);

`Maple 2025.1, X86 64 LINUX, Jun 12 2025, Build ID 1932578`

ode := -x*sqrt((1 - x)/(x + 1))*(x + 1)*arcsech(x)*diff(y(x), x)*exp(y(x)/arcsech(x)
       + exp(y(x)/arcsech(x))) - y(x)*exp(y(x)/arcsech(x) + exp(y(x)/arcsech(x)))
       + 2*x*sqrt((1 - x)/(x + 1))*(x + 1)*arcsech(x)^2 = 0:

[ dsolve(ode) ]; # NULL

[]

[ dsolve(ode) ] assuming x>0; # NULL

[]

forget(`ODEtools/remember`);
dsolve(ode) assuming x>0;

y(x) = ln(ln(2*x-2*c__1))*arcsech(x)

Download ode_solution_remembered_11022026.mw


note: The symmetry methods attempt `odsolve/sym_pat/[F(x),G(y)]` calls `ODEtools/play`, which seems to work with substitutions for x,y by names (`ODEtools/x`, `ODEtools/y`) which lack the assumptions. Then a check for a remembered result in `ODEtools/remember` for `odeadv/high_oder/lin_sym` utilizes the expression with the substituted names, finds details from the earlier call, and it fails out.

@Mac Dude This is just a side comment related to what you've written (as opposed to the OP's issue).

If the GUI (front-end interface) itself locks up while dealing with a particular worksheet then it can be frustrating if killing it would result in lost changes in other open sheets.

The GUI runs in a Java virtual machine (jvm), and by default opening multiple sheets via the desktop icon will result in their all being under that single jvm. Forced closure of that jvm+GUI can then result in all its related open worksheets being closed.

But there is an alternate way to operate. If the GUI is launched with a command option
   -standalone
then the GUI instance will be separate from other instances. When one of the GUI front-end instances crashes hard (without Save offerings) then other sheets in such separate GUI instances won't also get forcibly closed.

On MS-Windows I have two desktop icons for launching the Maple GUI. One is a copy of the other, except that I edit the launching command within it (right-click Properties, IIRC), and add that option (and then rename it something helpful as visual reminder).

So this give me a choice of how to launch. In practice I find that the memory cost of multiple jvms is not prohibitive. (Many years ago the resident memory in the OS was a significant portion of the total available on my machine. These days it's not...)

On Linux I don't use a desktop icon, but launch from a terminal shell with a command (aliased to a single word), eg.
    /usr/local/maple/maple2024.2/bin/maple -s -x -standalone &

There are other variants to this. Eg, I also use the -s option when I want to exclude reading of a personal init file's Maple commands.)

ps. IIRC you might be a Max OSX person. I don't know where the underlying executable call is located under any OSX icon launcher.
pps. Another (slightly odd) thing one can do with separate GUI/jvm is open the very same .mw file more than once (without renaming), separately. Of course, you need to be careful when saving such.
ppps. edit with care

You've asked about this in at least two earlier and separate Question threads.

This is one of them, and plots:-display(seq(...),insequence=true) worked there as well as here.

@sand15 I shall log a full bug report, including a link to your notes (and possibly your .mw files). Thanks.

ps. I didn't write more commentary before about the behaviour (other than only an observation of when the runtime error appeared) because I'm busy these days. But thanks again.

@JoyDivisionMan You could submit a bug report using this form.

That error appears to have started some time between Maple 2023.2 and Maple2024.2, ie. with some release of Maple 2024.

@nm I'd agree that is undesirable. I'd like to track down what's being remembered.

@Kitonum Those are the same reasons why I used the assumptions 0<x<1 in my Answer from yesterday.

And with x>0 I had already gotten the very same 4sec performance and the very same target result. (Only a part of those assumptions turned out necessary to get that.)

You have (importantly) added a programmatic aspect to such deduction. It might be difficult to take all that same approach in general, but it could be nice if there were somewhat easier ways to convey such detail and have the system figure more of such details as it went.

I thought that I'd checked this when I first Answered, but apparently I didn't.

Using the assumption x>0 (which is the same as the OP was willing to use in hist odetest call) in the dsolve attempt can also work pretty quickly and without undue memory use.

restart;

kernelopts(version);

`Maple 2024.2, X86 64 LINUX, Oct 29 2024, Build ID 1872373`

ode := -x*sqrt((1 - x)/(x + 1))*(x + 1)*arcsech(x)*diff(y(x), x)*exp(y(x)/arcsech(x)
       + exp(y(x)/arcsech(x))) - y(x)*exp(y(x)/arcsech(x) + exp(y(x)/arcsech(x)))
       + 2*x*sqrt((1 - x)/(x + 1))*(x + 1)*arcsech(x)^2 = 0;

-x*((1-x)/(x+1))^(1/2)*(x+1)*arcsech(x)*(diff(y(x), x))*exp(y(x)/arcsech(x)+exp(y(x)/arcsech(x)))-y(x)*exp(y(x)/arcsech(x)+exp(y(x)/arcsech(x)))+2*x*((1-x)/(x+1))^(1/2)*(x+1)*arcsech(x)^2 = 0

sol := CodeTools:-Usage( dsolve(ode) ) assuming x>0;

memory used=485.34MiB, alloc change=106.00MiB, cpu time=4.50s, real time=4.01s, gc time=848.14ms

y(x) = ln(ln(2*x-2*c__1))*arcsech(x)

odetest(sol, ode) assuming x>0;

0

Download de_hard04.mw

I guess I started trying the expln form before I started leveraging that assumption.

note: The above worked directly, if the same assumption was used. But it's not as lightning fast and lean as was the (also) successful trick of doing the temporary change: Y(x)=y(x)/arcsech(x)

The following runs very quickly, with low memory use.

restart;

kernelopts(version);

`Maple 2024.2, X86 64 LINUX, Oct 29 2024, Build ID 1872373`

ode := -x*sqrt((1 - x)/(x + 1))*(x + 1)*arcsech(x)*diff(y(x), x)*exp(y(x)/arcsech(x)
       + exp(y(x)/arcsech(x))) - y(x)*exp(y(x)/arcsech(x) + exp(y(x)/arcsech(x)))
       + 2*x*sqrt((1 - x)/(x + 1))*(x + 1)*arcsech(x)^2 = 0;

-x*((1-x)/(x+1))^(1/2)*(x+1)*arcsech(x)*(diff(y(x), x))*exp(y(x)/arcsech(x)+exp(y(x)/arcsech(x)))-y(x)*exp(y(x)/arcsech(x)+exp(y(x)/arcsech(x)))+2*x*((1-x)/(x+1))^(1/2)*(x+1)*arcsech(x)^2 = 0

 

new2 := eval(ode, y(x)=Y(x)*arcsech(x));

-x*((1-x)/(x+1))^(1/2)*(x+1)*arcsech(x)*((diff(Y(x), x))*arcsech(x)-Y(x)/(x^2*(1/x-1)^(1/2)*(1/x+1)^(1/2)))*exp(Y(x)+exp(Y(x)))-Y(x)*arcsech(x)*exp(Y(x)+exp(Y(x)))+2*x*((1-x)/(x+1))^(1/2)*(x+1)*arcsech(x)^2 = 0

 

new2b := simplify(new2) assuming x>0;

(-(diff(Y(x), x))*exp(Y(x)+exp(Y(x)))+2)*x*(-x^2+1)^(1/2)*arcsech(x)^2 = 0

Sol2 := dsolve(new2b);

Y(x) = ln(ln(2*x+2*c__1))

sol2 := solve(eval(Sol2, Y(x)=y(x)/arcsech(x)), {y(x)})[];

y(x) = ln(ln(2*x+2*c__1))*arcsech(x)

odetest(sol2, ode) assuming x>0;

0

Download de_hard03.mw

Another note on variables, since the OP mentioned "names": the declared globals,
the declared locals, and the lexicals are (the) symbols and not, say, indexed
names as might appear and be used.

restart;


Notice that it is the symbol res that gets implicitly declared local
to the procedure assigned to f, not the name res[1] .

f := proc() local g,x;
  g := proc()
    int(sin(x[1]), x[1]=0..Pi);
  end proc;
lprint("op 7 is the so-called lexical table:",[op(7,eval(g))]);
  res[1] := g();
  return res[1];
end proc:

Warning, (in f) `res` is implicitly declared local


Notice also that the lexical table contains the symbol x and
not the name x[1] .

f();

"op 7 is the so-called lexical table:", [x, x]

2

maplemint(f);

Procedure f()
  These local variables were used but never assigned a value:  x

proc() global G[1]; end proc:

Error, `[` unexpected

proc() global G; end proc:

proc() local L[1]; end proc:

Error, `[` unexpected

proc() local L; end proc:


Download proc_lcl_ex1.mw

And another note: names used as globals in the procedure, but which are not declared as global, are not "global variables" of the procedure, per se.

restart;

p := proc() global g1;
  g2;
end proc;

proc () global g1; g2 end proc

"op 6 is the globalSequence:",op(6,eval(p));

"op 6 is the globalSequence:", g1

maplemint(p);

Procedure p()
  These names were used as global names but were not declared:  g2
  These global variables were declared, but never used:  g1


Download proc_lcl_ex2.mw

4 5 6 7 8 9 10 Last Page 6 of 607