acer

32303 Reputation

29 Badges

19 years, 306 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

It sounds like you're seeing this problem.

I suggest that you use the settings as I described in that previous thread's Answer, but also with (the default),

    interface(typesetting=extended):

The Y[i] in the result from convertsys are not the global names Y[i].

You could instead work with convert(sys0,`global`), as one simple way to replace those names.

带有阻尼的固有频率分析

restart

with(Typesetting); Settings(typesetdot = true)

with(LinearAlgebra); with(linalg); with(plots); with(DEtools)

couple := diff(q(t), `$`(t, 2))+nu*(diff(q(t), t))/omega+q(t)+b*L__1*(diff(x(t), `$`(t, 2)))/L-`α__11`*L__1*(diff(x(t), t))/(L*omega)-`α__22`*omega*r*L^2*(diff(q(t), t))^3, diff(eta(t), `$`(t, 2))+nu*(diff(eta(t), t))/omega+eta(t)+b*L__1*(diff(x(t), `$`(t, 2)))/L-`α__11`*L__1*(diff(x(t), t))/(L*omega)-`α__22`*omega*r*L^2*(diff(eta(t), t))^3, diff(x(t), `$`(t, 2))+`ν__1`*(diff(x(t), t))/omega+(`ω__1`/omega)^2*x(t)+g*gamma*L*(diff(q(t), `$`(t, 2)))/L__1+g*gamma*L*(diff(eta(t), `$`(t, 2)))/L__1-`α__11`*L*(diff(q(t), t))/(omega*L__1)-`α__11`*L*(diff(eta(t), t))/(omega*L__1)-omega*r*L^3*`ς`*(diff(q(t), t))^3/L__1-omega*r*L^3*`ς`*(diff(eta(t), t))^3/L__1

couple1 := seq(remove(has, [couple][i], [(diff(q(t), t))^3, (diff(eta(t), t))^3]), i = 1 .. 3)

NULL

data := nu = 2*xi*`ω__2`-(1/2)*a__11*`ρ__air`*D*h__2*U*p__2^2, `ν__1` = 2*xi*`ω__1`-(1/2)*a__11*`ρ__air`*D*h__2*U*p__12^2-(1/2)*a__11*`ρ__air`*D*h__2*U*p__13^2

eqn := subs(data, [couple1])

with(DEtools)

temp := convertsys({eqn[]}, [], {eta, q, x}, t); sys0 := `~`[rhs](%[1]); vars := `%%`[2]

[Y[1] = eta(t), Y[2] = diff(eta(t), t), Y[3] = q(t), Y[4] = diff(q(t), t), Y[5] = x(t), Y[6] = diff(x(t), t)]

var1 := [seq(Y[i], i = 1 .. 6)]

[Y[1], Y[2], Y[3], Y[4], Y[5], Y[6]]

[indets(var1, specindex({Y}))[]]; map(addressof, %)

[Y[1], Y[2], Y[3], Y[4], Y[5], Y[6]]

[36893628250316374108, 36893628250316374132, 36893628250316374156, 36893628250316374180, 36893628250316374204, 36893628250316374228]

foo := [indets(temp, anyindex(anything))[]][1 .. 6]; map(addressof, %)

[Y[1], Y[2], Y[3], Y[4], Y[5], Y[6]]

[36893628250228598724, 36893628250228598916, 36893628250228599252, 36893628250228599444, 36893628250228599780, 36893628250228599972]

map(addressof, convert(foo, `global`))

[36893628250316374108, 36893628250316374132, 36893628250316374156, 36893628250316374180, 36893628250316374204, 36893628250316374228]

collect(simplify(expand(convert(sys0, `global`))), var1, distributed)

[Y[2], -(1/2)*(b*g*gamma-1)*Y[1]/(b*g*gamma-1/2)+(1/4)*((g*(D*U*a__11*h__2*p__2^2*rho__air-4*xi*omega__2)*gamma+2*alpha__11)*L*b-(D*U*a__11*h__2*p__2^2*rho__air-4*xi*omega__2)*L)*Y[2]/(omega*L*(b*g*gamma-1/2))+(1/2)*b*g*gamma*Y[3]/(b*g*gamma-1/2)+(1/4)*(-g*(D*U*a__11*h__2*p__2^2*rho__air-4*xi*omega__2)*gamma+2*alpha__11)*b*Y[4]/(omega*(b*g*gamma-1/2))-(1/2)*b*L__1*omega__1^2*Y[5]/(L*(b*g*gamma-1/2)*omega^2)+(1/4)*((D*a__11*U*h__2*(p__12^2+p__13^2)*rho__air-4*xi*omega__1)*L__1*b-2*alpha__11*L__1)*Y[6]/(omega*L*(b*g*gamma-1/2)), Y[4], (1/2)*b*g*gamma*Y[1]/(b*g*gamma-1/2)+(1/4)*(-g*(D*U*a__11*h__2*p__2^2*rho__air-4*xi*omega__2)*gamma+2*alpha__11)*b*Y[2]/(omega*(b*g*gamma-1/2))+(1/2)*(-b*g*gamma+1)*Y[3]/(b*g*gamma-1/2)+(1/4)*((g*(D*U*a__11*h__2*p__2^2*rho__air-4*xi*omega__2)*gamma+2*alpha__11)*L*b-(D*U*a__11*h__2*p__2^2*rho__air-4*xi*omega__2)*L)*Y[4]/(omega*L*(b*g*gamma-1/2))-(1/2)*b*L__1*omega__1^2*Y[5]/(L*(b*g*gamma-1/2)*omega^2)+(1/4)*((D*a__11*U*h__2*(p__12^2+p__13^2)*rho__air-4*xi*omega__1)*L__1*b-2*alpha__11*L__1)*Y[6]/(omega*L*(b*g*gamma-1/2)), Y[6], -(1/2)*gamma*g*L*Y[1]/((b*g*gamma-1/2)*L__1)+(1/4)*(g*(D*U*a__11*h__2*p__2^2*rho__air-4*xi*omega__2)*L*gamma-2*alpha__11*L)*Y[2]/(omega*(b*g*gamma-1/2)*L__1)-(1/2)*gamma*g*L*Y[3]/((b*g*gamma-1/2)*L__1)+(1/4)*(g*(D*U*a__11*h__2*p__2^2*rho__air-4*xi*omega__2)*L*gamma-2*alpha__11*L)*Y[4]/(omega*(b*g*gamma-1/2)*L__1)+(1/2)*omega__1^2*Y[5]/((b*g*gamma-1/2)*omega^2)+(1/4)*(4*g*alpha__11*L__1*gamma-(D*a__11*U*h__2*(p__12^2+p__13^2)*rho__air-4*xi*omega__1)*L__1)*Y[6]/(omega*(b*g*gamma-1/2)*L__1)]

 

 

Download nature_frequency_question_ac.mw


ps. I did a similar thing just a few weeks ago, in order to substitute for such names.

There are lots of ways to get such a construction. Here are a few.

restart;

f := x -> x[1]^2 + x[2]^2

proc (x) options operator, arrow; x[1]^2+x[2]^2 end proc

# correction of your attempt
# this inefficiently does the differentations every
# time it gets called.
Gf1 := proc(v::{list,Vector}) local x;
         eval(<diff(f(x),x[1]),diff(f(x),x[2])>,
              [x[1]=v[1], x[2]=v[2]]);
       end proc:

Gf1(<2,3>);

Vector(2, {(1) = 4, (2) = 6})

# this does the differentiations once, up front
# presuming that the procedure f returns the expected
# expression when called with symbolic arguments
Gf2 := unapply(Student:-MultivariateCalculus:-Gradient(f(<x[1],x[2]>),
                                                       [x[1],x[2]]),
               x::{list,Vector}):

Gf2(<2,3>);

Vector(2, {(1) = 4, (2) = 6})

# this does the differentiations once, up front
# presuming that the procedure f returns the expected
# expression when called with symbolic arguments
Gf3 := unapply(<diff(f(x),x[1]),diff(f(x),x[2])>,
               x::{list,Vector}):

Gf3(<2,3>);

Vector(2, {(1) = 4, (2) = 6})

F := (a,b) -> a^2 + b^2;

proc (a, b) options operator, arrow; b^2+a^2 end proc

D[1](F), D[2](F);
D[1](F)(2,3), D[2](F)(2,3);

proc (a, b) options operator, arrow; 2*a end proc, proc (a, b) options operator, arrow; 2*b end proc

4, 6

# this does the differentiations once, up front
# using automatic differentiation of procedure f.
Gf4 := subs( d1f=D[1](F), d2f=D[2](F),
             (v::{list,Vector}) -> <d1f(v[1],v[2]),
                                    d2f(v[1],v[2])> ):

Gf4(<2,3>);

Vector(2, {(1) = 4, (2) = 6})

Download grad_f_ex.mw

Another way is to use the n=i for tickmarks along the vertical axis placed at the right.

Here are some ideas along those lines. I wasn't sure how much of the rest of the stylistic elements from your image you wanted to mimic. There is also a version in the attachment with gridlines, but no left-axis. It's your choice of how you want to mix and match such features. (If you have difficulty please just state exactly what look&feel you want.)

S7MAA_Dveloppement_Limit_ac.mw
 

Looking at the structure of the inert integral representation of the PDF (GG in the attachment) then it's not clear (to me) how an elliptic special-function would not appear in the result of symbolic integration.

But, you can reformulate and get rid of the I appearance. (That instance is not the only contributor of imaginary values here, and is countered by other contributors for which the I doesn't appear explicitly.)

And you can also force some simplification and a specific integration method for which the final integration result is much simpler. But, still an elliptic special-function.

Here, I use Maple 2023 (as you did).

Basics_ac1.mw

This site is not letting me inline my attachment right now. But the simpler result is,

    8*EllipticK((-2 + t)/(t + 2))/(Pi^2*(t + 2))

which evaluates to purely real values (for any real t),

and its plot is,

which doesn't have the unfortunate gaps where your plot of your y expression runs into small imaginary float artefacts which are still large enough to disrupt the plot driver.

ps. You also wrote that, "Even a numerical solution would be fine." But you already have a plot. And you complaint is about the formula. So what does "a numeric solution" mean, in that case!? Do you mean that you would be OK with, say, an approximating rational polynomial with float coefficients?

You get so much numeric error that the implicitplot(s) appear empty if the working precision is too small.

You can get noise (and false implicit level-curves) if Digits is increased but still too low.

If you're lucky you can hope that you can find a high enough setting for Digits to that the numeric error is small enough that you get a decently representative implicitplot.

PLOT11_ac0.mw

In the following plot the blue curve is the implicitplot of the imaginary component of your expression, and the red curve is the implicitplot of the real portion. That is using Digits=50.

It might also be possible to rearrange the expression (or terms in it) and so improve the numeric error situation. I didn't try.

You could compare with results in other Answers threads posted so far, but I am not sure that adequate working precision was used throughout. As explained in my worksheet, raising Digits can get you some results rather than your original empty plots, but it might not be enough (in which case spurious zeroes might even be "found").

As dharr noted, the situation might possibly be further improved if you used higher working precision while forming your mixed float/symbolic expression -- though we have been given no clues at all as to how it was formed. Possibly even better might be if you had an earlier purely exact symbolic expression (with no floats at all), which might be manipulated and then evaluated to float numeric with less running error. We cannot know any of that, being quite in the dark.

In your first attempt you forgot to load the inttrans package (like you did in the second attempt).

So the invfourier calls in the first attempt don't resolve to anything -- it's just an unassigned and meaningless name.

If you add the command,
   with(inttrans):
to the first attempt (just like it is for the second attempt) then it works.

nb. You could also apply the assumptions that dharr suggested. But that is not strictly necessary, in order to get actual plots in your problem case. Whether you also do that depends on what specifics you want for your alternative approach(es).

But the missing with(inttrans) was what was preventing it from working altogether.

It looks as if, somehow, your GUI setting for the level of pretty-printing of Output has become 1 (ie. plaintext character notation).

Not only is that unwanted, but for some years now it doesn't even work as it ought to due to some muddle with typesetting level. ie, interface(typesetting).

Anyway, you can check that thee Output setting is wrong by looking in the GUI Options menu, at the
    Display -> Output display
item which normally is
    "2-D Math"
but for you might be wrongly set as, say, "Character Notation".

If you set it to "2-D Math", and then close the menu by clicking on,
   "Apply Globally"
then you ought to be good to go. That should store the option for future GUI sessions.

You can also check that it's wrong by issuing the command,
   interface(prettyprint)
which I suspect would have returned 1 (ie. one) when in that wrong state. You can manually/programmatically set that in a session, but it's unclear how that affects what setting value the GUI saves when you close it.

My guess is that you are using 2D Input mode and that you have the right-panel (aka context-panel open), and that placing the cursor (mouse/pointer focus) in that input causes it to evaluate.

You could collapse the right-panel entirely, using the double-chevron appearing near it stop in the GUI.

Or (even with the right-panel open), you could execute the command,
     _EnvSubexpressionMenu := false:
say at the top of your sheet (or after explicit restart).

Either of those seem to remedy the situation, for me, in Maple 2025.

I will submit a bug report.  There is an internal list of things for which not analyze subexpression menu items (or context-panel suggested actions), and it looks like this belongs in it (because it acts in-place on first argument M; ie. has a side-effect on it).

You can make the conditional test the argument of a procedure.

That gains you the flexibility of being able to make different/arbitrary queries involving multiple variables and conditions.

color_Q.mw

colortf := (ee::boolean) -> nprintf(`#mi(%s, mathcolor=%s)`,
              ifelse(ee,["true","red"],["false","blue"])[]):

x1 := 1: x2 := 4:

colortf( x1 > 1 );
                   false

colortf( x2 > 1 );
                    true

colortf( x1 > 1 or x2 > -5 );
                    true

colortf( x1::odd and x2::even );
                    true

colortf( x1 > -6 and x2 < 3 );
                   false


You could also utilize the is command, rather than evalb, (which `if` and ifelse use by default) to test the conditional. That handles the earlier examples but also allows testing of inferences based on assumptions or involving some symbolic inequality.

coloris := proc(ee::{boolean,`::`}) local p,r;
             r := is(ee);
             if r=true then p := ["true","red"];
             elif r=false then p := ["false","blue"];
             else p := ["FAIL","black"]; end if;
             nprintf(`#mi(%s, mathcolor=%s)`,p[]);
end proc:

coloris( x1 > 1 );
                   false

coloris( x2 > 1 );
                    true

coloris( (2*y+1)::odd ) assuming y::integer;
                    true

coloris( y > 3 ) assuming y > 5;
                    true

assume( w > 6 );
coloris( y + w > 10 ) assuming y > 0;
                   false

coloris( f(y) > 0 ) assuming y::posint;
                   FAIL

You could have a look at the DEtools[convertsys] command.

restart;

Typesetting:-Settings(prime=t):
Typesetting:-Settings(typesetprime=true):

 

de := diff(y(t), t$2) + 3*diff(y(t), t) + 2*y(t) = exp(t);

diff(diff(y(t), t), t)+3*(diff(y(t), t))+2*y(t) = exp(t)

raw := DEtools[convertsys]({de}, {}, {y(t)}, t, s)[1..2];

[[YP[1] = s[2], YP[2] = exp(t)-3*s[2]-2*s[1]], [s[1] = y(t), s[2] = diff(y(t), t)]]

eval(raw, [s[1]=u, s[2]=v]);

[[YP[1] = v, YP[2] = exp(t)-3*v-2*u], [u = y(t), v = diff(y(t), t)]]

de := diff(x(t), t$2) = x(t)- x(t)^3;

diff(diff(x(t), t), t) = x(t)-x(t)^3

DEtools[convertsys]({de}, {}, {x(t)}, t, y)[1..2];

[[YP[1] = y[2], YP[2] = -y[1]^3+y[1]], [y[1] = x(t), y[2] = diff(x(t), t)]]

de := diff(y(t), t$2) - 5*diff(y(t), t) + 6*y(t) = 0;

diff(diff(y(t), t), t)-5*(diff(y(t), t))+6*y(t) = 0

raw := DEtools[convertsys]({de}, {}, {y(t)}, t, s)[1..2];

[[YP[1] = s[2], YP[2] = 5*s[2]-6*s[1]], [s[1] = y(t), s[2] = diff(y(t), t)]]

new := eval(convert(raw,`global`), [s[1]=u, s[2]=v]);

[[YP[1] = v, YP[2] = 5*v-6*u], [u = y(t), v = diff(y(t), t)]]

new2 := eval(new[1], [YP[1]=diff(u(t),t), YP[2]=diff(v(t),t)]);

[diff(u(t), t) = v, diff(v(t), t) = 5*v-6*u]

Download convertsys_ex0.mw

You could also use LinearAlgebra:-GenerateMatrix as one way to express the new equations in Matrix form.

Is the output of such expressions also suboptimal?

Sorry, all I can think of offhand is a way printed results might look better in this regard. Eg, using Maple,

restart;

 

1/conjugate(foo(x));

1/conjugate(foo(x))

1/conjugate(x);

1/conjugate(x)

1/conjugate(x*y+z);

1/conjugate(x*y+z)

restart;

`print/conjugate` := proc(t)
  uses Typesetting;
  msup(mover(Typeset(t),mo(`&conjugate0;`)),mo(``));
end proc:

 

1/conjugate(foo(x));

1/conjugate(foo(x))

1/conjugate(x);

1/conjugate(x)

1/conjugate(x*y+z);

1/conjugate(x*y+z)

Download conj_pr.mw

Do you have the ability to add an arbitrary Favorites palette entry? (just wondering about an idea...)

The Describe command uses the printf facility, which is not the same as regular print.

Perhaps you could instead get by with,

   op(5,eval(timing))

which programmatically returns the description portion of a procedure.

Or you might explicitly print that, if within some other procedure body, ie.

   print(op(5,eval(timing)))


ps. I haven't double checked where Flow puts print'd or even printf'd display. I replied mostly because you wrote "print".

On my Linux machine a local-disk installation of Maple 2025.0 (running the already downloaded installation file, from a local account, into a local host location) took about 2.5 mins on a somewhat old Intel Core-i5.

The same installation from downloaded file, from&to an nfs mounted location, took about 8.5 mins.

Over the years I've noticed a few items like tensorflow, curated data, and pre-computed large Group Theory data files can take up large amounts of space and slow down the install. But the biggest change seems to be that the maple.help Help database step takes longer (about 45sec).

Some major releases ago I could do a local install in less than a minute. Eg. purely local disk install of Maple2020.2 takes 50sec on the same machine.

Your main problem is that when you call Median(f) or Percentile(f,50) you haven't let it know that you intend on f being interpreted as a Probability Density Function.

restart

kernelopts(version)

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

with(Statistics)

f := 2*t*piecewise(t <= 0, 0, t <= 1, t^2+Pi-4*t, t <= sqrt(2), -(sqrt(t^2-1)*t^2+2*sqrt(t^2-1)*arcsin((t^2-2)/t^2)-4*t^2+2*sqrt(t^2-1)+4)/sqrt(t^2-1), sqrt(2) < t, 0)

RV := RandomVariable(PDF = unapply(f, t), Support = 0 .. infinity)

Median(RV, numeric)

HFloat(0.5120032690832947)

Percentile(RV, 50, numeric)

HFloat(0.5120032690832947)

myM := int(f, t = 0 .. x)

fsolve(myM = 1/2, x = 0 .. infinity)

.5120032691

alt := CDF(RV, t)

piecewise(t <= 0, 0, t <= 1, (1/2)*t^4+Pi*t^2-(8/3)*t^3, t <= 2^(1/2), (1/6)*(-3*((t^2-1)/t^4)^(1/2)*t^6+16*(t^2-1)^(3/2)*t^2*((t^2-1)/t^4)^(1/2)-12*t^4*arcsin((t^2-2)/t^2)*((t^2-1)/t^4)^(1/2)-12*((t^2-1)/t^4)^(1/2)*t^4+2*t^2*((t^2-1)/t^4)^(1/2)+24*t^2-24)/(t^2*((t^2-1)/t^4)^(1/2)), 2^(1/2) < t, 1)

simplify(alt-(eval(myM, x = t)))

0

Download Median_ac.mw

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