acer

32363 Reputation

29 Badges

19 years, 332 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

It seems to be due to a much older -- but apparently rarely occurring -- bug in plotttols:-getdata, on which I will submit a bug report.

In Maple 2024 Explore started to make use of plotttols:-getdata.

Fortunately for your example, it can be avoided by using the Explore option adaptview=false .

Planck_Curve_ac.mw

Is it the same if you add the documented option,

   subfunctions=true

to the simplify call.

That would make it also forget the remember table of `simplify/do`, etc.

Using subs on the generated XML, you can retain "conveniences" of having Tabulate as a command.

GenerateSimilar_Ala_ac.mw
 



Download GenerateSimilar_Ala_ac.mw

It would be nice if Tabulate would offer Cell/Textfield alignment as an option.

You wrote "list of points", but in your code you are instead using a set of lists/points, and not a list of lists/points.

Note the difference between,
   plot( [ [3, 6], [-1, 6], [-1, 1], [-1, -2], [3, -2] ], x=-3..4, y=-4..10, style=line)
and,
   plot( { [3, 6], [-1, 6], [-1, 1], [-1, -2], [3, -2] }, x=-3..4, y=-4..10, style=line)

That is because of the difference in the results of,
   [ [3, 6], [-1, 6], [-1, 1], [-1, -2], [3, -2] ]
versus,
   { [3, 6], [-1, 6], [-1, 1], [-1, -2], [3, -2] }

A set's elements are sorted (an automatic simplification).

I use Ctrl-t to change an Exec Group's execution prompt into a text prompt/mode.

Do these plots have the expected form?

I raised working precision to help with numeric accuracy, as well as added the value for E(0).

I also turned E into an operator, just before the plotting, for the E3(nu) plot. Please check. It's a bit confusing, with the assignments to function calls.

PLanckPh_ac.mw

The GUI puts an amount of space below the title, so that if axes=boxed then upon rotation the corners don't get too close to the title. The effective distance then gets large if the plot is rotated. Unfortunately the distance is similar even if axes=normal.

You can get around it by zooming in the plot. For example, right-click to change "manipulator" to zoom, etc. Then the distance to the title can be reduced. Or you could pan (although, with any zoom that can leave blank space at the other end). Note that if you zoom in then not all the plot may be visible at certain orientations.

It is possible to get such effects programmatically. For example,
Plot_title_too_high_ac.mw
 

Inside the call to plot3d, change,

    eval(M)

to,

    eval(M,last[1])

The Help page for next mentions this at the end of its Description section,

"Note:  Multi-level next statements are not currently supported in 2-D input in the Standard interface."

One big choice is whether to make C be taken from an integer ranges (whose number of elements works nicely with the number of frames), and have the 2*Pi factor occur in the plot command's code.

Or you can keep the range C=0..2*Pi and "turn" the values back to rationals.

I'll do the latter of those below.

And even then, there are still some fun choices for customizing the tickmarks and title, to get results that may clearly illustrate the progression.

I'll disable the paraminfo option of animate, and put the rational C values back in using the title option.

Here are a few variants of that, according to whether the title appears at all values, etc. You can adjust to taste. (Note that the number of frames is a nice multiple of the number of intervals. As Kitonum explained, that's key.)

 

NULL

restart

G := plot(sin(x), x = 0 .. 2*Pi, view = [0 .. 2*Pi, -2 .. 2], color = blue, tickmarks = [piticks, default], labels = ["", ""], gridlines, thickness = 2)

N := 48

plots[animate](proc (C) options operator, arrow; plot(sin(x+C), x = 0 .. 2*Pi, thickness = 3, title = (Typesetting:-Typeset(:-C) = convert(C/Pi, rational)*Pi)) end proc, [C], frames = N+1, C = 0 .. 2*Pi, background = G, labels = ["", ""], paraminfo = false, size = [800, 400], axis[1] = [gridlines = spacing((1/12)*Pi), tickmarks = [spacing((1/6)*Pi), subticks = 3]])

plots[animate](proc (C) options operator, arrow; plot(sin(x+C), x = 0 .. 2*Pi, thickness = 3, title = ifelse(denom(convert(C/Pi, rational)) <= 12, Typesetting:-Typeset(:-C) = convert(C/Pi, rational)*Pi, NULL)) end proc, [C], frames = N+1, C = 0 .. 2*Pi, background = G, labels = ["", ""], paraminfo = false, size = [1000, 400], axis[1] = [gridlines = spacing((1/12)*Pi), tickmarks = [spacing((1/12)*Pi), subticks = 1]], ytickmarks = [-1, 0, 1], axesfont = ["Times", 10])

plots[animate](proc (C) options operator, arrow; plot(sin(x+C), x = 0 .. 2*Pi, thickness = 3, title = ifelse(denom(convert(C/Pi, rational)) <= 6, Typesetting:-Typeset(:-C) = convert(C/Pi, rational)*Pi, NULL)) end proc, [C], frames = N+1, C = 0 .. 2*Pi, background = G, labels = ["", ""], paraminfo = false, size = [1000, 400], axis[1] = [gridlines = spacing((1/12)*Pi), tickmarks = [spacing((1/6)*Pi), subticks = 3]], ytickmarks = [-1, 0, 1], axesfont = ["Times", 10])

 

 

Download Q_Pi_scaling_ac.mw

One way is to utilize the Physics:-diff command instead.

restart

with(Physics, diff)

L := -r^2*((-fA(r)^4+(-2*fB(r)^2-2*fC(r)^2+2)*fA(r)^2+4*(D(fB))(r)*fA(r)*fC(r)*r-fB(r)^4+(-2*fC(r)^2+2)*fB(r)^2-4*fB(r)*fC(r)*(D(fA))(r)*r-2*r^2*(D(fA))(r)^2-1-2*r^2*(D(fB))(r)^2)/(2*g^2*r^4)+(r*(fB(r)^2+(1/2)*fC(r)^2+fA(r)^2-2*fA(r)+1)*H(r)^2+(-(D(K))(r)*r^2*fC(r)-2*K(r)*fB(r)*r)*H(r)+(1/2)*K(r)^2*fC(r)^2*r+(D(H))(r)*K(r)*r^2*fC(r)+r*((fB(r)^2+fA(r)^2)*K(r)^2+(1/2)*r^2*((D(H))(r)^2+(D(K))(r)^2)))*v^2/(r^2)^(3/2)-lambda((1/2)*(K(r)^2+H(r)^2-1)*v^2)^2)

-r^2*((1/2)*(-fA(r)^4+(-2*fB(r)^2-2*fC(r)^2+2)*fA(r)^2+4*(D(fB))(r)*fA(r)*fC(r)*r-fB(r)^4+(-2*fC(r)^2+2)*fB(r)^2-4*fB(r)*fC(r)*(D(fA))(r)*r-2*r^2*(D(fA))(r)^2-1-2*r^2*(D(fB))(r)^2)/(g^2*r^4)+(r*(fB(r)^2+(1/2)*fC(r)^2+fA(r)^2-2*fA(r)+1)*H(r)^2+(-(D(K))(r)*r^2*fC(r)-2*K(r)*fB(r)*r)*H(r)+(1/2)*K(r)^2*fC(r)^2*r+(D(H))(r)*K(r)*r^2*fC(r)+r*((fB(r)^2+fA(r)^2)*K(r)^2+(1/2)*r^2*((D(H))(r)^2+(D(K))(r)^2)))*v^2/(r^2)^(3/2)-lambda((1/2)*(K(r)^2+H(r)^2-1)*v^2)^2)

diff(L, fA(r))

-r^2*((1/2)*(-4*fA(r)^3+2*(-2*fB(r)^2-2*fC(r)^2+2)*fA(r)+4*(D(fB))(r)*fC(r)*r)/(g^2*r^4)+(r*(2*fA(r)-2)*H(r)^2+2*r*fA(r)*K(r)^2)*v^2/(r^2)^(3/2))


Download test_funtion_diff.mw

You can do that by calling it with its long-form package name, ie,
     Physics:-diff(..., fA(r))

Or you can load it from the Physics package (as I did in the attachment).
That makes the call,
    diff(..., fA(r))
utilize it since the `diff` name is rebound to the package export.

According to whether k in formula B is even or odd, the B formula corresponds to one of the A formulas.

restart;

S := [solve(sin(x)=1/2, x, allsolutions)];

[(1/6)*Pi+2*Pi*_Z1, (5/6)*Pi+2*Pi*_Z1]

v := indets(S, suffixed(_Z))[1]:

A1 := eval( S[1], v=c1 );

(1/6)*Pi+2*Pi*c1

A2 := eval( S[2], v=c2 );

(5/6)*Pi+2*Pi*c2

B := k*Pi+(-1)^k*Pi/6;

k*Pi+(1/6)*(-1)^k*Pi

expand(simplify( eval(B, [k=2*k]) )) assuming k::integer;
A1 = %;
solve(%);

2*k*Pi+(1/6)*Pi

(1/6)*Pi+2*Pi*c1 = 2*k*Pi+(1/6)*Pi

{c1 = k, k = k}

expand(simplify( eval(B, [k=2*k+1]) )) assuming k::integer;
A2 = %;
solve(%);

2*k*Pi+(5/6)*Pi

(5/6)*Pi+2*Pi*c2 = 2*k*Pi+(5/6)*Pi

{c2 = k, k = k}

Download trig_e_1.mw

You can force the rearrangement of some subterms terms in your R using the sort command. This acts in-place on the internally stored structure.

You may have to forget(latex) to clear remembered results.

In the following example I first (forcibly) create the whole R expression in an order that you don't want. (Otherwise it the problem might not arise...) Thus I can illustrate the effect.

restart

f(x, y, z, t) = 1+exp(k[i]*((-1+sqrt(-4*beta*mu*l[i]-4*delta*mu*r[i]-4*mu*k[i]^2-4*alpha*mu+1))*t/(2*mu)+y*l[i]+r[i]*z+x)+eta[i])

f(x, y, z, t) = 1+exp(k[i]*((1/2)*(-1+(-4*beta*mu*l[i]-4*delta*mu*r[i]-4*mu*k[i]^2-4*alpha*mu+1)^(1/2))*t/mu+y*l[i]+r[i]*z+x)+eta[i])

R := f(x, y, z, t) = 1+exp(k[i]*((-1+sqrt(-4*beta*mu*l[i]-4*delta*mu*r[i]-4*mu*k[i]^2-4*alpha*mu+1))*t/(2*mu)+y*l[i]+r[i]*z+x)+eta[i])

f(x, y, z, t) = 1+exp(k[i]*((1/2)*(-1+(-4*beta*mu*l[i]-4*delta*mu*r[i]-4*mu*k[i]^2-4*alpha*mu+1)^(1/2))*t/mu+y*l[i]+r[i]*z+x)+eta[i])

latex(R)

f \! \left(x , y , z , t\right) =
1+{\mathrm e}^{k_{i} \left(\frac{\left(-1+\sqrt{-4 \beta  \mu  l_{i}-4 \delta  \mu  r_{i}-4 \mu  k_{i}^{2}-4 \alpha  \mu +1}\right) t}{2 \mu}+y l_{i}+r_{i} z +x \right)+\eta_{i}}

sort(R, order = plex(x, y, z))

f(x, y, z, t) = 1+exp(k[i]*(x+l[i]*y+r[i]*z+(1/2)*(-1+(-4*beta*mu*l[i]-4*delta*mu*r[i]-4*mu*k[i]^2-4*alpha*mu+1)^(1/2))*t/mu)+eta[i])

forget(latex); latex(R)

f \! \left(x , y , z , t\right) =
1+{\mathrm e}^{k_{i} \left(x +l_{i} y +r_{i} z +\frac{\left(-1+\sqrt{-4 \beta  \mu  l_{i}-4 \delta  \mu  r_{i}-4 \mu  k_{i}^{2}-4 \alpha  \mu +1}\right) t}{2 \mu}\right)+\eta_{i}}

sort(R, order = plex(z, y, x), ascending)

f(x, y, z, t) = 1+exp(k[i]*((1/2)*(-1+(-4*beta*mu*l[i]-4*delta*mu*r[i]-4*mu*k[i]^2-4*alpha*mu+1)^(1/2))*t/mu+x+l[i]*y+r[i]*z)+eta[i])

forget(latex); latex(R)

f \! \left(x , y , z , t\right) =
1+{\mathrm e}^{k_{i} \left(\frac{\left(-1+\sqrt{-4 \beta  \mu  l_{i}-4 \delta  \mu  r_{i}-4 \mu  k_{i}^{2}-4 \alpha  \mu +1}\right) t}{2 \mu}+x +l_{i} y +r_{i} z \right)+\eta_{i}}


Download latex_sort_ex.mw

nb. Generally, this facility acts on sums which are polynomial in the specified names.

ps. You can also get some such effects with collect, eg.
    subsindets(R, `+`, u -> collect(u, [x, y, z]))
but note that has less control over the term constant wrt x,y,z.

Since you explicitly provide integrals over ranges where the integrand is negative (or positive), then why not shade with colors that illustrate that nicely?

A command that can do that in one call is FunctionChart from the Student:-Calculus1 package.

For example,

Download εμβαδόν_χωρίου_ac.mw


Note: If such a plot is assigned to name foo, then the following will force transparency on it:
     plots:-display(foo, overrideoption, transparency = 0.7)
Or you can simple wrap that around the FunctionPlot call.
εμβαδόν_χωρίου_ac2.mw

Of course, you can also color regions by sign, or add transparency, using just the a single plotting command and a pair of piecewise. One piecewise is undefined for f(x) negative, the other for f(x) positive. That is pretty easy, and requires no break up of the domain, etc.

restart;

with(plots): setoptions(size=[600,300]);

 

form := [piecewise(F(x)>0,F(x),undefined), piecewise(F(x)<0,F(x),undefined)]:

NULL

f := x^3;
F := unapply(f,x,numeric,proc_options=remember):
display(
   plot(form, x = -1 .. 1, filled, color = [cyan, "Coral"]),
   plot(F(x), x = -1 .. 1, color = black, thickness = 2)
);

x^3

f := x^2 - 4*x + 3;
F := unapply(f,x,numeric,proc_options=remember):
display(
   plot(form, x = 1/2..4, filled, color = ["Green", "Coral"]),
   plot(F(x), x = 1/2..4, color = black, thickness = 2)
);

x^2-4*x+3

 

 

Download easy_signed_fill.mw

The point is that you don't have to find all the zero crossings of f(x) and make multiple plots for the subdomains between crossings. Doing so is not hard, but it's unnecessarily complicated in general. In contrast, the piecewise-pair formula works directly, and in general.

ps. You could also use f instead of every F(x) above. I only used option remember to avoid some duplication of computation, even though these simple examples don't have efficiency concerns.

with(plots):
form := [piecewise(f>0,f,undefined), piecewise(f<0,f,undefined)]:

f := x^3;
display(
   plot(form, x = -1 .. 1, filled, color = [cyan, "Coral"]),
   plot(f, x = -1 .. 1, color = black, thickness = 2) );

f := x^2 - 4*x + 3;
display(
   plot(form, x = 1/2..4, filled, color = ["Green", "Coral"]),
   plot(f, x = 1/2..4, color = black, thickness = 2) );

You can add the allsolutions option to the call to the solve command.

Using Maple 2024.2,

restart;

sol := [ solve(sqrt(2)*sin(2*x-Pi/6)=1, allsolutions) ];

[(5/24)*Pi+Pi*_Z1, -(13/24)*Pi+Pi*_Z1]

var := indets(sol, suffixed(`_`))[1];

_Z1

about(var);

Originally _Z1, renamed _Z1~:
  is assumed to be: integer
 

If you prefer,

eval( sol, var = k );

[(5/24)*Pi+Pi*k, -(13/24)*Pi+Pi*k]

Download solve_allsolutions.mw

ps. The point of the indets call is that the generated parameter name can be programmatically extracted. That can help since repeated calls to solve may generate different such names, eg. _Z3, _Z1, _Z17, etc. You can them replace it by, say, k without having to manually enter it of copy&paste. You can also target such names more specifically, eg.
     suffixed(`_Z`)`
or,
     suffixed(`_B`)

pps. It's interesting that versions Maple 2015 (or Maple 2018) and Maple 2024 can produce different valid forms. I used Maple 2024 since that is the version in which the OP's attachment was last saved.

5 6 7 8 9 10 11 Last Page 7 of 336