acer

32303 Reputation

29 Badges

19 years, 307 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

A few examples,

restart;

assume(k, integer);

sin(k*Pi);

0

restart;

sin(k*Pi) assuming k::integer;

0

expr1 := sin(k*Pi);

sin(k*Pi)

expr1 assuming k::integer;

0

expr2 := sin(k*Pi + x);

sin(Pi*k+x)

simplify(expr2) assuming k::integer;

sin(x)*(-1)^k

# Since we did not use `assume` we can
# still manipulate this expression without
# the assumption having an effect.

expand(expr2);

sin(k*Pi)*cos(x)+cos(k*Pi)*sin(x)

expand(expr2) assuming k::integer;

sin(x)*(-1)^k

Download basic_assumptions.mw

It's difficult to know what exactly you are now doing. I could make a wild guess, and so maybe it's something like the following (ie. maybe you're no longer using such an F). Guessing isn't a productive way to proceed here.

restart

randomize()

M := [seq(RandomTools:-GenerateSimilar(x-y = 0), 1 .. 6)]

L := [seq(S[i], i = 1 .. 6)]

Sol := map(proc (sys) options operator, arrow; solve(sys, {x, y}) end proc, M)

DocumentTools:-InsertContent(DocumentTools:-Layout:-Worksheet(subs("centred" = "left", DocumentTools:-Tabulate(Matrix(3, 2, proc (i, j) options operator, arrow; `≡`(L[2*i-2+j], M[2*i-2+j]) end proc), width = 100, alignment = center, color = blue, fillcolor = "AliceBlue", output = XML, exterior = none))))

 

`≡`(S[1], x-y-1 = 0)

`≡`(S[2], 2*x-2*y-2 = 0)

`≡`(S[3], 2*x+2*y+2 = 0)

`≡`(S[4], x+y-1 = 0)

`≡`(S[5], -x+y+1 = 0)

`≡`(S[6], -x+2*y-1 = 0)

 

F := proc (L::{equation, ({list, set})(equation)}) local i; nprintf(`#%a;`, subs("\`\`" = "", convert(eval(('Typesetting:-Typeset')(L)), `global`))) end proc

DocumentTools:-InsertContent(DocumentTools:-Layout:-Worksheet(subs("centred" = "left", DocumentTools:-Tabulate(Matrix(3, 2, proc (i, j) options operator, arrow; `≡`(L[2*i-2+j], F(M[2*i-2+j])) end proc), width = 100, alignment = center, color = blue, fillcolor = "AliceBlue", output = XML, exterior = none))))

 

`≡`(S[1], `#mrow(mi("x",mathcolor = "blue"),mo("−",mathcolor = "blue"),mi("y",mathcolor = "blue"),mo("−",mathcolor = "blue"),mn("1",mathcolor = "blue"),mo("=",mathcolor = "blue"),mn("0",mathcolor = "blue"))`)

`≡`(S[2], `#mrow(mn("2",mathcolor = "blue"),mo("⁢"),mi("x",mathcolor = "blue"),mo("−",mathcolor = "blue"),mn("2",mathcolor = "blue"),mo("⁢"),mi("y",mathcolor = "blue"),mo("−",mathcolor = "blue"),mn("2",mathcolor = "blue"),mo("=",mathcolor = "blue"),mn("0",mathcolor = "blue"))`)

`≡`(S[3], `#mrow(mn("2",mathcolor = "blue"),mo("⁢"),mi("x",mathcolor = "blue"),mo("+",mathcolor = "blue"),mn("2",mathcolor = "blue"),mo("⁢"),mi("y",mathcolor = "blue"),mo("+",mathcolor = "blue"),mn("2",mathcolor = "blue"),mo("=",mathcolor = "blue"),mn("0",mathcolor = "blue"))`)

`≡`(S[4], `#mrow(mi("x",mathcolor = "blue"),mo("+",mathcolor = "blue"),mi("y",mathcolor = "blue"),mo("−",mathcolor = "blue"),mn("1",mathcolor = "blue"),mo("=",mathcolor = "blue"),mn("0",mathcolor = "blue"))`)

`≡`(S[5], `#mrow(mo("&uminus0;",mathcolor = "blue"),mi("x",mathcolor = "blue"),mo("+",mathcolor = "blue"),mi("y",mathcolor = "blue"),mo("+",mathcolor = "blue"),mn("1",mathcolor = "blue"),mo("=",mathcolor = "blue"),mn("0",mathcolor = "blue"))`)

`≡`(S[6], `#mrow(mo("&uminus0;",mathcolor = "blue"),mi("x",mathcolor = "blue"),mo("+",mathcolor = "blue"),mn("2",mathcolor = "blue"),mo("⁢"),mi("y",mathcolor = "blue"),mo("−",mathcolor = "blue"),mn("1",mathcolor = "blue"),mo("=",mathcolor = "blue"),mn("0",mathcolor = "blue"))`)

 
 

S4_Generate_Systmes_ac.mw

Your evalf calls don't use enough working precision, and the floating-point evaluation is inaccurate.

It's faster and easier (and more accurate at default working precision) to do purely floating-point integration here. (Note the use of inert Int, where evalf(Int(...)) does purely floating-point integration.)

Or you could call evalf[n], to use higher working precision when evalf'ing your large exact expression. (But you have to find n large enough...)

Is there some special reason that you need that large and unwieldy exact symbolic integration result?

restart

kernelopts(version)

`Maple 2023.2, X86 64 LINUX, Nov 24 2023, Build ID 1762575`

with(Statistics)

f := -t*piecewise(t <= 0, 0, t <= 1, t*(t^3+6*Pi*t-8*t^2-4*Pi), t <= sqrt(2), -(2*(4*t^2*sqrt(t^2-1)*arcsin((t^2-2)/t^2)+4*t^2*arctan(sqrt(t^2-1))*sqrt(t^2-1)+(t^4+(2*Pi+3)*t^2-4*t*Pi+3*Pi-1/2)*sqrt(t^2-1)-8*t^4+4*t^2+4))/sqrt(t^2-1), t <= sqrt(3), (8*arctan((t^3+t^2-3*t-1)/(sqrt(t^2-2)*(t^3-t^2-t-1)))*t*sqrt(t^2-2)-4*arccot((t^2-t-1)/sqrt(t^2-2))*t^2*sqrt(t^2-2)+4*t*sqrt(t^2-2)*(t+2)*arctan((t^2+t-1)/sqrt(t^2-2))+(8*t^2-4)*sqrt(t^2-2)*arcsin((t^2-3)/(t^2-1))+16*arcsin(sqrt(t^2-2)/sqrt(t^2-1))*sqrt(t^2-2)-16*arcsin(1/sqrt(t^2-1))*sqrt(t^2-2)+((t^2+5)*sqrt(t^2-2)-8*t^2+16)*(t^2+1))/sqrt(t^2-2), sqrt(3) < t, 0)

evE := simplify(int(t*f, t = 0 .. sqrt(3)))

(1/105)*(294*(-2+3^(1/2))*(2^(1/2)-3/2)*ln(1+2^(1/2))+168*(-2+3^(1/2))*(2^(1/2)-3/2)*ln(1+3^(1/2))-252*(-2+3^(1/2))*(2^(1/2)-3/2)*arccoth(2^(1/2))+((-14*Pi-84*ln(2)-19)*3^(1/2)+28*Pi+168*ln(2)+50)*2^(1/2)+(21*Pi+126*ln(2)+20)*3^(1/2)-42*Pi-252*ln(2)-58)/((2*2^(1/2)-3)*(-2+3^(1/2)))

forget(evalf); evalf(evE); forget(evalf); evalf[10](evalf[20](evE))

.6617071838

.6617071823

evalf(Int(t*f, t = 0 .. sqrt(3)))

.6617071823

stdE := simplify(sqrt(int(f*(t-evE)^2, t = 0 .. sqrt(3))))

forget(evalf); evalf(stdE); forget(evalf); evalf[10](evalf[35](stdE))

7031348.295

.2492861908

evalf(sqrt(Int(f*(t-evE)^2, t = 0 .. sqrt(3))))

.2492861908

 

 

Download StdE_ac.mw

NB. Using default Digits=10 or evalf[10] is not a guarantee of getting 10 correct digits in a float result, when obtaining a float approximation of a compound exact symbolic expression. It's not a specification of requested final accuracy. Rather, it makes Maple use 10 digits of working precision for individual floating-point operations. For a compound symbolic expression, numeric error (round-off, loss of precision) can accrue.

ps. The construction,
   evalf[10](evalf[40]( ... ))
does the inner computation with Digits=40, and then applies Digits=10 to the inner result. So that initially uses Digits=40, and then rounds a float result to 10 places.

And the forget(evalf) is to clear evalf's remember table, so that my explanation is not muddied if you try and repeat the coarser computation after having computed the more accurate one.

You can get decent instruction from Student:-Calculus1:-ShowSolution, example at the end of attachment. That is, you might not want to reinvent that functionality from scratch...

But, for fun, here are also a few variants on your requestion (some along the lines of ftoc),

restart

Parse:-ConvertTo1D, "`%1` is not a module or member", InertForm
NULL

trieq(x^2, x = 0 .. a)

"(&int;)[0]^af(x) &DifferentialD;x=(&int;)[0]^ax^2 &DifferentialD;x=
(a^3)/3"

trieq(sin(s), s = 0 .. a)

"(&int;)[0]^af(s) &DifferentialD;s=(&int;)[0]^asin(s) &DifferentialD;s=
1-cos(a)"

Parse:-ConvertTo1D, "`%1` is not a module or member", InertForm
``

trieq2(x^2, x = 0 .. a)

Int(f(x), x = 0 .. a) = Int(x^2, x = 0 .. a) and Int(x^2, x = 0 .. a) = `
`(Limit((1/3)*x^3, x = a))-(Limit((1/3)*x^3, x = 0)) and `
`(Limit((1/3)*x^3, x = a))-(Limit((1/3)*x^3, x = 0)) = (1/3)*a^3

trieq2(sin(s), s = 0 .. a)

"(&int;)[0]^af(s) &DifferentialD;s=(&int;)[0]^asin(s) &DifferentialD;s=
(lim)(-cos(s))-((lim)(-cos(s)))=1-cos(a)"

Parse:-ConvertTo1D, "`%1` is not a module or member", InertForm

trieq3(x^2, x = 0 .. a)

Int(f(x), x = 0 .. a) = Int(x^2, x = 0 .. a) and Int(x^2, x = 0 .. a) = Limit((1/3)*x^3, x = a)-(Limit((1/3)*x^3, x = 0)) and Limit((1/3)*x^3, x = a)-(Limit((1/3)*x^3, x = 0)) = (1/3)*a^3

Student:-Calculus1:-ShowSolution(Int(x^2, x = a .. b))

"[[,,"Integration Steps"],[,,(&int;)[a]^bx^2 &DifferentialD;x],["&EmptyVerySmallSquare;",,"1. Apply the" "power" "rule to the term" &int;x^2 &DifferentialD;x],[,"?","Recall the definition of the" "power" "rule, for n" "<>" "-1"],[,,&int;x^[] &DifferentialD;x=[]],[,"?","This means:"],[,,&int;x^2 &DifferentialD;x=[]],[,"?","So,"],[,,&int;x^2 &DifferentialD;x=(x^3)/3],[,"?","Apply limits of definite integral"],[,,[]-([])],[,,"We can rewrite the integral as:"],[,,(b^3)/3-(a^3)/3]]6""

NULL

Download 5.3-Definite-Integral_ac.mw

It seems that a nice compact answer can be had for your Case (i).

restart

interface(showassumed = 0)

assume(x::real); assume(t::real); assume(lambda1::complex); assume(lambda2::complex); assume(a::real); assume(A__c::real); assume(B1::real); assume(B2::real); assume(delta1::real); assume(delta2::real); assume(`&omega;__0`::real); assume(g::real); assume(l__0::real)

expr := A__c*exp(-(2*I)*(A__c^2*g*l__0^2-1/2)*`&omega;__0`*t)+(2*I)*exp(-I*(A__c^2*g*l__0^2-1/2)*`&omega;__0`*t)*(sqrt(delta1+I*delta2-sqrt(-A__c^2*g+(delta1+I*delta2)^2))*exp(-2*sqrt(-A__c^2*g+(delta1+I*delta2)^2)*(l__0^2*(I*delta1-delta2)*t*`&omega;__0`+(1/2)*x))-sqrt(delta1+I*delta2+sqrt(-A__c^2*g+(delta1+I*delta2)^2))*exp(sqrt(-A__c^2*g+(delta1+I*delta2)^2)*(x+(2*I)*`&omega;__0`*l__0^2*(delta1+I*delta2)*t)))*(sqrt(-delta1+I*delta2-sqrt(-A__c^2*g+(delta1-I*delta2)^2))*exp((2*(l__0^2*(I*delta1+delta2)*t*`&omega;__0`-(1/2)*x))*sqrt(-A__c^2*g+(delta1-I*delta2)^2))-sqrt(-delta1+I*delta2+sqrt(-A__c^2*g+(delta1-I*delta2)^2))*exp(-(2*(l__0^2*(I*delta1+delta2)*t*`&omega;__0`-(1/2)*x))*sqrt(-A__c^2*g+(delta1-I*delta2)^2)))*delta2/(exp(I*(A__c^2*g*l__0^2-1/2)*`&omega;__0`*t)*(((-sqrt(delta1+I*delta2-sqrt(-A__c^2*g+(delta1+I*delta2)^2))*sqrt(-delta1+I*delta2+sqrt(-A__c^2*g+(delta1-I*delta2)^2))-sqrt(delta1+I*delta2+sqrt(-A__c^2*g+(delta1+I*delta2)^2))*sqrt(-delta1+I*delta2-sqrt(-A__c^2*g+(delta1-I*delta2)^2)))*exp((2*(l__0^2*(I*delta1+delta2)*t*`&omega;__0`-(1/2)*x))*sqrt(-A__c^2*g+(delta1-I*delta2)^2))+exp(-(2*(l__0^2*(I*delta1+delta2)*t*`&omega;__0`-(1/2)*x))*sqrt(-A__c^2*g+(delta1-I*delta2)^2))*(sqrt(delta1+I*delta2-sqrt(-A__c^2*g+(delta1+I*delta2)^2))*sqrt(-delta1+I*delta2-sqrt(-A__c^2*g+(delta1-I*delta2)^2))+sqrt(-delta1+I*delta2+sqrt(-A__c^2*g+(delta1-I*delta2)^2))*sqrt(delta1+I*delta2+sqrt(-A__c^2*g+(delta1+I*delta2)^2))))*exp(-2*sqrt(-A__c^2*g+(delta1+I*delta2)^2)*(l__0^2*(I*delta1-delta2)*t*`&omega;__0`+(1/2)*x))+exp(sqrt(-A__c^2*g+(delta1+I*delta2)^2)*(x+(2*I)*`&omega;__0`*l__0^2*(delta1+I*delta2)*t))*((sqrt(delta1+I*delta2-sqrt(-A__c^2*g+(delta1+I*delta2)^2))*sqrt(-delta1+I*delta2-sqrt(-A__c^2*g+(delta1-I*delta2)^2))+sqrt(-delta1+I*delta2+sqrt(-A__c^2*g+(delta1-I*delta2)^2))*sqrt(delta1+I*delta2+sqrt(-A__c^2*g+(delta1+I*delta2)^2)))*exp((2*(l__0^2*(I*delta1+delta2)*t*`&omega;__0`-(1/2)*x))*sqrt(-A__c^2*g+(delta1-I*delta2)^2))-exp(-(2*(l__0^2*(I*delta1+delta2)*t*`&omega;__0`-(1/2)*x))*sqrt(-A__c^2*g+(delta1-I*delta2)^2))*(sqrt(delta1+I*delta2-sqrt(-A__c^2*g+(delta1+I*delta2)^2))*sqrt(-delta1+I*delta2+sqrt(-A__c^2*g+(delta1-I*delta2)^2))+sqrt(delta1+I*delta2+sqrt(-A__c^2*g+(delta1+I*delta2)^2))*sqrt(-delta1+I*delta2-sqrt(-A__c^2*g+(delta1-I*delta2)^2)))))*(-delta1+I*delta2)*(delta1+I*delta2))

simplify(combine(simplify(convert(combine(eval(expr,A__c=0)),trigh)))) assuming delta1>0:
simplify(convert(numer(%),exp))/factor(denom(%)):
ans1 := evalindets(%,`+`,u->collect(u,[t,omega__0,l__0]));

-I*exp((I+(4*I)*(delta1^2-delta2^2)*l__0^2)*omega__0*t+(2*I)*delta2*x)*delta2/(cosh(2*delta1*(4*delta2*l__0^2*t*omega__0-x))*(delta1^2+delta2^2))

simplify(eval(expr,A__c=0)-ans1) assuming delta1>0;

0

NULL

Download simplify_Ahmed1_ac1.mw

There are shorter codes which produce results not so terse. (Yet, even above, it'd be nicer to factor the I in the exp call's argument.)

You can, naturally, also turn that simplified result's solitary exp call into trigh form. But that just doubles its size...

evalindets(simplify(evalc(ans1)),`+`,u->collect(u,[t,omega__0,l__0]));

-delta2*(I*cos((1+(4*delta1^2-4*delta2^2)*l__0^2)*omega__0*t+2*delta2*x)-sin((1+(4*delta1^2-4*delta2^2)*l__0^2)*omega__0*t+2*delta2*x))/(cosh(8*(l__0^2*delta2*t*omega__0-(1/4)*x)*delta1)*(delta1^2+delta2^2))

NULL

For the other cases it may require more effort to find a near-optimally-compacted form.

The equivalence of entries is -- as far as the union command goes -- by memory address. That is to say, it's a Maple structural comparison rather than a purely mathematical comparison. This is mentioned in a note on the Help-page of the union command.

In practice that is mostly quite useful, since stored numbers and general algebraic expressions share both equivalences.

But for some objects they are not the same. That goes for mutable data structures such as Vectors/Matrices/Arrays. Two Matrices which have the very same entries may appear the same, but they are distinct objects.

Let's suppose that the Matrices are returned to you by some commands or program.

One way to deal with this is the use a facility like the EqualEntries command, to test equivalence and remove "duplicates" manually. That can get awkward if there are many elements in the collections, or if you have to do it repeatedly.  You might prefer not to have to fix up (after the fact) the set that results from any usual `union` attempt involving Matrices/Vectors.

On the other hand, both lists and lists-of-lists that have identical entries are uniquified and stored just once in memory. (The apparent mutability of short lists is merely a convenient veil.) A pair of lists with identical entries always both point at the same uniquified list stored in memory. 

So another way to approach this is to work with sets of lists-of-lists rather than Matrices. You can programmatically add them to a look-up table, to help with repeated access.

You could simply do the relevant work by then working with lists only. Or you could switch back and forth in a more programmatic manner -- an example of which I outline below.

In the following, the Matrices are "registered" via conversion to listlist. Naturally, if you change the values of any entries in the Matrices after registering them then the comparison becomes invalid.

restart;


A couple of reusable procedures.

`&Union` := proc(a::set(Matrix),b::set(Matrix))
  map(u->:-T[u],map(u->:-T[u],a) union map(u->:-T[u],b));
end proc:
T := table([]):
R := proc(r::Matrix) local rl := convert(r,listlist);
  :-T[r],:-T[rl] := rl,r; return NULL;
end proc:

 

A := Matrix([1]);

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

AA := Matrix([7]);

Vector(1, {(1) = 7})

B := Matrix([1]);

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

 

R(A); R(B); R(AA); # register them

 

{A} &Union {B};

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

{A,AA} &Union {B};

{Vector(1, {(1) = 1}), Vector(1, {(1) = 7})}

{A,AA} &Union {B,AA};

{Vector(1, {(1) = 1}), Vector(1, {(1) = 7})}
 

{A,B,AA}; # can even use it to "correct" this
{} &Union %;

{Vector(1, {(1) = 1}), Vector(1, {(1) = 7})}

{Matrix(%id = 36893627939407872716), Matrix(%id = 36893627939407879572)}

Download set_listlist_Matrix.mw

There are other ways to program all that. I'd often rather a little more code at the start, if it makes the subsequent operations easier. I didn't put in guards to ensure that &Union were called ony with registered items, etc. I don't know whether this route is appealing for you.

Here are two ways.

There are more possible ways, but I don't know what set-up you want to hide, or whether you'd prefer right-click & context-menu versus more programmatic ways.

restart


First way, using right-click on the Sigma-summation-form input to toggle
"Evaluate and Display Inline", and then with focus on the output of that,

using context-panel "Apply a Command" to apply the command value.


Inert powering.

f := MakeFunction(InertForm:-MakeInert(i^2), i)

 

sum(f(i), i = 1 .. 5) = `%^`(1, 2)+`%^`(2, 2)+`%^`(3, 2)+`%^`(4, 2)+`%^`(5, 2)"->"55


Second way, display the three things in a multi-equation

A procedure for displaying three expressions, separated by `=` symbol.
Parse:-ConvertTo1D, "`%1` is not a module or member", InertForm


The three things. The first (the inert Sigma-summation form) is entered by
command-completion (Esc key, for me) on the typed 
input word Sum.

e1 := Sum(f(i), i = 1 .. 5); e2 := eval(e1, Sum = sum); e3 := value(e2)

 

trieq(e1, e2, e3)

Sum(`%^`(i, 2), i = 1 .. 5) = `%^`(1, 2)+`%^`(2, 2)+`%^`(3, 2)+`%^`(4, 2)+`%^`(5, 2) and `%^`(1, 2)+`%^`(2, 2)+`%^`(3, 2)+`%^`(4, 2)+`%^`(5, 2) = 55

NULL

Download ts_multi_sum_1.mw

nb. I originally had,
   f := i -> `%^`(i, 2)
for the inert powering. That's not too difficult, for this simple example. But I've now changed my worksheet to that the inert expression and the operator f are constructed in a more general purpose manner -- using MakeInert. That would be easier than having to type out all the prefix inert function calls, in a more involved example.

For the algebra (not the geometry),

restart;


Part 1)

E := z^2 - 2^alpha*exp(i*alpha)*(1 + 2*i)*z
     + i*2^(2*alpha + 1)*exp(i*2*alpha) = 0;

 

z^2-2^alpha*exp(i*alpha)*(1+2*i)*z+i*2^(2*alpha+1)*exp(2*i*alpha) = 0

1)
factor(expand(discrim(lhs(E), z)));

(2^alpha)^2*(exp(i*alpha))^2*(2*i-1)^2

1) again
simplify(discrim(lhs(E), z));

(2*i-1)^2*4^alpha*exp(2*i*alpha)

E := eval(E,i=I);

z^2+(-1-2*I)*2^alpha*exp(I*alpha)*z+I*2^(2*alpha+1)*exp((2*I)*alpha) = 0

2)
expand(E);
factor(%);
S := [solve(%,{z})];

z^2-2^alpha*exp(I*alpha)*z-(2*I)*2^alpha*exp(I*alpha)*z+(2*I)*(exp(I*alpha))^2*(2^alpha)^2 = 0

I*(exp(I*alpha)*2^alpha-z)*(I*z+2*exp(I*alpha)*2^alpha) = 0

[{z = exp(I*alpha)*2^alpha}, {z = (2*I)*exp(I*alpha)*2^alpha}]

3)
eval(z,S[1])/eval(z,S[2]);

-(1/2)*I


Part 2)

eq1 := 1/h =1/a+1/b;
eq2 :=b/a=lambda*I;

1/h = 1/a+1/b

b/a = I*lambda

1)
r1 := isolate(eq1,h);

h = a*b/(a+b)

a)
expr := h/(b-a):
expr = eval( expr, r1 );
lhs(%) = expand(simplify(rhs(%), {eq2}));

h/(b-a) = a*b/((a+b)*(b-a))

h/(b-a) = -I*lambda/(lambda^2+1)

c)
expr2 := (h-a)/(b-a):
expr2 = simplify(eval( expr2, r1 ));
lhs(%) = factor(simplify(rhs(%), {eq2}));

(h-a)/(b-a) = a^2/(a^2-b^2)

(h-a)/(b-a) = 1/(lambda^2+1)

Download jalal_cplx.mw

Perhaps you could simplify at each step, to reduce the burden.

(I wonder also whether there is a pattern; perhaps iteration is not necessary?)

restart

with(inttrans)

with(PDEtools)

with(DEtools)

with(Physics)

declare(u(x, t), quiet); declare(v(x, t), quiet); declare(U(x, t), quiet)

undeclare(prime)

`There is no more prime differentiation variable; all derivatives will be displayed as indexed functions`

``

pde0 := I*(Diff(U(x, t), t))+Diff(U(x, t), `$`(x, 2))+2*(Diff(U(x, t)*conjugate(U(x, t)), x))*U(x, t)+U(x, t)^2*conjugate(U(x, t))^2*U(x, t)

I*(Diff(U(x, t), t))+Diff(U(x, t), x, x)+2*(Diff(U(x, t)*conjugate(U(x, t)), x))*U(x, t)+U(x, t)^3*conjugate(U(x, t))^2

pde := expand(-I*pde0)

Diff(U(x, t), t)-I*(Diff(Diff(U(x, t), x), x))-(2*I)*U(x, t)*(Diff(U(x, t), x))*conjugate(U(x, t))-(2*I)*U(x, t)^2*(Diff(conjugate(U(x, t)), x))-I*U(x, t)^3*conjugate(U(x, t))^2

LLu := Diff(U(x, t), t); RRu := I*(Diff(U(x, t), x, x)); NNu := -pde+LLu-RRu

B[0] := -I*U[0](x, t)^3*conjugate(U[0](x, t))^2

B1[0] := -(2*I)*U[0](x, t)^2*(diff(U[0](x, t), x))

T[0] := -(2*I)*U[0](x, t)*(diff(U[0](x, t), x))*conjugate(U[0](x, t))

for n to 4 do B[n] := expand(-I*simplify(diff((sum(U[k](x, t)*lambda^k, k = 0 .. n))^3*(sum(conjugate(U[k](x, t))*lambda^k, k = 0 .. n))^2/factorial(n), [`$`(lambda, n)]))); B1[n] := expand(-(2*I)*simplify(diff((sum(U[k](x, t)*lambda^k, k = 0 .. n))^2*(sum((diff(U[k](x, t), x))*lambda^k, k = 0 .. n))/factorial(n), [`$`(lambda, n)]))); T[n] := expand(-(2*I)*simplify(diff((sum(U[k](x, t)*lambda^k, k = 0 .. n))*(sum(conjugate(U[k](x, t))*lambda^k, k = 0 .. n))*(sum((diff(U[k](x, t), x))*lambda^k, k = 0 .. n))/factorial(n), [`$`(lambda, n)]))) end do

lambda := 0; for n from 0 to 4 do P[n] := B[n]; Q[n] := B1[n]; R[n] := T[n] end do

for i from 0 to 4 do A[i] := P[i]+Q[i]+R[i] end do

``

# By writing this

Transformations := [ seq(seq(abs(U[i](x, t))^(2*n) = U[i](x, t)^n*(conjugate(U[i](x, t))^n), n=1..5), i=0..3) ]:

for i from 0 to 4 do
  Ad[i] := eval(A[i], Transformations)
end do:

for i from 0 to 6 do
    U[i](x, t) := u[i] assuming real;
end do:

u[0] := beta*exp(I*x)

beta*exp(I*x)

for i from 0 to 4 do u[i+1] := combine(simplify(evalc(invlaplace(laplace(I*(diff(u[i], `$`(x, 2)))+Ad[i], t, s)/s, s, t)))) end do

-(I*u[0]^5+beta*(I*cos(x)-sin(x)))*t

(1/2)*(-(4*I)*beta^8*sin(3*x)-(6*I)*beta^8*sin(5*x)+4*beta^8*cos(3*x)-6*beta^8*cos(5*x)-(25*I)*beta^4*sin(5*x)-(2*I)*beta^4*sin(x)-25*beta^4*cos(5*x)-2*beta^4*cos(x)-I*sin(x)-cos(x))*t^2*beta

-(1/6)*t^3*beta*(-(90*I)*cos(3*x)*beta^8+(36*I)*beta^12*cos(x)-(30*I)*beta^8*cos(x)-I*cos(x)-6*beta^12*sin(7*x)+18*beta^12*sin(9*x)+30*beta^12*sin(5*x)-36*sin(x)*beta^12-(375*I)*cos(5*x)*beta^8-(625*I)*cos(5*x)*beta^4-(18*I)*beta^12*cos(9*x)+375*beta^8*sin(5*x)+30*beta^8*sin(x)-90*beta^8*sin(3*x)-(30*I)*beta^12*cos(5*x)-(6*I)*beta^12*cos(7*x)+625*beta^4*sin(5*x)+5*beta^4*sin(x)-(5*I)*cos(x)*beta^4+sin(x))

-(1/24)*t^4*beta*(1824*beta^12*cos(3*x)-15625*beta^4*cos(5*x)+168*beta^16*cos(3*x)-24*beta^16*cos(13*x)-312*beta^16*cos(9*x)-72*beta^16*cos(7*x)-216*beta^16*cos(5*x)-3186*beta^12*cos(9*x)+234*beta^12*cos(7*x)+60*beta^12*cos(x)-4626*beta^12*cos(5*x)-146*beta^8*cos(x)-(312*I)*beta^16*sin(9*x)+(72*I)*beta^16*sin(7*x)-(216*I)*beta^16*sin(5*x)-(168*I)*beta^16*sin(3*x)-(1824*I)*beta^12*sin(3*x)-(3086*I)*sin(3*x)*beta^8-(9*I)*beta^4*sin(x)-(146*I)*beta^8*sin(x)-(16875*I)*beta^8*sin(5*x)-(234*I)*beta^12*sin(7*x)-(3186*I)*beta^12*sin(9*x)-(4626*I)*beta^12*sin(5*x)+(60*I)*beta^12*sin(x)-(24*I)*beta^16*sin(13*x)+(336*I)*sin(x)*beta^16-(15625*I)*beta^4*sin(5*x)+336*beta^16*cos(x)+3086*beta^8*cos(3*x)-16875*beta^8*cos(5*x)-9*beta^4*cos(x)-I*sin(x)-cos(x))

(1/120)*t^5*beta*(-(84156*I)*beta^8*cos(3*x)-(656250*I)*beta^8*cos(5*x)-(380496*I)*beta^12*cos(9*x)-(8808*I)*beta^16*cos(3*x)-(25278*I)*beta^16*cos(7*x)-(49950*I)*beta^16*cos(5*x)-(110922*I)*beta^16*cos(9*x)-(2880*I)*beta^20*cos(3*x)+1440*beta^20*sin(13*x)-2880*beta^20*sin(3*x)-1800*beta^20*sin(5*x)-3600*beta^20*sin(7*x)+8160*beta^20*sin(9*x)+480*beta^20*sin(11*x)-11640*sin(x)*beta^20-(8160*I)*beta^20*cos(9*x)-(3600*I)*beta^20*cos(7*x)+(1800*I)*beta^20*cos(5*x)+(480*I)*beta^20*cos(11*x)-(1440*I)*beta^20*cos(13*x)-(8316*I)*beta^16*cos(13*x)-(23824*I)*beta^12*cos(7*x)-(347755*I)*beta^12*cos(5*x)-(87644*I)*beta^12*cos(3*x)+(11640*I)*beta^20*cos(x)+(43836*I)*beta^16*cos(x)+(35470*I)*beta^12*cos(x)-(451*I)*beta^8*cos(x)-(14*I)*beta^4*cos(x)+8316*beta^16*sin(13*x)+110922*beta^16*sin(9*x)-25278*beta^16*sin(7*x)+49950*beta^16*sin(5*x)-8808*beta^16*sin(3*x)-87644*beta^12*sin(3*x)+390625*beta^4*sin(5*x)-23824*beta^12*sin(7*x)+380496*beta^12*sin(9*x)+347755*beta^12*sin(5*x)-35470*sin(x)*beta^12+451*beta^8*sin(x)-(390625*I)*beta^4*cos(5*x)-I*cos(x)-84156*beta^8*sin(3*x)+656250*beta^8*sin(5*x)+14*beta^4*sin(x)+sin(x)-43836*sin(x)*beta^16)

 

``

Download b1_ac.mw

Your attempt,

   pointplot3d(eval(polygon[[0, 0, 0], [x3e, y3e, z3e], [1, 0, 0]], t = 1/100*tt), color = pink)

is not valid syntax.

1) You've used square brackets, but polygon needs round brackets in the usual way for a function call.
2) The pointplot3d bit is wrong. (what did you expect it to do here?)
3) The eval usage is out of place.

It's not helpful to provide only a portion of your code. You could at least provide the obvious missing bits, such as x3e, y3e, z3e, tt, whether you loaded packages, etc. There's no reason not to upload and (at least) attach (insert link) your actual worksheet here.

Here's an example that might help. I've had to make some guesses.

restart;

with(plots): with(plottools):

x3e, y3e, z3e := sin(t), cos(t), sin(2*t):

tt := 300:

g1 := tt -> polygon(eval([[0, 0, 0], [x3e, y3e, z3e], [1, 0, 0]],
                         t = 1/100*tt), color = pink):

plots:-display(g1(1.0), size=[300,300], lightmodel=none);

 animate([g1], [t], t = 0 .. 314, frames = 25,
         size=[400,400], lightmodel=Light1);

Download polygon_ex.mw

Here's one way to get that.

nb. The outer (mapped) sort is to turn terms like z*y and y*x into y*z and x*y, etc.

L := [z^2, y*z, x*z, z, y^2, x*y, y, x^2, x, 1];

[z^2, y*z, x*z, z, y^2, x*y, y, x^2, x, 1]


The order of these terms agrees with that of your requested output.

[op(sort(`+`(op(L)), order=tdeg(z,y,x), ascending))];

[1, x, y, z, x^2, y*x, z*x, y^2, z*y, z^2]


A little polish, to turn z*y back into y*z, etc.

map(sort,
    [op(sort(`+`(op(L)), order=tdeg(z,y,x), ascending))],
    order=plex(x,y,z));

[1, x, y, z, x^2, x*y, x*z, y^2, y*z, z^2]

Download sort_lex_fun.mw

 

ps. You seemed to have an extra "x*x" term in your expected output. Perhaps it is a typo, since you had x^2 only once in both input and output. However, if you do indeed have the possibility of repeated terms then please let me know (as the addition trick wouldn't work directly; though it could be amended by removing/reinstating multiplicity fore&aft, or just by using the coefficient.)

I don't think that I'd do it all this way, but is the following the kind of thing that you're trying to do?

(I put in some redundancy, so you can check and compare. And I couldn't tell whether you wanted the mixed conjugate products to be turned into abs form.)

restart

with(PDEtools)

with(Physics)

declare(u(x, t), quiet); declare(v(x, t), quiet)


Either don't make this an equation (=0), or use just it's rhs when needed.
(Hasn't dharr mentioned this, more than once before?)

pde := u(x, t)+I*(diff(u(x, t), `$`(x, 2)))+2*(diff(u(x, t)*conjugate(u(x, t)), x))*u(x, t)+u(x, t)^2*conjugate(u(x, t))^2*u(x, t)

u(x, t)+I*(diff(diff(u(x, t), x), x))+(2*(diff(u(x, t), x))*conjugate(u(x, t))+2*u(x, t)*(diff(conjugate(u(x, t)), x)))*u(x, t)+u(x, t)^3*conjugate(u(x, t))^2

pde_linear, pde_nonlinear := selectremove(proc (term) options operator, arrow; not has((eval(term, u(x, t) = T*u(x, t)))/T, T) end proc, expand(pde))

u(x, t)+I*(diff(diff(u(x, t), x), x)), 2*u(x, t)*(diff(u(x, t), x))*conjugate(u(x, t))+2*u(x, t)^2*(diff(conjugate(u(x, t)), x))+u(x, t)^3*conjugate(u(x, t))^2

oppde := [op(expand(pde))]

[u(x, t), I*(diff(diff(u(x, t), x), x)), 2*u(x, t)*(diff(u(x, t), x))*conjugate(u(x, t)), 2*u(x, t)^2*(diff(conjugate(u(x, t)), x)), u(x, t)^3*conjugate(u(x, t))^2]


It doesn't make sense to consider (in your way) the operands of each
entry in oppde unless the entry is a product. The code needed to protect
against the case that some addend in the pde might not be itself a product.
It was not robust; not guarding against that.


Also, your approach seems designed for a pde in the form of a sum of terms,
so expanding the products of sums seems key to it working as designed.

u_occurrences := map(proc (i) options operator, arrow; numelems(select(has, [ifelse(i::`*`, op(i), i)], u)) end proc, oppde)

[1, 1, 3, 2, 2]

linear_op_indices := [ListTools:-SearchAll(1, u_occurrences)]

[1, 2]

pde_linear := add(oppde[linear_op_indices])

u(x, t)+I*(diff(diff(u(x, t), x), x))

nonlinear_op_indices := [seq(ifelse(u_occurrences[j] > 1, j, NULL), j = 1 .. nops(u_occurrences))]

[3, 4, 5]

pde_nonlinear := add(oppde[nonlinear_op_indices])

2*u(x, t)*(diff(u(x, t), x))*conjugate(u(x, t))+2*u(x, t)^2*(diff(conjugate(u(x, t)), x))+u(x, t)^3*conjugate(u(x, t))^2

pde_nonlinear := expand(pde-pde_linear)

2*u(x, t)*(diff(u(x, t), x))*conjugate(u(x, t))+2*u(x, t)^2*(diff(conjugate(u(x, t)), x))+u(x, t)^3*conjugate(u(x, t))^2

simplify(pde-pde_linear); r1 := expand(%)

u(x, t)*(abs(u(x, t))^4+2*(diff(u(x, t), x))*conjugate(u(x, t))+2*u(x, t)*(diff(conjugate(u(x, t)), x)))

u(x, t)*abs(u(x, t))^4+2*u(x, t)*(diff(u(x, t), x))*conjugate(u(x, t))+2*u(x, t)^2*(diff(conjugate(u(x, t)), x))

simplify(pde-pde_linear, size); r2 := expand(%)

u(x, t)*(u(x, t)^2*conjugate(u(x, t))^2+2*(diff(u(x, t), x))*conjugate(u(x, t))+2*u(x, t)*(diff(conjugate(u(x, t)), x)))

2*u(x, t)*(diff(u(x, t), x))*conjugate(u(x, t))+2*u(x, t)^2*(diff(conjugate(u(x, t)), x))+u(x, t)^3*conjugate(u(x, t))^2

Download solving_ac.mw

ps. Where did you get that code? If it's not originally your own then you'd benefit from picking it apart so that you understood what the various parts do. Otherwise, it's going to be hard to fix/adjust/extend it in future.

The result from a direct solve call is not so nice in your Maple 2019.

But a little preliminary adjustment can help it.

restart

kernelopts(version)

`Maple 2019.2, X86 64 LINUX, Nov 26 2019, Build ID 1435526`

B := w+Ce; A := (1/3)*`&varphi;`*(-beta*p1+a)-upsilon*Pu

ineq := (B-A*(2*U*upsilon+1)/upsilon)/(2*(U*upsilon+1)) <= (`&varphi;`*(-beta*p1+a)-A)/upsilon

(w+Ce-((1/3)*varphi*(-beta*p1+a)-upsilon*Pu)*(2*U*upsilon+1)/upsilon)/(2*U*upsilon+2) <= ((2/3)*varphi*(-beta*p1+a)+upsilon*Pu)/upsilon

temp := collect(ineq,p1);

(1/3)*varphi*beta*(2*U*upsilon+1)*p1/(upsilon*(2*U*upsilon+2))+(w+Ce-((1/3)*varphi*a-upsilon*Pu)*(2*U*upsilon+1)/upsilon)/(2*U*upsilon+2) <= -(2/3)*varphi*beta*p1/upsilon+((2/3)*varphi*a+upsilon*Pu)/upsilon

# lhs and rhs are both of type `+`, so select/remove make sense
new := simplify(temp - remove(depends,lhs(temp),p1) - select(depends,rhs(temp),p1));

(1/6)*varphi*beta*p1*(6*U*upsilon+5)/(upsilon*(U*upsilon+1)) <= (1/6)*((6*U*a*varphi-3*Ce+3*Pu-3*w)*upsilon+5*varphi*a)/(upsilon*(U*upsilon+1))

simplify(solve(new,p1));

piecewise(`and`(`&varphi;`*beta*(6*U*upsilon+5)/(6*upsilon*(U*upsilon+1)) = 0, 0 <= ((6*U*a*`&varphi;`-3*Ce+3*Pu-3*w)*upsilon+5*`&varphi;`*a)/(6*upsilon*(U*upsilon+1))), [{p1 = p1}], 0 < `&varphi;`*beta*(6*U*upsilon+5)/(6*upsilon*(U*upsilon+1)), [{p1 <= ((6*U*a*`&varphi;`-3*Ce+3*Pu-3*w)*upsilon+5*`&varphi;`*a)/(`&varphi;`*beta*(6*U*upsilon+5))}], `&varphi;`*beta*(6*U*upsilon+5)/(6*upsilon*(U*upsilon+1)) < 0, [{((6*U*a*`&varphi;`-3*Ce+3*Pu-3*w)*upsilon+5*`&varphi;`*a)/(`&varphi;`*beta*(6*U*upsilon+5)) <= p1}], [])

Download Q_isolate_acc.mw

There are pieces of information missing wrt whether all entries of any given (after the first outer list) are of the same type. Eg., what would be the classification number, if not all entries were of the same type?

But here is something that covers your sole, lonely example. How it extends will depend on your as-yet-unspecified other examples; your choices could make or break it.

restart;

 

H := proc(L::list,N::nonnegint)
  if L::And(list(list), positive &under nops) then
    N+H(L[1],N);
  else
    N;
  end if;
end proc:

 

H2 := proc(LL)
  subsindets(LL,And(list,
                    satisfies(u->(nops(u)>0 and u::list(list)))),
             op);
end proc:

 

L := [[1, 2, 3], [], [[1, 2], [3, 4], [5, 6]], [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]];

[[1, 2, 3], [], [[1, 2], [3, 4], [5, 6]], [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]]

map(H,L,1);

[1, 1, 2, 3]

map(H2,L);

[[1, 2, 3], [], [1, 2], [3, 4], [5, 6], [1, 2], [3, 4], [5, 6], [7, 8]]

L := [ [1, 2, 3],
       [],
       [[[[71,72], [92,93]]]],
       [[1, 2], [3, 4], [5, 6]],
       [[[1, 2], [3, 4]], [[5, 6], [7, 8]]] ];

[[1, 2, 3], [], [[[[71, 72], [92, 93]]]], [[1, 2], [3, 4], [5, 6]], [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]]

map(H,L,1);

[1, 1, 4, 2, 3]

map(H2,L);

[[1, 2, 3], [], [71, 72], [92, 93], [1, 2], [3, 4], [5, 6], [1, 2], [3, 4], [5, 6], [7, 8]]

Download some_list_stuff.mw

It is not necessary to make a separate ZeroMatrix call, or (in general) to simplify all of M+M^%T.

That is, forming mtest:=simplify(M+M^%T) is itself not very efficient, in general. The simplicification action can instead be part of the andmap predicate (with possible early bailout), and there's no need to test both triangles.

Also, the user-defined operator X->evalb(X) is an unnecessary layer; one could just map evalb.

restart;

M:=Matrix([[0,(40*sqrt(7)+140)/(560+sqrt(7)),(80*sqrt(7)+35)/(560+sqrt(7))],
           [(-40*sqrt(7)-140)/(560+sqrt(7)),0,(280-32*sqrt(7))/(560+sqrt(7))],
           [(-80*sqrt(7)-35)/(560+sqrt(7)),(-280+32*sqrt(7))/(560+sqrt(7)),0]]):

Easy to write, but not so efficient, despite using
andmap, since the whole of M+M^%T is computed.
(Also, no need to call ZeroMatrix.)
andmap(evalb,simplify(M+M^%T)=~0)

true

Slightly more efficient, since not doing all the simplifications
of every entry up-front.
andmap(evalb@simplify@`=`,M + M^%T,0);

true

Don't even form all of M+M^%T up front, but compute and
test each entry (or only the triangular portion, without duplicating
effort) in turn (and allow for early bail-out)
andseq(andseq(simplify(M[i,j]+M[j,i])=0,j=1..i),i=1..3);

true


Download Download_ac.mw

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