Maple 2022 Questions and Posts

These are Posts and Questions associated with the product, Maple 2022

Could you suggest a more elegent way to remove any entry in piecewise which has undefined in it?

expr:=(s+exp(-Pi*s)-exp(-2*Pi*s))/(s*(s^2+2*s+2));
inttrans:-invlaplace(expr,s,t);
Y:=convert(%,piecewise);
#remove all entries in piecwise which has undefined

To obtain this

I can;t just apply select on piecewise. So currently I convert piecwise to list of lists, each sublist has the 2 entries you see above in each row.

Next apply select. Then use piecewise again on the result. This works, but wondering if there is a better way.

Attached worksheet.

interface(version);

`Standard Worksheet Interface, Maple 2022.2, Windows 10, October 23 2022 Build ID 1657361`

restart;
expr:=(s+exp(-Pi*s)-exp(-2*Pi*s))/(s*(s^2+2*s+2));
inttrans:-invlaplace(expr,s,t);
Y:=convert(%,piecewise);
#remove all entries in piecwise which has undefined

expr := (s+exp(-Pi*s)-exp(-2*Pi*s))/(s*(s^2+2*s+2))

exp(-t)*sin(t)+(1/2)*(-1+exp(-t+2*Pi)*(cos(t)+sin(t)))*Heaviside(t-2*Pi)+(1/2)*(1+exp(-t+Pi)*(cos(t)+sin(t)))*Heaviside(t-Pi)

piecewise(t < Pi, exp(-t)*sin(t), t = Pi, undefined, t < 2*Pi, exp(-t)*sin(t)+1/2+(1/2)*exp(-t+Pi)*(cos(t)+sin(t)), t = 2*Pi, undefined+(1/2)*exp(-Pi), 2*Pi < t, exp(-t)*sin(t)+(1/2)*exp(-t+2*Pi)*(cos(t)+sin(t))+(1/2)*exp(-t+Pi)*(cos(t)+sin(t)))

Y:=[op(Y)]:
Y:=seq([Y[n],Y[n+1]],n=1..nops(Y)-1,2):
ListTools:-Flatten(select(not has,[Y],'undefined')):
piecewise(op(%))

piecewise(t < Pi, exp(-t)*sin(t), t < 2*Pi, exp(-t)*sin(t)+1/2+(1/2)*exp(-t+Pi)*(cos(t)+sin(t)), 2*Pi < t, exp(-t)*sin(t)+(1/2)*exp(-t+2*Pi)*(cos(t)+sin(t))+(1/2)*exp(-t+Pi)*(cos(t)+sin(t)))


Download remove_undefined.mw

Another very strange result from simplify.  Consider

simplify(a*f(x) + b*f(x) + a*g(x))

Which is what is expected. Now 

expr := a*f(x) + b*f(x) + a*g(x) + 1/(a*f(x) + b*f(x) + a*g(x));
simplify(expr)

gives

why?  I expected (a+b)*f(x) also in the first expression. Compare for reference the same thing in Mathematica where it does them both the same way:

You see it simplified it to (a+b)*f(x)+a*g(x) in both places as expected.

I tried using size option for simplify, but it had no effect.

How can one obtain same result shown above using Maple? And why it does not automatically produce this result?

Maple 2022.2

 

I give up.

Why 

restart;
the_rule:=A::anything+B::anything=A*B;
applyrule(the_rule,a+b);

returns 0?

I was expecting a*b

No clue from help what I am doing wrong.

Maple 2022.2

trace gives this

restart;
the_rule:=A::anything+B::anything=A*B;
trace(applyrule);
applyrule(the_rule,a+b);


{--> enter applyrule, args = A::anything+B::anything = A*B, a+b
                        answer := a + b

                             i := 

                           i := a + b

                          answer := b

                             i := b

                          answer := 0

                             i := 0

                          answer := 0

I am not sure why it is doing the above still. 

I think I will stick to evalindents and subsindets as I do not understand applyrule very well.

I'm new to maple and I dont know how to solve this equation for k=1 to 4 and finding the roots. If anyone can help with this.

Equation  "cos(k).cosh(k)-1=0"

B := ((cos(k)) . (cosh(k))) - 1 = 0;
               B := (cos(k)) . (cosh(k)) - 1 = 0

solve(B, k);
               RootOf((cos(_Z)) . (cosh(_Z)) - 1)

solve(B, k);
 = 
               RootOf((cos(_Z)) . (cosh(_Z)) - 1)

plot(((cos(l)) . (cosh(l))) - 1, l = 5*_8);
Error, (in plot) unexpected option: l = 5*_8
solve(B, k = 1 .. 4);
Error, invalid input: too many and/or wrong type of arguments passed to solve; first unused argument is k = 1 .. 4
solve(B, k, k = 1 .. 4);
Error, invalid input: too many and/or wrong type of arguments passed to solve; first unused argument is k = 1 .. 4
solve({B}, {k = 1 .. 4});
Warning, solving for expressions other than names or functions is not recommended.
NULL;

Given an expression, I want to do an operation each time the pattern  f(arg1)+f(arg2) is found by replacing it by f(arg1+arg2). Regadless of how many there are. For example

f(A)+f(B) -> f(A+B) and  f(A)+f(B)+f(C) -> f(A+B+C)  and so on. But here is the catch, there could be anything else in the expressions. These will be left unchanged. 

So f(A)+f(B)+x -> f(A+B)+x

I can do it in Maple only when the input is exactly f(A)+f(B)  when the input is f(A)+f(B)+f(C) and so on.

But this is not practical as I need to make new type for each case.

I need a general way that will work for any expression like in the above example.

I am now using evalindets, but I do not know how to tell it the type for the general pattern of  f(n1)+f(n2)+.....+f(nn) to replace these with f(n1+n2+....nn).

For reference, this is code in Mathematica I am trying to translate to maple.

expr = Sin[x] + f[A] + f[B] + 10*Exp[x]/13 + Cos[x] + f[c] + f[10*c];
expr //. f[a_] + f[b_] :> f[a + b]

In the above //. means repeated replacement. So it will keep replacing the same pattern over and over and this works regardless of where f(a)+f(b) show up. They can be anywhere in the sum.

I wish I can the same in Maple using evalindets. I tried patmatch also, and same problem. Which is how to make it general. This is what I tried

expr:=f(A)+f(B);
evalindets(expr,`&+`('specfunc(f)','specfunc(f)'),F->f( op([1,1],F) + op([2,1],F) ) );

Which works

But to detect expr:=f(A)+f(B)+f(C) it would need new code

expr:=f(A)+f(B)+f(C);
evalindets(expr,`&+`('specfunc(f)','specfunc(f)','specfunc(f)'),F->f( op([1,1],F) + op([2,1],F) + op([3,1],F) ) );

Obviously this approach will not work. It will also fail once a new term is added in between. 

But how to extend this to the general case of

expr:=sin(x)+f(A)+f(B)+10*exp(x)/13+cos(x)+f(C)+f(10*C);

Is there a way to tell Maple to apply the pattern over and over like with Mathematica so it works for general case? I need to try to do this using either patmatch or evalindets. Ofcourse I can do it the hard way, by iterating over the expression and collecting all the f() and add their arguments one by one each `+` subtype. But that is now what I looking for.  

There should be something similar to how it is done in Mathematica, but using Maple command. Notice that the Mathematica example will work regadless of where the f(a)+f(b) shows up.

expr = Sin[x] + f[A] + f[B] + 10*Exp[x]/13 + Cos[x] + f[c] + 1/(f[10*c] + x + f[99])
expr //. f[a_] + f[b_] :> f[a + b]

ps. may be I need to use subsindets['nocache'] need to look more into it.

Are there rules of thumb to follow to decide to use evalindets vs. subsindets?  They seems to do the same thing, but I did not read every details of the help pages.  Is the difference similar to difference between using eval vs. subs? i.e.

          eval(expr,A=2)

vs.

         subs(A=2,expr) ?

For example

expr:=ln(A)+ln(B);
evalindets(expr,`&+`('specfunc(ln)','specfunc(ln)'),f->ln(op([1,1],f)*op([2,1],f)));
subsindets( expr, `&+`('specfunc(ln)','specfunc(ln)'), f->ln(op([1,1],f)*op([2,1],f)));

Both give

I am learning very basic matrix ops in Maple and I'm running into questions nearly at every step.

At the risk asking too many trivial questions, I have written my ~7 questions in the attached worksheet in red font.

Any answers will be appreciated.

matrix_ops_Qs.mw

matrix_ops_Qs.pdf

Hello

After using maple for quite a while, I am still confused by some basic concepts.   

Given the following table, how can I select the indices for which the entry is not null ([])?  

table([1 = NULL, 2 = NULL, 3 = NULL, 4 = NULL, 5 = NULL, 6 = NULL, 7 = 5, 9 = NULL, 8 = NULL, 11 = 4, 10 = NULL, 13 = NULL, 12 = NULL, 15 = 9, 14 = NULL, 18 = NULL, 19 = 8, 16 = 9, 17 = NULL, 22 = 9, 23 = NULL, 20 = NULL, 21 = 8, 27 = NULL, 26 = 8, 25 = 4, 24 = NULL, 31 = NULL, 30 = 9, 29 = NULL, 28 = 9, 36 = NULL, 37 = 9, 38 = 9, 39 = NULL, 32 = 5, 33 = NULL, 34 = NULL, 35 = NULL, 45 = NULL, 44 = NULL, 47 = NULL, 46 = NULL, 41 = 8, 40 = NULL, 43 = NULL, 42 = NULL, 54 = NULL, 55 = NULL, 52 = NULL, 53 = NULL, 50 = NULL, 51 = NULL, 48 = 5, 49 = 9, 60 = 8, 59 = NULL, 58 = 7, 57 = 7, 56 = NULL])

Many thanks

Hi, 

Maple has corrupted my file without notice. I get the error "There was a problem in the loading process, you worksheet may be incomplete."

I've tried restarting maple, checked my backup folder, and followed maples troubleshooting process (maplesoft support) without any luck.

Anyone who might help me here? 

File: Assignment2.mw

The algebraic equation in four variables is: 

restart;
expr := (a^2 + b^2 + c^2 + d^2 - 4)*(a^2 + b^2 + c^2 + d^2) + 4*d*c*b*a - (a + b + c + d - 2)*(a + b + c + d) + 6:
solve(expr = 0, useassumptions, allsolutions) assuming nonnegative;

Unfortunately, I've been waiting for a long time, and I have no more time to wait; I have to interrupt the current session by hand. However, it appears that MMA can solve it within bearable time:

Did Maple miss something here?

in my program, I keep assumptions in a set. Sometimes this is empty if no assumptions are used. This never caused a problem before (at least I do not think so, else I would have seen it) when using empty {} in assuming, except for now.

Here is one example below. Is this a known problem? I noticed when changing {} to [] the error goes away. I am not sure why, and if this is known issue. But will change from a set to a list to avoid this. 

Maple 2022.2 on windows 10

interface(version);

`Standard Worksheet Interface, Maple 2022.2, Windows 10, October 23 2022 Build ID 1657361`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1392 and is the same as the version installed in this computer, created 2023, February 13, 12:58 hours Pacific Time.`

restart;

ode:=diff(diff(y(x),x),x)+diff(y(x),x)^2+diff(y(x),x) = 0;
ic:=y(0) = 0;
sol:=y(x) = -ln(exp(x))+ln(-1+_C1*exp(x))-ln(-1+_C1);

diff(diff(y(x), x), x)+(diff(y(x), x))^2+diff(y(x), x) = 0

y(0) = 0

y(x) = -ln(exp(x))+ln(-1+_C1*exp(x))-ln(-1+_C1)

odetest(sol,[ode,ic]) assuming {};

Error, (in convert/multiset) too many levels of recursion

odetest(sol,[ode,ic]) assuming [];

[0, 0]

odetest(sol,[ode, ic]);

[0, 0]

 

Download feb_14_2023.mw

I am new to Maple. I'm having trouble with simple caluclations such as the one in the image. The answer (after simplificatoin and cancellations) should be (|a|^2+|b|^2)(x^2 + y^2 + z^2)  but it's not happening! The result shown is correct; only the simplification is missing. What step am I missing?

The calculation is so simple, a look at the picture should suffice for the expert,

(sorry! I still don't know how to pick-off a single tab out from the whole workbook).

Question-2: judging from the missing overbar (complex conj) on z, the "assuming" seems to only apply to z and not x and y.

if that is correct, then why?

Question-3: How can I implement the constraint (|a|^2+|b|^2)=1 (preferably)before or after this  multiplication? I tried assume((|a|^2+|b|^2)=1), and though it compiled it did not help with the simplification.

TYVM

i have on ode with some parameters. it is ok and it is solved. but when i substitute the parameter itself, it is not solved, can i use any assumption to solve this? tnx for the help.

restart

ode := diff(T(x), x, x)+q/k = 0

diff(diff(T(x), x), x)+q/k = 0

(1)

dsolve(ode)

T(x) = -(1/2)*q*x^2/k+_C1*x+_C2

(2)

ics1 := -k*(D(T))(0) = h[1]*(T[inf1]-T(0)), -k*(D(T))(0.5e-1) = h[2]*(T(0.5e-1)-T[inf2])

-k*(D(T))(0) = h[1]*(T[inf1]-T(0)), -k*(D(T))(0.5e-1) = h[2]*(T(0.5e-1)-T[inf2])

(3)

dsolve({ics1, ode})

T(x) = -(1/2)*q*x^2/k-(1/40)*h[1]*(800*k*T[inf1]*h[2]-800*k*T[inf2]*h[2]-40*k*q-q*h[2])*x/((20*k*h[1]+20*k*h[2]+h[1]*h[2])*k)+(1/40)*(800*k*T[inf1]*h[1]+800*k*T[inf2]*h[2]+40*T[inf1]*h[1]*h[2]+40*k*q+q*h[2])/(20*k*h[1]+20*k*h[2]+h[1]*h[2])

(4)

ics2 := -k*(D(T))(0) = h[1]*(T[inf1]-T(0)), -k*(D(T))(L) = h[2]*(T(L)-T[inf2])

-k*(D(T))(0) = h[1]*(T[inf1]-T(0)), -k*(D(T))(L) = h[2]*(T(L)-T[inf2])

(5)

dsolve({ics2, ode})

Error, (in dsolve) found differentiated functions with same name but depending on different arguments in the given DE system: {T(L), T(x)}

 

``

Download ExactSol.mw

My question is can the last step be equal to 1/6.

I want to output to 1/6. it outputs to sqrt(9)/18 - (See Below).

NULL"5)Square root: undefined - DNE (Limit does not exist):"

NULL

NULL

NULL

limit((sqrt(x+1)-3)/(x-8), x = 8)"(=)"1/6 

 

 

limit((sqrt(x+1)-3)/(x-8), x = 8)Limit(((x+1)^(1/2)-3)/(x-8), x = 8) = (1/18)*9^(1/2)"(=)"Limit(((x+1)^(1/2)-3)/(x-8), x = 8) = 1/6

NULL

Download limit-sqrt-5.mw

What is the logic behind this?

expr:=(c[2]+x)^3;
simplify(expr)

Which is what expected. But 

expr:=(c[2]+x)^3+a;
simplify(expr)

gives

Which does not look simpler to me. I expected it to be the same as before but with "a" added.  This is what Mathematica gives for comparison

I know I can use simplify with size option. But my question is, how did Maple decide that x^3 + 3*x^2*c[2] + 3*x*c[2]^2 + c[2]^3 + a is "simpler" than (c[2] + x)^3 + a ? It must use some logic which I am trying to understand.

Maple 2022.2 on windows 10

First 18 19 20 21 22 23 24 Last Page 20 of 43