Maple 2022 Questions and Posts

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

Hello guys
I'm having trouble solving a PDE using pdsolve-numerical. Here's a notebook attached.

I'm grateful if anyone can help.

Regards,

Oliveira

                   PDE1.mw

x := 19.073*Unit('m'^4*'kg'^2/('s'^6*'A'^2)); simplify(x); Units:-Simple:-simplify(x); Units:-Standard:-simplify(x); Units:-Natural:-simplify(x); convert(x, units, V^2); # None of the simplify commands do anything. Is there a way to get the last result?

interface(version);

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

restart;
ode := diff(y(x),x)/y(x)-(3*(4*x^2+y(x)^2+1))/(2*x*(4*x^2+y(x)^2-2-2*x))=0;
DEtools:-odeadvisor(ode);
sol:=dsolve(ode,y(x));

(diff(y(x), x))/y(x)-(3/2)*(4*x^2+y(x)^2+1)/(x*(4*x^2+y(x)^2-2-2*x)) = 0

[_rational]

Error, (in dsolve) invalid subscript selector

 

Download error_jan_27_2023.mw

I want to create the groups (Z/nZ)+ and (Z/nZ)*.

I can do this in python for n=7. I want to do this with other values of n.

(Z/7Z)+
   0 1 2 3 4 5 6
0 0 1 2 3 4 5 6
1 1 2 3 4 5 6 0
2 2 3 4 5 6 0 1
3 3 4 5 6 0 1 2
4 4 5 6 0 1 2 3
5 5 6 0 1 2 3 4
6 6 0 1 2 3 4 5
 
(Z/7Z)*
   1 2 3 4 5 6
1 1 2 3 4 5 6
2 2 4 6 1 3 5
3 3 6 2 5 1 4
4 4 1 5 2 6 3
5 5 3 1 6 4 2
6 6 5 4 3 2 1
 

I tried creating a Cayley table but can not get that right.

This question was inspired by https://www.mapleprimes.com/questions/235613-Convert-A-List-With-Nested-Ordered-Sets.

I want to replace several characters of a string separately. 

s:="[ (0, 1), (1, 2), (1, 10), (2, 3), (3, 4), (4, 5), (4, 9), (5, 6), (6, 7), (7, 8),(8, 9), (10, 11), (11, 12), (11, 16), (12, 13), (13, 14), (14, 15), (15, 16)]"

Like this their will be many say n element then I need to a list as 

{{0,1},{1,2},{1,10},......}

I took the for-loop as follows, but I'm wondering if there's a more concise way to deal with it.

with(StringTools):
L:="[ (0, 1), (1, 2), (1, 10), (2, 3), (3, 4), (4, 5), (4, 9), (5, 6), (6, 7), (7, 8),(8, 9), (10, 11), (11, 12), (11, 16), (12, 13), (13, 14), (14, 15), (15, 16)]":    
L1:=["(",")","[","]"]:
L2:=["{","}","{","}"]:
X:=L:
for i from 1 to nops(L1) do
X:=SubstituteAll(X,L1[i],L2[i]);
end do:
parse(X)

{{0, 1}, {1, 2}, {1, 10}, {2, 3}, {3, 4}, {4, 5}, {4, 9}, {5, 6}, {6, 7}, {7, 8}, {8, 9}, {10, 11}, {11, 12}, {11, 16}, {12, 13}, {13, 14}, {14, 15}, {15, 16}}

I know that a function acting repeatedly can use f @@ n, for example,

(sin@@2)(x);

But if f  has some  arguments, can it still be used?

I am trying to call an optimization function for a set of operations where the object function contains integrals. i get this error when i try to do the optimization, i actually want to optimize a cost function, this is the error i get: Error, (in Optimization:-NLPSolve) integration range or variable must be specified in the second argument, got 1. = 4 .. 7

here is my work: 

a2 := 18;
b2 := 5;
a1 := 3;
b1 := 2.5;
ci := 0.05;
cr := 1;
cf := 10;
p := 0.1;
L := 0.5;
S := 3;
T := 10;
cud := 50;
co := 0.02;
tr := 0.006;
ti := 0.0014;
tf := 0.014;
K := 2;
A := 2;
M := 7;
f01 := x -> b1*(x/a1)^(b1 - 1)*exp(-(x/a1)^b1)/a1;
f02 := x -> b2*(x/a2)^(b2 - 1)*exp(-(x/a2)^b2)/a2;
fx := x -> p*f01(x) + (1 - p)*f02(x);
fh := h -> L*exp(-L*h);
Fh := h -> 1 - exp(-L*h);

P1_1 := (K, A, M) -> sum(int(fx(x)*(1 - Fh(i*A - x)), x = (i - 1)*A .. i*A), i = 1 .. K);
L1_1 := (K, A, M) -> sum((i*A + tr + i*ti)*P1_1(K, A, M), i = 1 .. K);
C1_1 := (K, A, M) -> sum((ci*i + cr)*P1_1(K, A, M), i = 1 .. K);
NULL;
P2_1 := (K, A, M) -> sum(int(fh(h)*fx(x), [h = 0 .. i*A - x, x = (i - 1)*A .. i*A]), i = 1 .. K);
L2_1 := (K, A, M) -> sum((tf + (i - 1)*ti)*int((x + h)*fh(h)*fx(x), [h = 0 .. i*A - x, x = (i - 1)*A .. i*A]), i = 1 .. K);
C2_1 := (K, A, M) -> sum(((i - 1)*ci + cf)*P2_1(K, A, M), i = 1 .. K);
P3_1 := (K, A, M) -> int(fh(h)*fx(x), [h = 0 .. M - x, x = A*K .. M]);
L3_1 := (K, A, M) -> (K*ti + tf)*int((x + h)*fh(h)*fx(x), [h = 0 .. M - x, x = A*K .. M]);
C3_1 := (K, A, M) -> (K*ci + cf)*P3_1(K, A, M);
P4_1 := (K, A, M) -> int(fx(x)*(1 - Fh(M - x)), x = A*K .. M);
L4_1 := (K, A, M) -> (K*ti + tr + M)*int(fx(x)*(1 - Fh(M - x)), x = A*K .. M);
C4_1 := (K, A, M) -> (K*ci + cr)*int(fx(x)*(1 - Fh(M - x)), x = A*K .. M);
P5_1 := (K, A, M) -> int(fx(x), x = M .. infinity);
L5_1 := (K, A, M) -> (K*ti + tr + M)*int(fx(x), x = M .. infinity);
C5_1 := (K, A, M) -> (K*ci + cr)*int(fx(x), x = M .. infinity);
Ptotal_1 := (K, A, M) -> P1_1(K, A, M) + P2_1(K, A, M) + P3_1(K, A, M) + P4_1(K, A, M) + P5_1(K, A, M);
Ptotal_1(K, A, M);
evalf(Ptotal_1(K, A, M));
Ltotal_1 := (K, A, M) -> L1_1(K, A, M) + L2_1(K, A, M) + L3_1(K, A, M) + L4_1(K, A, M) + L5_1(K, A, M);
evalf(Ltotal_1(K, A, M));
Ctotal_1 := (K, A, M) -> C1_1(K, A, M) + C2_1(K, A, M) + C3_1(K, A, M) + C4_1(K, A, M) + C5_1(K, A, M);
Cost_rate_1 := (K, A, M) -> Ctotal_1(K, A, M)/Ltotal_1(K, A, M);
integralOF := int(Cost_rate_1(K, A, M), x = 1 .. 2);
evalf(integralOF);
                          0.2759938793

MTBOF := Ltotal_1(K, A, M)/(P2_1(K, A, M) + P3_1(K, A, M));
evalf(MTBOF);
                          159.4642167

rd := 1/MTBOF;
ro := 1/M + rd;
const1 := 0 <= K;
const2 := K*A <= M;
const3 := M <= 20;
const4 := 0 <= A;
const5 := 0 <= M;
totalconstr := {const1, const2, const3, const4, const5};

optimized_cost := Optimization:-Minimize(integralOF, totalconstr);
Error, (in Optimization:-NLPSolve) integration range or variable must be specified in the second argument, got 1. = 4 .. 7
NULL;
 

please, i need assitance urgently.. thanks

What is happening at f(0)?

Look at PlotProblem.mw

Writing an explanatory paragrah i want to use an approximately equal symbol. How can I do this? The palette has lots of symbols but not what in latex would be done with \approx

My following code:

restart;
PDE := diff(u(x, t), t) + u(x, t)*diff(u(x, t), x) - 0.1*diff(diff(u(x, t), x), x) = 0;
IC := u(x, 0) = sin(x);
BC := [u(0, t) = u(2*Pi, t)];
pds := {BC, IC, PDE};
ds := {pds, t = 0 .. 10, x = 0 .. 2*Pi};
p := pdsolve(ds, numeric);
u := rhs(p[1]);
u(x, t);

producing following 2 errors, don't know how to handle?

Error, (in anonymous procedure called from pdsolve/numeric) invalid terms in sum: 0 .. 10
Error, invalid input: rhs received p[1], which is not valid for its 1st argument, expr

Hello guys
I'm having trouble converting the RootOf function. Attached is a simple notebook.

Sincerely,

Oliveira

Example.mw

Dear Maple Users:

Could you help in the following question?

How do I use a symbol as a subscript, e.g.  A_*, to label an axis?

When taking notes I sometimes use the palette to insert a matrix into a worksheet. When I do this, the main aspect that is useful to me is being able to visualize matrix expressions as I would write them.

I would like to do the same but for determinants of matrices. Is there a way to get almost the same thing as with the matrix palette, but with vertical bars denoting a determinant rather than the brackets used for matrices?

How do we compute integrals of functions or expressions that have units attached?
For example

v__1 := proc (t) options operator, arrow; 3*Unit('m'/'s') end proc

proc (t) options operator, arrow; 3*Unit('m'/'s') end proc

(1)

v__2 := 4*Unit('m'/'s')

4*Units:-Unit(m/s)

(2)

s__1 := int(v__1(t), t = 0 .. 5)

15*Units:-Unit(m/s)

(3)

s__2 := int(v__2, t = 0 .. 5)

20*Units:-Unit(m/s)

(4)

NULL


The results of the integrals have the wrong units.

Download integration_with_units.mw

Let's say we have four equations and four unknowns and we use solve to find a solution.

The return value of solve is a set.

Here is an example

solve({T__1 = m__1*a, a = R*alpha, -R*T__1+R*T__2 = I__s*a/R, g*m__2-T__2 = m__2*a}, {T__1, T__2, a, alpha})

{T__1 = R^2*g*m__2*m__1/(R^2*m__1+R^2*m__2+I__s), T__2 = m__2*g*(R^2*m__1+I__s)/(R^2*m__1+R^2*m__2+I__s), a = R^2*g*m__2/(R^2*m__1+R^2*m__2+I__s), alpha = R*g*m__2/(R^2*m__1+R^2*m__2+I__s)}

(1)

NULL


If we want to make the four expressions above procedures, the manual way is to basically copy the right-hand side of each expression and then write

T__1 := (R,m__1, m__2, g, I__s) -> ...

T__2 := (R,m__1, m__2, g, I__s) -> ...

a := (R,m__1, m__2, g, I__s) -> ...

alpha := (R,m__1, m__2, g, I__s) -> ...

Is there a way to do this automatically from the return value of solve?

If the return value were a list, I would use something like

T__1 := unapply(result[1], R, m__1, m__2, g, I__s)

T__2 := unapply(result[2], R, m__1, m__2, g, I__s)

a := unapply(result[3], R, m__1, m__2, g, I__s)

alpha := unapply(result[4], R, m__1, m__2, g, I__s)

But the return value is not a list.

So, in summary my quesions are

1) what, in general, is the best way to obtain the desired procedures?

2) is there a way to use the strategy I suggested if the result were a list, but for sets?

Download solveEqs.mw

Dear Maple users

I have encountered a very strange error at one of my students. When using functions from the Expression Palette, she receives an error. It happens every time she is using this Palette. A reinstallation of Maple didn't help solve this issue. When using Command Completion for the very same function (for example cosine or square root), it works properly. 

She did send a Maple file to me in order for me to investigate it. I opened it and reexecuted the entire document. The error messages remained. I tried applying the functions from the Expression Palette myself resulting in the same errors. I even opened a new document and tried it again. Still an error. Then I closed Maple completely and opened it again. Within a new document, I applied a function from the Expression Palette. Now it worked!! I can't seem to understand  the logic behind this behavior. The file sent to me by the student obviously contain some kind of error, but why will this error spread to a new document, which I have opned on my own computer? My own computer does not have any issues with Maple. 

I have attached the Maple file with the errors and a screen shot. I hope someone can explain this strange behavior and tell me how I can help this student make Maple work again. 

Kind regards,

Erik V.

Maple file:

Error.mw

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