acer

32722 Reputation

29 Badges

20 years, 86 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@dharr My Maple 2024.2 does not exhibit that behavior.

Download forget_M20242.mw

Is the behavior new to M2025?

@nm I don't think that you really understand what's going on here, and I don't think that you understand the question in terms of what it actually means.

More importantly, you could very easily have branched this Question thread off of that older one or one of its Replies. That would insert cross-reference links automatically. Instead you didn't even add any link at all, which is unhelpful and counter-productive. The substance is clearly highly related (even if you maintain it's not the "same").

The earlier (followup) query boiled down to this: once the undesirable form has been created, how can one get the desired form? One cannot enter/get that same expression in the desired form unless one can change its stored & simpl'd structure. It's only because of that fact that I gave the other Asker an alternative of merely displaying something that looked like his desired form of the expression -- that might not be what he asked for, which was how to "write" it.

The easiest thing to do is just to make sure that the first call to CompleteSquare is like the following (for this! example):

restart;

eq := x^2 + y^2 + z^2 - 2*x + 8*y - 6*z - 30 = 0:

Student:-Precalculus:-CompleteSquare(eq, [z,y,x]);

(x-1)^2+(y+4)^2+(z-3)^2-56 = 0

Download comp_sq_01.mw

If you have unfortunately already created your result in the undesirable form then it is somewhat problematic to get it to exist in your desird form in ther same session. Consider:

restart;

eq := x^2 + y^2 + z^2 - 2*x + 8*y - 6*z - 30 = 0:

Student:-Precalculus:-CompleteSquare(eq, [x,y,z]);

(z-3)^2+(y+4)^2+(x-1)^2-56 = 0

Student:-Precalculus:-CompleteSquare(eq, [z,y,x]); # no good now

(z-3)^2+(y+4)^2+(x-1)^2-56 = 0

restart;

eq := x^2 + y^2 + z^2 - 2*x + 8*y - 6*z - 30 = 0:

Student:-Precalculus:-CompleteSquare(eq);

(z-3)^2+(y+4)^2+(x-1)^2-56 = 0

Student:-Precalculus:-CompleteSquare(eq, [z,y,x]); # no good now

(z-3)^2+(y+4)^2+(x-1)^2-56 = 0

Download comp_sq_02.mw

It is possible to turn targeted addends into function calls which can be sorted.

Here are a few ways, to get such pretty-printed,

restart;

expr := (z-3)^2 + (y+4)^2 + (x-1)^2 - 56  =  0;

(z-3)^2+(y+4)^2+(x-1)^2-56 = 0

 

L := [ (x-1)^2, (y+4)^2, (z-3)^2 ]:

 

F := u->InertForm:-Display(u,'inert'=false):
sort(subsindets(expr,`^`,F), order=plex(F~(L)[]));

Typesetting:-msup(Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("x"), Typesetting:-mo("−"), Typesetting:-mn("1"))), Typesetting:-mn("2"))+Typesetting:-msup(Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("y"), Typesetting:-mo("+"), Typesetting:-mn("4"))), Typesetting:-mn("2"))+Typesetting:-msup(Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("z"), Typesetting:-mo("−"), Typesetting:-mn("3"))), Typesetting:-mn("2"))-56 = 0

`print/G` := u->subsindets(u,name,convert,`local`):
sort(subsindets(expr,`^`,G), order=plex(G~(L)[]));

G((x-1)^2)+G((y+4)^2)+G((z-3)^2)-56 = 0

H := u -> subsindets(u,`^`,`%^`@op):
InertForm:-Display(sort(H(expr), order=plex(H~(L)[])), 'inert'=false);

`%^`(x-1, 2)+`%^`(y+4, 2)+`%^`(z-3, 2)-56 = 0; "_noterminate"


Download sort_fun.mw

There are other variants on some of those, depending on what one wants targeted or handled programagically.

That list L (of, say, addends of the lhs) could also be sorted programatically, using a grading scheme of one's choice. That could be done with, say, lexicographic aspects, taking into consideration the various names in the addends. Lists of terms can be sorted by arbitrary comparators.

@janhardo Please don't post duplicates of this as wholly separate Questions/Posts. Duplicate postings (especially with no context or differences or extra queries, etc) will get flagged as such and may be deleted.

restart;

kernelopts(version);

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

ode := diff(y(x),x) +cos(1/exp(2*x))*y(x) = sin(1/exp(x)):

IC := a*D(y)(x0)+ c*y(x0) = b*y0:

maple_sol:=dsolve([ode,IC],y(x));

y(x) = (Int(sin(exp(-_z1))*exp(-(1/2)*Ci(exp(-2*_z1))), _z1 = x0 .. x)+(sin(cosh(x0)-sinh(x0))*a-b*y0)/(cos(cosh(2*x0)-sinh(2*x0))*cosh((1/2)*Ci(cosh(2*x0)-sinh(2*x0)))*a+cos(cosh(2*x0)-sinh(2*x0))*sinh((1/2)*Ci(cosh(2*x0)-sinh(2*x0)))*a-c*cosh((1/2)*Ci(cosh(2*x0)-sinh(2*x0)))-c*sinh((1/2)*Ci(cosh(2*x0)-sinh(2*x0)))))*exp((1/2)*Ci(exp(-2*x)))

odetest(convert(maple_sol,exp), [ode, IC]);

[0, 0]

Download nm_ode_ex2.mw

@Rouben Rostamian

Naturally one can can test the sign (and I'm sure you did). And the OP did also mention a step by step way. (vote up)

For direct programming, years ago I'd usually reach for `radnormal` which is still usually pretty quick. But as machines got faster I found myself preferring `evala` for such situations where I needed to bolster what `simplify` did.

Also, there still seem to be more situations where both `radnormal` or `simplify` also need help from `rationalize` -- even if not the case here -- while `evala` more often does not.

How you handle this can depend on what you think it means to have a numeric solution of an IVP on the other side of the singularity from the IC information.

Btw, I told you just a few hours ago that DEplot can use dsolve,numeric . And that is also the case for your new example.

@nm The calls to DEtools:-DEplot in your Question above do call dsolve,numeric , for example, as,

   dsolve({diff(y(x), x) = x*(x^2+9)^(1/2), y(-4) = 0}, {y(x)},
               output = listprocedure, type = numeric, method = rkf45,
               range = -9.950000000 .. 9.950000000)

That kind of thing happens in `DEtools/DEplot/drawlines` .

You can see it as, 

  showstat(`DEtools/DEplot/drawlines`)

and notice how the result from dsolve gets used to produce the values for the lines/curves.

This might be getting off topic, though. What might be relevant to your original question is that going out-of-range (as far as the obsrange option is concerned) could be a slightly tricky consideration, and if floats are used then there could be a tolerance gotcha.

[edit] Note that the OP has augmented his Reply (immediately above this) with an additional example only after I add this Repy. That is unhelpful. It would be better to add it in a new Reply, so that the material would all appear in order and make more sense. Adding new examples to earlier queries/replies can make responses look like they've overlooked it.

Anyway, the smaller view that plot gets for this added followup example is due to the internal behaviour controlled by its smartview option. With smartview=false one gets a taller y range, and with default smartview=true one gets the shorter range (that slightly obscures the asymptote at the singularity, imo). Internally, it adds a VIEW substructure to restrict what parts of the computed data is rendered.

In my Maple 2024.2 the call odetest(sol,ode) returns 0 directly.

As I suspected, the change in typesetting of BesselJ icame in the same release that the default "level" changed from standard to extended.

It is documented in the compatibility updates for Maple 2017.

@sand15 Are you sure that your results are correct?

Can you get a piecewise constant difference for the difference between the integrand and the derivative of your result, either by plotting or simplification?

Or, can you do it even if you don't assemble the piecewise, but just try that on the two pieces separately, under their respective assumptions?

I wasn't able to confirm your results in such a way, even with Maple 2015 (as you've used). It's possible I lost the thread of your code, though.

Another way to do that,

restart;

integrand:=-3*(Pi-2*arcsin(tau))
           *(tau+1)^(1/2)*(tau+(tau^2-1)^(1/2))^(2*(tau^2-1)^(1/2)/(tau-1)^(1/2)/(tau+1)^(1/2))*(tau-1)^(1/2)
           *(-16/3*tau^2+Pi-2*arcsin(tau)+8/3)/(4*tau^2-4):


First, a piecewise representation and simplification of the integrand,
if tau is take to be real.
 

new := piecewise(tau<-1, (combine(simplify(integrand)) assuming tau < -1),
                 tau>-1, (combine(simplify(integrand)) assuming tau > -1));

new := piecewise(tau < -1, -(8*tau^2-3*arccos(tau)-4)*arccos(tau)/((tau+sqrt(tau^2-1))^2*sqrt(tau^2-1)), -1 < tau, (8*tau^2-3*arccos(tau)-4)*(tau+sqrt(tau^2-1))^2*arccos(tau)/sqrt(tau^2-1))

ans := combine(simplify( int( expand(evala(new)), tau ) )):


We can check the answer, expecting here a piecewise constant.
 

simplify(combine( new - diff(ans,tau) ))

piecewise(tau = -1, undefined, 0)


And, only because the piecewise ans doesn't display nicely when inlined on
Mapleprimes, here are its pieces:
 

ans assuming tau < -1;

(1/4)*(((6+4*I-12*tau^2)*arcsin(tau)^2+(12*Pi*tau^2-2+(-6-4*I)*Pi)*arcsin(tau)+(16*tau^4+(-16-12*I)*tau^2+6*I)*arccos(tau)+(4*I)*tau^4+(-3*Pi^2+6-4*I)*tau^2+(3/2+I)*Pi^2+(-3+(1/2)*I))*(tau^2-1)^(1/2)-4*(tau+1)*(-3*arcsin(tau)^2+3*Pi*arcsin(tau)+(4*tau^2+(-2-3*I))*arccos(tau)+I*tau^2-(3/4)*Pi^2+3/2-(1/2)*I)*tau*(tau-1))/(tau^2-1)^(1/2)

ans assuming tau > -1;

-(3/4)*((1/6+(4/3)*(tau^2-3*arccos(tau)-1/2)*tau*(tau^2-1)^(1/2)+(4/3)*arcsin(tau)^2-(4/3)*Pi*arcsin(tau)+2*(-2*tau^2+1)*arccos(tau)+(1/3)*Pi^2+(4/3)*tau^4-(4/3)*tau^2)*(-tau^2+1)^(1/2)+(2*(2*tau^2-1)*arcsin(tau)^2+2*(1/3-2*Pi*tau^2+Pi)*arcsin(tau)+(16/3)*(-tau^4+tau^2)*arccos(tau)+(tau^2-1/2)*(Pi^2-2))*(tau^2-1)^(1/2)+(tau+1)*(-(16/3)*arccos(tau)*tau^2+Pi^2-4*Pi*arcsin(tau)+4*arcsin(tau)^2+(8/3)*arccos(tau)-2)*tau*(tau-1))/(tau^2-1)^(1/2)


Download nm_int2.mw

I get that error using Maple 2024.2 on Linux.

In Maple 2023.2.1 on Linux it returned unevaluated.

MmaTranslator:-FromMma("sol = y -> Function[{x}, Sin[x] + C[1]]");

`MmaTranslator/Assign`(sol, y = unapply(sin(x)+_C1, x))

MmaTranslator:-FromMma("IC /. sol");

eval(IC, sol)

Download FromMma_ex.mw

I too don't understand what janhardo's trying to say. Perhaps he's trying to ensure that you're using https rather than http. Or perhaps not.

@dharr I vote up both this and sand15's Answer. (Utilizing unapply and eval is a very natural way to tackle this.)

A short note to users of that other software:

MmaTranslator:-FromMma("sol = y -> Function[{x}, Sin[x] + C[1]]");

`MmaTranslator/Assign`(sol, y = unapply(sin(x)+_C1, x))

MmaTranslator:-FromMma("IC /. sol");

eval(IC, sol)


Translation is not always perfect, but in this case it produces essentially the same approach. It's often worthwhile to try it.

1 2 3 4 5 6 7 Last Page 1 of 599