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

One way is to utilize the plots:-listplot command, with the useunits option.

testSheetHorseShoe_ac.mw

That attachment produce the following, amongst a few other plots.

The plot command works with Maple's usual scheme for procedure calls, and its arguments are evaluated up-front, ie. before the plot routine receieves them.

So when you call,

   plot(kk(3,m)[1], ...)

then the call kk(3,m) gets evaluated up-front, ie. before m gets any actual numeric values.

But when m is just a symbolic name then the sort actions inside your kk procedure don't act the same way (for generic name m) as they would for all the numeric values of m.

The key thing, then, is to delay the evalutation of the argument k(3,m)[1] passed to the plot command until such time as name m gets actual numeric values. That avoids the so-called premature evaluation.

This is a very common user-issue.

Below, I show you code for two ways to delay that evaluation, for your plot attempts. The underlying problem and its possible alternatives are the same here for plot3d as they are for plot, so I'll leave those for you to adjust according to whichever approach you choose.

restart

with(LinearAlgebra); with(Typesetting); Settings(typesetdot = true); with(plots); with(DEtools); with(MultiSeries); with(plottools)

couple := [diff(x(t), `$`(t, 2))+2*xi*`ω__1`*(diff(x(t), t))+`ω__1`^2*x(t)+m__1*l*(diff(`ϕ`(t), `$`(t, 2)))-m__1*l*(diff(varphi(t), t))^2*varphi(t) = F*cos(Omega*t), diff(varphi(t), `$`(t, 2))+(diff(x(t), `$`(t, 2)))/l+`ω__2`^2*varphi(t) = 0]

couple1 := remove(has, (lhs-rhs)(couple[1]), [2*xi*`ω__1`*(diff(x(t), t)), m__1*l*(diff(`ϕ`(t), t))^2*`ϕ`(t), F*cos(Omega*t)])+epsilon*select(has, (lhs-rhs)(couple[1]), [2*xi*`ω__1`*(diff(x(t), t)), m__1*l*(diff(`ϕ`(t), t))^2*`ϕ`(t), F*cos(Omega*t)]); couple2 := (lhs-rhs)(couple[2])

变换F的值,F=f cos((Omega2+εσ)(T0+εT1))

data1 := F*cos(Omega*t) = f*cos(applyrule(T__0*epsilon = T__1, expand((epsilon*sigma+`Ω__2`)*T__0)))

couple := [subs(data1, couple1), couple2]

timescales := T__0, T__1

dt__1 := proc (expr) options operator, arrow; diff(expr, T__0)+epsilon*(diff(expr, T__1)) end proc

dt__2 := proc (expr) options operator, arrow; diff(expr, `$`(T__0, 2))+2*epsilon*(diff(diff(expr, T__1), T__0))+epsilon^2*(diff(expr, `$`(T__1, 2))) end proc

expand_1 := subs(diff(x(t), t, t) = dt__2(x(timescales)), diff(x(t), t) = dt__1(x(timescales)), x(t) = x(timescales), diff(`ϕ`(t), t, t) = dt__2(`ϕ`(timescales)), diff(`ϕ`(t), t) = dt__1(`ϕ`(timescales)), `ϕ`(t) = `ϕ`(timescales), couple)

fexpand := seq(convert(series(expand_1[i], epsilon = 0, 2), polynom), i = 1 .. 2)

solForm := map(proc (term) local i; term(timescales) = add(epsilon^i*term[i](timescales), i = 0 .. 1) end proc, [x, varphi])[]

fexpand2 := seq(seq(coeff(expand(subs(solForm, fexpand[i])), epsilon^j), i = 1 .. 2), j = 1 .. 2)

ordery0 := map(proc (expr) options operator, arrow; expr = 0 end proc, [seq(remove(has, expand(subs(solForm, fexpand[i])), epsilon), i = 1 .. 2)])[]

ordery1 := seq(select(has, fexpand2[i], [diff(x[1](T__0, T__1), T__0, T__0), diff(x[1](T__0, T__1), T__0, T__0), x[1](T__0, T__1), diff(x[1](T__0, T__1), T__0), diff(`ϕ`[1](T__0, T__1), T__0), `ϕ`[1](T__0, T__1), V[1](T__0, T__1)]) = -remove(has, fexpand2[i], [diff(`ϕ`[1](T__0, T__1), T__0, T__0), diff(x[1](T__0, T__1), T__0, T__0), x[1](T__0, T__1), diff(x[1](T__0, T__1), T__0), diff(`ϕ`[1](T__0, T__1), T__0), `ϕ`[1](T__0, T__1), V[1](T__0, T__1)]), i = 1 .. 2)[]

针对最初上部方程求解固有频率

couple1 := [remove(has, couple[1], epsilon), couple[2]]

data2 := x(t) = x__0*exp(I*omega*t), varphi(t) = `ϕ__0`*exp(I*omega*t)

expand(simplify(expand(subs(data2, couple1)/exp(I*omega*t)))); AA, bb := GenerateMatrix(%, [x__0, `ϕ__0`]); det := Determinant(AA); omega_nature := solve(%, omega)

NULL

data4 := xi = 0.25e-1, g = 9.8, M = 300, k = 2000, F = 600

m__1 := subs(data4, m/(m+M)); `ω__1` := evalf(subs(data4, sqrt(k/(m+M)))); `ω__2` := evalf(subs(data4, sqrt(g/l))); f := subs(data4, F/(m+M))

`Ω__1` := sort(subs(data4, `~`[evalf]([omega_nature])))[3]; `Ω__2` := sort(subs(data4, `~`[evalf]([omega_nature])))[4]

Q__1 := subs(data4, l*m__1*`Ω__1`^2/(-`Ω__1`^2+`ω__1`^2)); Q__2 := subs(data4, l*m__1*`Ω__2`^2/(-`Ω__2`^2+`ω__1`^2))

sort(subs(l = 3, m = 300, evalf([omega_nature])))

subs(data4, l = 1, m = 100, `~`[evalf]([omega_nature]))

绘制比例Q2的变化曲线

 

kk := proc (i, ii) local Omega1, Omega2, Q1, Q2; Omega1 := sort(subs(data4, l = i, m = ii, `~`[evalf]([omega_nature])))[3]; Omega2 := sort(subs(data4, l = i, m = ii, `~`[evalf]([omega_nature])))[4]; Q1 := subs(data4, l = i, m = ii, l*m__1*Omega1^2/(-Omega1^2+`ω__1`^2)); Q2 := subs(data4, l = i, m = ii, l*m__1*Omega2^2/(-Omega2^2+`ω__1`^2)); return Omega1, Omega2, Q1, Q2 end proc

Notice the distinction here!

kk(3, 300)

1.390272336, 3.356656496, 2.070214276, -2.130214275


If instead you call kk with a symbolic second argument m then
that calls evaluates, and subsequent substitution with numeric values
or 
m is a completely different result from calling kk with the actual
numeric second arguments.


So, in your procedure, the sort actions will work differently if m
is not an actual number.

That's what's gone wrong in your original plotting attempts. It's
sometimes called "premature evaluation". The plot call is
receiving the prematurely evaluated result from kk(3,m).
temp := kk(3, m); eval(%, m = 300)

3.356656496, -3.356656496, -2.130214275, -2.130214275

One was to deal with it is to use the operator-form
calling sequence of the plot command.
plot(proc (m) options operator, arrow; kk(3, m)[1] end proc, 200 .. 600)

This is your original attempt, with argument kk(3,m) accidentally evaluated too early.

plot(kk(3, m)[1], m = 200 .. 600)

Another way to handle it is to make your procedure
kk return unevaluated if its arguments are not the
"expected" type, ie. numeric.

altkk := proc(i, ii) local Omega1, Omega2, Q1, Q2;
  if not ii::numeric and i::numeric then return 'procname'(args); end if;
  Omega1 := sort(subs(data4, l = i, m = ii, evalf~([omega_nature])))[3];
  Omega2 := sort(subs(data4, l = i, m = ii, evalf~([omega_nature])))[4];
  Q1 := subs(data4, l = i, m = ii, l*m__1*Omega1^2/(-Omega1^2 + omega__1^2));
  Q2 := subs(data4, l = i, m = ii, l*m__1*Omega2^2/(-Omega2^2 + omega__1^2));
  return Omega1, Omega2, Q1, Q2;
end proc;

proc (i, ii) local Omega1, Omega2, Q1, Q2; if not ii::numeric and i::numeric then return ('procname')(args) end if; Omega1 := sort(subs(data4, l = i, m = ii, `~`[evalf]([omega_nature])))[3]; Omega2 := sort(subs(data4, l = i, m = ii, `~`[evalf]([omega_nature])))[4]; Q1 := subs(data4, l = i, m = ii, l*m__1*Omega1^2/(-Omega1^2+omega__1^2)); Q2 := subs(data4, l = i, m = ii, l*m__1*Omega2^2/(-Omega2^2+omega__1^2)); return Omega1, Omega2, Q1, Q2 end proc

altkk(3,m);

altkk(3, m)

plot(altkk(3, m)[1], m = 200 .. 600);

NULL

Download gra423_Omega_ac.mw

nb. You could also delay the evaluation with single right-ticks (aka unevaluation quotes), by instead doing it as,
      plot( 'kk(3,m)'[1], ... )
but I didn't show that above because quotes seems to confused some people (and also because the uneval-quotes are ephemeral; if you pass around an expression with them then they vanish, upon intermediate evaluation...). Definitely not the best choice.

ps. There are several kinds of ways in which the issue of premature evaluation can be an issue. Another common case is where an error message occurs when the plotted procedure call gets accidentally evaluated. As you can see from that link, that error is common enough that it has its own special page. Your situation is more insidious because instead of a helpful error and stoppage your code merely procedes with wrong values (which for another example might possibly be overlooked).

Using implicitplot3d for generating a plot of a plane is a relatively very inefficient way to do it.

But first, to address your particular query: No, you don't need the plots:-display call, and that's not actually what made it work for you. What made it work for you is that your large plot structure by default needs a separate printing, without being in an assignment statement, in order for the GUI to render the plot. See the attachment below, for an example.

A more efficient way to construct the 3D plot of the plane would be to use the plot3d command with the minimal grid=[2,2] option. (Using a small plot structure will get better GUI performance if you have to rotate it much, or use it in an animation, or export it, or transform it, or right-click adjust it much, etc.)

restart

with(plots)

pln := x-2*y+3*z

x-2*y+3*z

P := plot3d(solve(pln, z), x = -3 .. 3, y = -3 .. 3, grid = [2, 2], transparency = .6)

length(P)

117

P;P

plt0 := implicitplot3d(pln, x = -3 .. 3, y = -3 .. 3, z = -3 .. 3, style = patchnogrid, transparency = .6)

length(plt0)

108118

plt0;plt0

NULL

Download 2025-05-18_Q_display_a_simple_plane_ac.mw


nb. For this example, the plt0 structure is about 1000 times larger than P.

Here are a few ways, producing either Matrices or DataFrames. Choose which you'd prefer.

The key bit seems to be removal of the datatype=truefalse from the inner Matrix, so that arbitrary substitutions can be made. That datatype restricts what kind of value can the stored entries can take.

I've split these into a few steps, both to show an idea of what's going on as well as to allow you to just take the generated Matrix rather than the new DataFrame (if you prefer).

restart;

with(Logic):

T:=TruthTable(a &xor b)

DataFrame(Matrix(4, 3, {(1, 1) = false, (1, 2) = false, (1, 3) = false, (2, 1) = false, (2, 2) = true, (2, 3) = true, (3, 1) = true, (3, 2) = false, (3, 3) = true, (4, 1) = true, (4, 2) = true, (4, 3) = false}), rows = [1, 2, 3, 4], columns = [a, b, value], datatypes = [truefalse, truefalse, truefalse])


The Matrix container inside the DataFrame assigned to T has
datatype=truefalse, which is awkward because it restricts
what kind of value can be used as replacement.

Let's re-construct the DataFrame, without that restriction.

T2:=DataFrame(Matrix(convert(T,Matrix),'datatype'=anything),
              columns=['a','b',value]);

DataFrame(Matrix(4, 3, {(1, 1) = false, (1, 2) = false, (1, 3) = false, (2, 1) = false, (2, 2) = true, (2, 3) = true, (3, 1) = true, (3, 2) = false, (3, 3) = true, (4, 1) = true, (4, 2) = true, (4, 3) = false}), rows = [1, 2, 3, 4], columns = [a, b, value])

map(e->subs(true='t',false='f',e),T2);

DataFrame(Matrix(4, 3, {(1, 1) = f, (1, 2) = f, (1, 3) = f, (2, 1) = f, (2, 2) = t, (2, 3) = t, (3, 1) = t, (3, 2) = f, (3, 3) = t, (4, 1) = t, (4, 2) = t, (4, 3) = f}), rows = [1, 2, 3, 4], columns = [a, b, value])


Another way to do it...

M0 := Matrix(convert(T,Matrix),'datatype'=anything);
subs(true='t',false='f',M0);
DataFrame(%, columns=['a','b',value]);

Matrix(4, 3, {(1, 1) = false, (1, 2) = false, (1, 3) = false, (2, 1) = false, (2, 2) = true, (2, 3) = true, (3, 1) = true, (3, 2) = false, (3, 3) = true, (4, 1) = true, (4, 2) = true, (4, 3) = false})

Matrix(4, 3, {(1, 1) = f, (1, 2) = f, (1, 3) = f, (2, 1) = f, (2, 2) = t, (2, 3) = t, (3, 1) = t, (3, 2) = f, (3, 3) = t, (4, 1) = t, (4, 2) = t, (4, 3) = f})

module DataFrame () description "two-dimensional rich data container"; local columns, rows, data, binder; option object(BaseDataObject); end module


And another...

M1 := map(e->subs(true='t',false='f',e),convert(T,Matrix));
DataFrame(M1, columns=['a','b',value]);

Matrix(4, 3, {(1, 1) = f, (1, 2) = f, (1, 3) = f, (2, 1) = f, (2, 2) = t, (2, 3) = t, (3, 1) = t, (3, 2) = f, (3, 3) = t, (4, 1) = t, (4, 2) = t, (4, 3) = f})

module DataFrame () description "two-dimensional rich data container"; local columns, rows, data, binder; option object(BaseDataObject); end module


Yet another way...

M := TruthTable(a &xor b, 'output'=Matrix);
M2 := map(e->subs(true='t',false='f',e),M);
DataFrame(M2, columns=['a','b',value]);

Matrix(4, 3, {(1, 1) = false, (1, 2) = false, (1, 3) = false, (2, 1) = false, (2, 2) = true, (2, 3) = true, (3, 1) = true, (3, 2) = false, (3, 3) = true, (4, 1) = true, (4, 2) = true, (4, 3) = false})

Matrix(4, 3, {(1, 1) = f, (1, 2) = f, (1, 3) = f, (2, 1) = f, (2, 2) = t, (2, 3) = t, (3, 1) = t, (3, 2) = f, (3, 3) = t, (4, 1) = t, (4, 2) = t, (4, 3) = f})

module DataFrame () description "two-dimensional rich data container"; local columns, rows, data, binder; option object(BaseDataObject); end module

Download TT_dt.mw

You can use Or(x<1,x>1), to forestall difficulties with assuming x<>1 (both at once, which can sometimes accidentally turn into `false`).

restart;

ode := diff(y(x),x)*(x-ln(diff(y(x),x))) = 1;

(diff(y(x), x))*(x-ln(diff(y(x), x))) = 1

maple_sol := dsolve(ode);

y(x) = -(1+LambertW(-exp(-x))*x+LambertW(-exp(-x))^2)/LambertW(-exp(-x))+c__1

odetest(maple_sol,ode) assuming Or(x<1,x>1);

0

Download odetest_challange_may_15_2025_ac.mw

ps. I do not recommend using simplify(...,symbolic), if you really care about whether the result is correct.

It's pretty easy to just do the brute force check, with a double seq/loop, and quite quick for just going up to 100.

So, for a fun alternative,

restart;


You can stop looking above x=N

N := floor(fsolve(factorial(x)+1=100^2, x=1..100));

7

F := x -> local X := x! + 1;
          ifelse(issqr(X),[x,sqrt(X)],NULL):

 

sols := CodeTools:-Usage( [ seq(F(x), x=1..N) ] );

memory used=5.64KiB, alloc change=0 bytes, cpu time=0ns, real time=0ns, gc time=0ns

[[4, 5], [5, 11], [7, 71]]


Now, let's display those results,

seq( print(InertForm:-Display(`%factorial`(s[1])+1=s[2]%^2,
                              'inert'=false)),  s=sols);

factorial(4)+1 = `%^`(5, 2)

factorial(5)+1 = `%^`(11, 2)

factorial(7)+1 = `%^`(71, 2); "_noterminate"

Download sol_fac.mw

Since N=7 is small there are even more lightweight and very fast alternative approaches. (Even the cost of the F procedure calls is slightly wasteful here.) Perhaps the nice typesetting of the solutions is the more interesting bit here, and naturally you can use that no matter how you compute the solutions.

Another way, for the second problem,

restart

c := sum(1/i, i = 1 .. n)

Psi(n+1)+gamma

c := expand(c)

Psi(n)+1/n+gamma

s := sum(c/(n*(n+1)), n = 1 .. infinity)

(1/6)*Pi^2

Download test1_ac.mw

I agree that it is a bug, the behaviour is at odds with the Description on the ?convert,Vector Help page which states that the default orientation is column.

I notice that Description says that an Array or list would each be passed straight to the Vector constructor. But notice the following difference in behavior (which appears to be the explanation of the behavioral side of the coin here):

A := Array([1, 2, 3]);

Vector[row](3, {(1) = 1, (2) = 2, (3) = 3})

Vector(A);

Vector[row](3, {(1) = 1, (2) = 2, (3) = 3})

L := [1,2,3];

[1, 2, 3]

Vector(L);

Vector(3, {(1) = 1, (2) = 2, (3) = 3})


It's possible that the person who wrote the ?convert,Vector Help page overlooked the fact that no single orientation satisfies that act of passing some structures straight to the constructor; ie. it varies by nature of the argument. It's even reasonable that someone might deem the appropriate fix to be to amend that documentation and retain the current behavior.

Having said that, I usually prefer do that kind of thing like,

    Vector[column](A);

I also convert-to-Matrix in a similar manner. Those constructor calls preserve datatype which is often quite important to me, and also storage=sparse (which, while much rarer for me, is something I'd often prefer my code respect by default unless I was deliberately coding to clobber it).

For example, if I had a list L I'd convert it to a Vector with,
    Vector(L)
rather than,
    convert(L,Vector)
which is both longer as well as (for my purposes, often) inferior. Similarly I'd handle a listlist LL with,
    Matrix(LL)
rather than,
    convert(LL,Matrix)

nb. In other words, I'd prefer to call the constructor directly, rather than write out a convert call which is more verbose while getting to the same act. I see less merit in calling convert in many such situations.

This was reported by someone else a little while ago, also for Maple 2025.

You might need to wait for the 2025.1 point-release, to get a GUI-update that fixes this.

(I do not believe that this can be fixed by a pure Library-side change, eg. in SupportTools).

That's the way it is, for 3D plots.

For 3D plots, the GUI places the largest "square" inside the inline plot window (the thing that has resizable borders, when you place the mouse focus on the plot). The `size` option only specifies the dimensions of the inlined plot window, and has no effect on the aspect ratios between the three extents of the displayed axes. I believe that the design intention is to allow the full plot to remain fully visible upon any manual rotation angles.

It is possible to use the DocumentTools package to embed an inline plot with the zoom factor programmatically specified. This can give the effect of stretching (only) horizontally, without the wasted white space above and below. If you look at the InlinePlot call in the very last example here ( Help Topic ?DocumentTools,Components,Plot ) then you can see such a programmatic zooming effect in which a long, short 3D thing is plotted without wasted vertical white space. (The effect is better see if you run the example in your Maple; the online Help page's rendering muddies the effect.)

The idea here is that the size option forces a long&short inlined plotting window, and then the rendered 3D plot seen through that window is forcibly zoomed in. That's the only way I know, to get such an effect programmatically at present. Another example, here.

Let us know, with an actual example, if you have trouble getting that effect to work for you. nb. I also don't know whether the effect maintains properly, on Close & Reopen of the sheet.

I've wanted 3D axes aspect ratios, as programmatic options, for some time now. But, in their absence, you're left with the choice of either unconstrained scaling (ie. all-equal aspect ratios) or a poor man's (still not fully satisfactory) effect if you manually rescale all your plot data/functions to mimic the desired aspect ratio.

The OP has encountered a common usage difficulty for users new to Maple.

In summary,
i) Using unevaluation quotes to delay the evaluation of the first argument works here, but is not the best general solution. Yes, it works for this example. But I've seen this usage devolve into even murkier difficulties far too often.
ii) Using irem vs modp happens to work for this example (and can have better efficiency) but is not by itself the best general solution because many similar difficulties arise for problems having nothing to do with modp/irem.
iii) The add command is more appropriate that sum here. It's specifically designed to better and more more generally handle this kind of issue. Yes, it's unfortunate that the 2D Input Sigma symbol is hooked into sum rather than add. But the allure of the typeset Sigma notation doesn't generally make up for the shortfalls of using sum in such situations.
iv) Similar distinctions can arise with product vs mul.

Altogether,
    add(irem(5, mul(2, t = 0 .. irem(q - 1, 3))), q = 1 .. 2)

And now, for some details,

restart;

sum(modp(5, product(2, t = 0 .. modp(q - 1, 3))), q = 1 .. 2);

10

The following is being evaluated, in the sum call, before q gets
any actual numeric value.

This call is being prematurely evaluated.

modp(5, product(2, t = 0 .. modp(q - 1, 3)));
eval(%,q=1)+eval(%,q=2);

modp(5, 2^(q+3))

10

One alternative is to delay the evaluation of the first
argument to the sum call, using single right-ticks
(a.k.a. unevaluation quotes)

sum('modp(5, product(2, t = 0 .. modp(q - 1, 3)))', q = 1 .. 2);

2

You can also get by with this, for this example,

sum(modp(5, 'product(2, t = 0 .. modp(q - 1, 3))'), q = 1 .. 2);

2

Hence you can also get by with the following.
nb. This is not as general a workaround, since not all sum evaluation
problems involve the tasks of modp or irem.

sum(irem(5, product(2, t = 0 .. irem(q - 1, 3))), q = 1 .. 2);

2

The previous example worked because the following happens
to return unevaluated for unknown q.

irem(5, product(2, t = 0 .. irem(q - 1, 3)))

irem(5, 2^(irem(q-1, 3)+1))

A generally better approach here is to use the add command instead of
the sum command.

The add command has so-called special evaluation rules, which
delays the evaluation of is first argument until the summation
index q gets some actual numeric values.

add(modp(5, product(2, t = 0 .. modp(q - 1, 3))), q = 1 .. 2);

2

You can also do the following: use add instead of sum, mul instead of
product (for the same reasons), and irem for suitability to this
particular computation (as well as efficiency).

add(irem(5, mul(2, t = 0 .. irem(q - 1, 3))), q = 1 .. 2);

2

Download sum_add_eval.mw

This is a common issue for new Maple users. There are lots of examples of this kind of problem on this forum.

There are also several Help Pages devoted specifically to the issue: eg,
1) special evaluation rules
2) sum vs add

Does this work for you? (Check that it makes good sense. It's late in the day...)

restart;

ode := y(x)*diff(y(x),x)-y(x)=A*x+B;

y(x)*(diff(y(x), x))-y(x) = A*x+B

book_sol := y(x)=_C1*t*exp( - Int( t/(t^2-t-A),t));

y(x) = _C1*t*exp(-(Int(t/(t^2-A-t), t)))

eq := x=_C1*exp(  - Int( t/(t^2-t-A),t))-B/A;

x = _C1*exp(-(Int(t/(t^2-A-t), t)))-B/A

new := t=RootOf(subs(t=_Z,rhs(eq))-x,_Z);

t = RootOf(_C1*exp(-(Int(-_Z/(-_Z^2+A+_Z), _Z)))*A-A*x-B)

eval(book_sol,new);

y(x) = _C1*RootOf(_C1*exp(-(Int(-_Z/(-_Z^2+A+_Z), _Z)))*A-A*x-B)*exp(-Intat(_a/(_a^2-A-_a), _a = RootOf(_C1*exp(-(Int(-_Z/(-_Z^2+A+_Z), _Z)))*A-A*x-B)))

odetest(eval(book_sol,new), ode);

0

alt := simplify(eval(book_sol,new));

y(x) = RootOf(c__1*exp(Int(_Z/(-_Z^2+A+_Z), _Z))*A-A*x-B)*(A*x+B)/A

odetest(alt, ode);

0


Download how_to_verify_parametric_solution_to_ode_ac.mw

You have defined the substitution equation T1 as,

   T1 := u(x, t) = U(-t*v + x)*exp(k(t*w + x)*I)

where you are missing a multiplication symbol between the k and the opening bracket. That gives you a function call k(t*w + x) , ie. a call to unknown function k. When you then substitute into the derivative wrt t the chain rule applies, and you get D(k)(...) terms.

You may have intended, instead,

   T1 := u(x, t) = U(-t*v + x)*exp(k*(t*w + x)*I)

restart

with(PDEtools)

undeclare(prime, quiet)

declare(u(x, t), quiet); declare(U(xi), quiet); declare(V(xi), quiet)

pde := I*(diff(u(x, t), `$`(t, 2))-s^2*(diff(u(x, t), `$`(x, 2))))+(1/24)*c[1]*(diff(u(x, t), t, `$`(x, 4)))-alpha*s*c[1]*(diff(u(x, t), `$`(x, 5)))+diff(c[2]*u(x, t)*U(-t*v+x)^2+c[3]*u(x, t)*U(-t*v+x)^4+c[4]*u(x, t)*(diff(U(-t*v+x)^2, `$`(x, 2))), t)-beta*s*(diff(u(x, t), `$`(x, 5)))+diff(c[2]*u(x, t)*U(-t*v+x)^2+c[3]*u(x, t)*U(-t*v+x)^4+c[4]*u(x, t)*(diff(U(-t*v+x)^2, `$`(x, 2))), x)

G1 := U(-t*v+x) = U(xi); G2 := (D(U))(-t*v+x) = diff(U(xi), xi); G3 := ((D@@2)(U))(-t*v+x) = diff(U(xi), `$`(xi, 2)); G4 := ((D@@3)(U))(-t*v+x) = diff(U(xi), `$`(xi, 3)); G5 := ((D@@4)(U))(-t*v+x) = diff(U(xi), `$`(xi, 4)); G6 := ((D@@5)(U))(-t*v+x) = diff(U(xi), `$`(xi, 5))

T := xi = -t*v+x; T1 := u(x, t) = U(-t*v+x)*exp(I*k*(t*w+x))

u(x, t) = U(-t*v+x)*exp(I*k*(t*w+x))

P1 := I*(diff(u(x, t), `$`(t, 2))-s^2*(diff(u(x, t), `$`(x, 2))))+(1/24)*c[1]*(diff(u(x, t), t, `$`(x, 4)))-alpha*s*c[1]*(diff(u(x, t), `$`(x, 5)))+diff(c[2]*u(x, t)*U(-t*v+x)^2+c[3]*u(x, t)*U(-t*v+x)^4+c[4]*u(x, t)*(diff(U(-t*v+x)^2, `$`(x, 2))), t)-beta*s*(diff(u(x, t), `$`(x, 5)))+diff(c[2]*u(x, t)*U(-t*v+x)^2+c[3]*u(x, t)*U(-t*v+x)^4+c[4]*u(x, t)*(diff(U(-t*v+x)^2, `$`(x, 2))), x)

P11 := eval(P1, {T, T1})

P111 := subs({G1, G2, G3, G4, G5, G6}, P11)

pde1 := P111 = 0

numer(lhs(pde1))*denom(rhs(pde1)) = numer(rhs(pde1))*denom(lhs(pde1))

%/(-exp(I*k(t*w+x)))

exp(I*k*(t*w+x))*(-48*(diff(U(xi), xi))*k*s^2-120*c[3]*U(xi)^4*(diff(U(xi), xi))+48*(diff(U(xi), xi))^3*v*c[4]-72*c[2]*U(xi)^2*(diff(U(xi), xi))-48*U(xi)^2*(diff(diff(diff(U(xi), xi), xi), xi))*c[4]+24*(diff(diff(diff(diff(diff(U(xi), xi), xi), xi), xi), xi))*beta*s+(diff(diff(diff(diff(diff(U(xi), xi), xi), xi), xi), xi))*v*c[1]+(24*I)*(diff(diff(U(xi), xi), xi))*s^2-(24*I)*(diff(diff(U(xi), xi), xi))*v^2-240*(diff(diff(diff(U(xi), xi), xi), xi))*alpha*k^2*s*c[1]+192*(diff(diff(U(xi), xi), xi))*(diff(U(xi), xi))*U(xi)*v*c[4]-(24*I)*U(xi)^5*k*w*c[3]+(24*I)*U(xi)*beta*k^5*s-I*U(xi)*k^5*w*c[1]-(240*I)*(diff(diff(U(xi), xi), xi))*beta*k^3*s-(4*I)*(diff(diff(U(xi), xi), xi))*k^3*v*c[1]+(6*I)*(diff(diff(U(xi), xi), xi))*k^3*w*c[1]-(24*I)*U(xi)^3*k*w*c[2]-(48*I)*(diff(diff(U(xi), xi), xi))*U(xi)^2*k*c[4]-(48*I)*(diff(U(xi), xi))^2*U(xi)*k*c[4]+(120*I)*(diff(diff(diff(diff(U(xi), xi), xi), xi), xi))*beta*k*s+(4*I)*(diff(diff(diff(diff(U(xi), xi), xi), xi), xi))*k*v*c[1]-I*(diff(diff(diff(diff(U(xi), xi), xi), xi), xi))*k*w*c[1]-48*(diff(U(xi), xi))^3*c[4]+120*(diff(U(xi), xi))*alpha*k^4*s*c[1]+120*c[3]*U(xi)^4*(diff(U(xi), xi))*v+120*(diff(U(xi), xi))*beta*k^4*s+(diff(U(xi), xi))*k^4*v*c[1]-4*(diff(U(xi), xi))*k^4*w*c[1]-48*(diff(U(xi), xi))*k*v*w+72*c[2]*U(xi)^2*(diff(U(xi), xi))*v+48*U(xi)^2*(diff(diff(diff(U(xi), xi), xi), xi))*v*c[4]-240*(diff(diff(diff(U(xi), xi), xi), xi))*beta*k^2*s-6*(diff(diff(diff(U(xi), xi), xi), xi))*k^2*v*c[1]+4*(diff(diff(diff(U(xi), xi), xi), xi))*k^2*w*c[1]-192*(diff(diff(U(xi), xi), xi))*(diff(U(xi), xi))*U(xi)*c[4]+24*(diff(diff(diff(diff(diff(U(xi), xi), xi), xi), xi), xi))*alpha*s*c[1]-(24*I)*U(xi)^5*k*c[3]-(24*I)*U(xi)^3*k*c[2]-(24*I)*U(xi)*k^2*s^2+(24*I)*U(xi)*k^2*w^2+(24*I)*U(xi)*alpha*k^5*s*c[1]-(240*I)*(diff(diff(U(xi), xi), xi))*alpha*k^3*s*c[1]-(48*I)*(diff(diff(U(xi), xi), xi))*U(xi)^2*k*w*c[4]-(48*I)*(diff(U(xi), xi))^2*U(xi)*k*w*c[4]+(120*I)*(diff(diff(diff(diff(U(xi), xi), xi), xi), xi))*alpha*k*s*c[1])/exp(I*k(t*w+x)) = 0


Download tr_ac.mw

Is this something like you what you're after, without the fractions? (Below are two ways, for this example)

restart

with(PDEtools)

undeclare(prime, quiet)

declare(u(x, t), quiet); declare(U(xi), quiet); declare(V(xi), quiet)

RR := (2*v*(1/3)+2*alpha*beta*(1/3))*U(xi)^3+(-3*alpha*k^2*lambda-4*alpha^2*k-k^2*v+2*k^2*w-4*k*v*w)*U(xi)+(alpha*lambda+v)*(diff(diff(U(xi), xi), xi)) = 0

IM := -2*(diff(diff(U(xi), xi), xi))*v*k-2*U(xi)*k^2*w^2-2*(diff(diff(U(xi), xi), xi))*alpha^2+2*(diff(diff(U(xi), xi), xi))*v^2+(diff(diff(U(xi), xi), xi))*k*w+2*U(xi)^3*k*w-2*U(xi)^3*alpha*beta*k-3*(diff(diff(U(xi), xi), xi))*alpha*k*lambda-U(xi)*k^3*w+2*U(xi)*alpha^2*k^2+U(xi)*alpha*k^3*lambda = 0

collect(%, {U(xi), diff(diff(U(xi), xi), xi)})

P := %

C1 := v = solve(2*v*(1/3)+2*alpha*beta*(1/3) = 0, v)

C2 := k = solve(-3*alpha*k^2*lambda-4*alpha^2*k-k^2*v+2*k^2*w-4*k*v*w = 0, k)

C22 := subs(C1, C2)

C222 := k = -(4*(-alpha*beta*w+alpha^2))/(-alpha*beta+3*alpha*lambda-2*w)

ode := subs({C1, C222}, P)

temp := numer(lhs(ode))*denom(rhs(ode)) = numer(rhs(ode))*denom(lhs(ode))

temp2 := simplify(temp)

temp3 := temp2/(-64*alpha)

PP := numer(lhs(temp3))*denom(rhs(temp3)) = numer(rhs(temp3))*denom(lhs(temp3))

expr := collect(PP, {U(xi), diff(U(xi), xi), diff(diff(U(xi), xi), xi)})

(-4*alpha^3*beta^4*w+24*alpha^3*beta^3*lambda*w-36*alpha^3*beta^2*lambda^2*w+4*alpha^4*beta^3-24*alpha^4*beta^2*lambda+36*alpha^4*beta*lambda^2-12*alpha^2*beta^3*w^2+24*alpha^2*beta^2*lambda*w^2+36*alpha^2*beta*lambda^2*w^2+12*alpha^3*beta^2*w-24*alpha^3*beta*lambda*w-36*alpha^3*lambda^2*w-48*alpha*beta*lambda*w^3+48*alpha^2*lambda*w^2+16*beta*w^4-16*alpha*w^3)*U(xi)^3+(32*alpha^3*beta^3*lambda*w^3-16*alpha^4*beta^3*w^2-48*alpha^4*beta^2*lambda*w^2-16*alpha^2*beta^3*w^4-48*alpha^2*beta^2*lambda*w^4+32*alpha^5*beta^2*w+32*alpha^3*beta^2*w^3+96*alpha^3*beta*lambda*w^3+32*alpha*beta^2*w^5-16*alpha^6*beta+16*alpha^6*lambda-16*alpha^4*beta*w^2-48*alpha^4*lambda*w^2-64*alpha^2*beta*w^4+32*alpha^3*w^3)*U(xi)+(-alpha^4*beta^5+9*alpha^4*beta^4*lambda-27*alpha^4*beta^3*lambda^2+27*alpha^4*beta^2*lambda^3-2*alpha^3*beta^4*w+6*alpha^3*beta^3*lambda*w+18*alpha^3*beta^2*lambda^2*w-54*alpha^3*beta*lambda^3*w-3*alpha^4*beta^3+21*alpha^4*beta^2*lambda-45*alpha^4*beta*lambda^2+27*alpha^4*lambda^3+6*alpha^2*beta^3*w^2-48*alpha^2*beta^2*lambda*w^2+90*alpha^2*beta*lambda^2*w^2-12*alpha^3*beta^2*w+48*alpha^3*beta*lambda*w-36*alpha^3*lambda^2*w+16*alpha*beta^2*w^3-48*alpha*beta*lambda*w^3-12*alpha^2*beta*w^2+12*alpha^2*lambda*w^2+8*beta*w^4)*(diff(diff(U(xi), xi), xi)) = 0

I suppose that you don't want the fractions in this result from simplify

ans0 := collect(PP, {U(xi), diff(U(xi), xi), diff(diff(U(xi), xi), xi)}, simplify)

16*(-alpha*beta+w)*((1/2)*(beta-3*lambda)*alpha+w)^2*(beta*w-alpha)*U(xi)^3+32*((1/2)*(-beta+lambda)*alpha^3+w*beta*alpha^2*lambda-(1/2)*w^2*(beta+3*lambda)*alpha+w^3)*alpha*(beta*w-alpha)^2*U(xi)+8*((1/2)*(-beta^3+3*beta^2*lambda-3*beta+3*lambda)*alpha^2+w*beta*(beta-3*lambda)*alpha+beta*w^2)*((1/2)*(beta-3*lambda)*alpha+w)^2*(diff(diff(U(xi), xi), xi)) = 0

alt1 := collect(PP, [U(xi), diff(U(xi), xi), diff(diff(U(xi), xi), xi)], factor)

4*(alpha*beta-w)*(alpha*beta-3*alpha*lambda+2*w)^2*(-beta*w+alpha)*U(xi)^3-16*(-2*alpha^2*beta*lambda*w+alpha^3*beta-alpha^3*lambda+alpha*beta*w^2+3*alpha*lambda*w^2-2*w^3)*alpha*(-beta*w+alpha)^2*U(xi)-(alpha^2*beta^3-3*alpha^2*beta^2*lambda-2*alpha*beta^2*w+6*alpha*beta*lambda*w+3*alpha^2*beta-3*alpha^2*lambda-2*beta*w^2)*(alpha*beta-3*alpha*lambda+2*w)^2*(diff(diff(U(xi), xi), xi)) = 0

simplify(PP-alt1)

0 = 0

alt2 := eval(collect(expr, [U(xi), diff(U(xi), xi), diff(diff(U(xi), xi), xi)], proc (u) options operator, arrow; subsindets(simplify(u), And(`+`, satisfies(proc (uu) options operator, arrow; type(denom(uu), {integer, `&*`(integer, specfunc(__K))}) end proc)), proc (uu) options operator, arrow; map(`*`, uu, denom(uu))/__K(denom(uu)) end proc) end proc), __K = (proc (u) options operator, arrow; u end proc))

4*(-alpha*beta+w)*((beta-3*lambda)*alpha+2*w)^2*(beta*w-alpha)*U(xi)^3+16*((-beta+lambda)*alpha^3+2*w*beta*alpha^2*lambda-w^2*(beta+3*lambda)*alpha+2*w^3)*alpha*(beta*w-alpha)^2*U(xi)+((-beta^3+3*beta^2*lambda-3*beta+3*lambda)*alpha^2+2*w*beta*(beta-3*lambda)*alpha+2*beta*w^2)*((beta-3*lambda)*alpha+2*w)^2*(diff(diff(U(xi), xi), xi)) = 0

simplify(PP-alt2)

0 = 0


Download B-R_ac.mw

> restart;
> kernelopts(version);
   Maple 2025.0, X86 64 LINUX, Mar 24 2025, Build ID 1909157

> A := -x*(x - 4*exp(x/2) + 2):
> B := x*sqrt((-8*x - 16)*exp(x/2) + x^2 + 4*x + 16*exp(x) + 4):

> simplify(simplify(A-B, {exp(x)=exp(x/2)^2})) assuming x::real;

                    0
2 3 4 5 6 7 8 Last Page 4 of 336