Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

What Maple type should I use so that test1 and test2 are always equal? (I use Maple 2017)

 

test1 := proc(x) type([op('x')], identical(['x'])) end;
MapleType := anything;
test2 := proc(x) type(x, MapleType) end;

 

Hi everyone,

I'm a beginner in maple and coding in general.

I'm making a model that need to solve a set of linear ODE in maple. Say I have model 1 and model 2.

In model 1, everything works fine and the results I get match with the experiments. However, when I modify model 1 into model 2 by adding 1 additional term multiplied by sigma (a constant) in the set of the ODE, The equations solved by maple produced complex number instead. 

May I know the reason why maple produces complex number as the result?

Please find attached the worksheet. SP1JH1B1.mw

The set of ODE are at the "longitudinal behaviour" section and the ODEs are deq2..6. When I set sigma=0 (basically back to model 1), maple gives me real number solutions again.

If I don't put "evalf" in front of value(dsolve(...)) (see sol_L), Maple produces `[Length of output exceeds limit of 1000000]`

Any help would be greatly appreciated.

Thanks in advance!

Hi,

Is it possible to write the title of a plot on two different lines with different fonts for each line?
For instance:

MyTitle := typeset("Identity function", "\n(illustration));
plot(x, x=0..1, title=MyTitle);

with the upper line  [times, bold, 14]
and the lower one   [times, roman, 12]

 

Hello all,

I am presenting some results in a small meeting tomorrow and I have a rather large symbollic matrix that I was hoping to be able to view in a more readable form (once you see my code, you will see what I mean). This should be a simple fix. Furthermore, when I use the Latex command to recieve code to import into latex, its not working properly, which makes me think I made some kind of mistake. I am really just trying to get this matrix in its full for so that it is easy for other people to read. Thanks for any help.Turns_Latex.mw
 

restart

with(LinearAlgebra)``

A := Matrix(5, 5, [0, 0, 0, 0, 0, -AXX*UU-AXY*VV-AXZ*WW, AXX, AXY, AXZ, 0, -AXY*UU-AYY*VV-AYZ*WW, AXY, AYY, AYZ, 0, -AXZ*UU-AYZ*VV-AZZ*WW, AXZ, AYZ, AZZ, 0, -AXX*UU*UU-AYY*VV*VV-AZZ*WW*WW-(AXY*UU*VV+AXZ*UU*WW+AYZ*VV*WW)*2+(-E+2*UVW)*AE, -AE*UU-VL2, -AE*VV-VL3, -AE*WW-VL4, AE])

A := subs(VL2 = -AXX*UU-AXY*VV-AXZ*WW, VL3 = -AXY*UU-AYY*VV-AYZ*WW, VL4 = -AXZ*UU-AYZ*VV-AZZ*WW, A)

A := subs(AXX = mu*(zeta__x^2+zeta__y^2+zeta__z^2+(1/3)*`#msup(mi("\`zeta__x\`"),mn("2"))`), AYY = mu*(`ζ__x`^2+`ζ__y`^2+`ζ__z`^2+(1/3)*`#msup(mi("\`ζ__y\`"),mn("2"))`), AZZ = mu*(`ζ__x`^2+`ζ__y`^2+`ζ__z`^2+(1/3)*`#msup(mi("\`ζ__z\`"),mn("2"))`), A)

A := subs(AXY = (1/3)*mu*zeta__x*zeta__y, AXZ = (1/3)*mu*zeta__x*zeta__z, AYZ = (1/3)*mu*zeta__y*zeta__z, A)

A := subs(UU = u, VV = v, WW = w, A)

A := subs(AE = mu*gamma*(`ζ__x`^2+`ζ__y`^2+`ζ__z`^2)/Pr, A)

Matrix(%id = 18446744078321522678)

(1)

latex(A)

 \left[ \begin {array}{ccccc} 0&0&0&0&0\\ \noalign{\medskip}-\mu\,
 \left( {\zeta_{x}}^{2}+{\zeta_{y}}^{2}+{\zeta_{z}}^{2}+\mbox {{\tt
\#msup(mi("zeta}}_{\mbox {{\tt x"),mn("2"))}}}/3 \right) u-1/3\,\mu\,
\zeta_{x}\,\zeta_{y}\,v-1/3\,\mu\,\zeta_{x}\,\zeta_{z}\,w&\mu\,
 \left( {\zeta_{x}}^{2}+{\zeta_{y}}^{2}+{\zeta_{z}}^{2}+\mbox {{\tt
\#msup(mi("zeta}}_{\mbox {{\tt x"),mn("2"))}}}/3 \right) &1/3\,\mu\,
\zeta_{x}\,\zeta_{y}&1/3\,\mu\,\zeta_{x}\,\zeta_{z}&0
\\ \noalign{\medskip}-1/3\,\mu\,\zeta_{x}\,\zeta_{y}\,u-\mu\, \left( {
\zeta_{x}}^{2}+{\zeta_{y}}^{2}+{\zeta_{z}}^{2}+\mbox {{\tt
\#msup(mi("zeta}}_{\mbox {{\tt y"),mn("2"))}}}/3 \right) v-1/3\,\mu\,
\zeta_{y}\,\zeta_{z}\,w&1/3\,\mu\,\zeta_{x}\,\zeta_{y}&\mu\, \left( {
\zeta_{x}}^{2}+{\zeta_{y}}^{2}+{\zeta_{z}}^{2}+\mbox {{\tt
\#msup(mi("zeta}}_{\mbox {{\tt y"),mn("2"))}}}/3 \right) &1/3\,\mu\,
\zeta_{y}\,\zeta_{z}&0\\ \noalign{\medskip}-1/3\,\mu\,\zeta_{x}\,\zeta
_{z}\,u-1/3\,\mu\,\zeta_{y}\,\zeta_{z}\,v-\mu\, \left( {\zeta_{x}}^{2}
+{\zeta_{y}}^{2}+{\zeta_{z}}^{2}+\mbox {{\tt \#msup(mi("zeta}}_{\mbox
{{\tt z"),mn("2"))}}}/3 \right) w&1/3\,\mu\,\zeta_{x}\,\zeta_{z}&1/3\,
\mu\,\zeta_{y}\,\zeta_{z}&\mu\, \left( {\zeta_{x}}^{2}+{\zeta_{y}}^{2}
+{\zeta_{z}}^{2}+\mbox {{\tt \#msup(mi("zeta}}_{\mbox {{\tt
z"),mn("2"))}}}/3 \right) &0\\ \noalign{\medskip}-\mu\, \left( {\zeta_
{x}}^{2}+{\zeta_{y}}^{2}+{\zeta_{z}}^{2}+\mbox {{\tt \#msup(mi("zeta}}
_{\mbox {{\tt x"),mn("2"))}}}/3 \right) {u}^{2}-\mu\, \left( {\zeta_{x
}}^{2}+{\zeta_{y}}^{2}+{\zeta_{z}}^{2}+\mbox {{\tt \#msup(mi("zeta}}_{
\mbox {{\tt y"),mn("2"))}}}/3 \right) {v}^{2}-\mu\, \left( {\zeta_{x}}
^{2}+{\zeta_{y}}^{2}+{\zeta_{z}}^{2}+\mbox {{\tt \#msup(mi("zeta}}_{
\mbox {{\tt z"),mn("2"))}}}/3 \right) {w}^{2}-2/3\,\mu\,\zeta_{x}\,
\zeta_{y}\,uv-2/3\,\mu\,\zeta_{x}\,\zeta_{z}\,uw-2/3\,\mu\,\zeta_{y}\,
\zeta_{z}\,vw+{\frac { \left( -E+2\,{\it UVW} \right) \mu\,\gamma\,
 \left( {\zeta_{x}}^{2}+{\zeta_{y}}^{2}+{\zeta_{z}}^{2} \right) }{\Pr}
}&-{\frac {\mu\,\gamma\, \left( {\zeta_{x}}^{2}+{\zeta_{y}}^{2}+{\zeta
_{z}}^{2} \right) u}{\Pr}}+\mu\, \left( {\zeta_{x}}^{2}+{\zeta_{y}}^{2
}+{\zeta_{z}}^{2}+\mbox {{\tt \#msup(mi("zeta}}_{\mbox {{\tt
x"),mn("2"))}}}/3 \right) u+1/3\,\mu\,\zeta_{x}\,\zeta_{y}\,v+1/3\,\mu
\,\zeta_{x}\,\zeta_{z}\,w&-{\frac {\mu\,\gamma\, \left( {\zeta_{x}}^{2
}+{\zeta_{y}}^{2}+{\zeta_{z}}^{2} \right) v}{\Pr}}+1/3\,\mu\,\zeta_{x}
\,\zeta_{y}\,u+\mu\, \left( {\zeta_{x}}^{2}+{\zeta_{y}}^{2}+{\zeta_{z}
}^{2}+\mbox {{\tt \#msup(mi("zeta}}_{\mbox {{\tt y"),mn("2"))}}}/3
 \right) v+1/3\,\mu\,\zeta_{y}\,\zeta_{z}\,w&-{\frac {\mu\,\gamma\,
 \left( {\zeta_{x}}^{2}+{\zeta_{y}}^{2}+{\zeta_{z}}^{2} \right) w}{\Pr
}}+1/3\,\mu\,\zeta_{x}\,\zeta_{z}\,u+1/3\,\mu\,\zeta_{y}\,\zeta_{z}\,v
+\mu\, \left( {\zeta_{x}}^{2}+{\zeta_{y}}^{2}+{\zeta_{z}}^{2}+\mbox {{
\tt \#msup(mi("zeta}}_{\mbox {{\tt z"),mn("2"))}}}/3 \right) w&{\frac
{\mu\,\gamma\, \left( {\zeta_{x}}^{2}+{\zeta_{y}}^{2}+{\zeta_{z}}^{2}
 \right) }{\Pr}}\end {array} \right]

 

``


 

Download Turns_Latex.mwTurns_Latex.mw

 

Set of vector mechanics exercises in the plane and space using the result technique in line (combining the key ALT + ENTER) also the unit package using the law of the triangle. It is observed that the solution is totally optimal. I leave your constructive criticism to the community's criteria. I hope that someone will raise an alternative solution using the minimum number of lines but that the students will learn. In spanish.

Ejercicios_de_Vectores_Fuerza_y_Proyecciones_2D_y_3D.mw

Lenin Araujo Castillo

Ambassador of Maple

I am writing a small code to find median and mean. The code works for an even number of terms, not for an odd number of terms. I tried to find the error but cannot.

restart:medianmean:= proc(x) local a,b,c,d,m,g;
a:=sort(x); b:=nops(x); c:=nops(x)/2; d:=(nops(x)+1)/2;
m:=(a[c]+a[c+1])/2; g:=add(a)/b;
if (b mod 2 = 0) then evalf([a,m,g]) ;
else evalf([a,a[d],g]);
end if; end proc:

 

Hi,

I use the first example in the HeatMap help page.

restart:
with(Statistics):
RM := LinearAlgebra:-RandomMatrix(10):
HeatMap(RM);

I want to replace each tickmarks k (k=1..10) by cat(`A`, k).
So I do

NewTickMarks := [seq(k+1/2=cat(`A`, k), k=1..10)]:
HeatMap( RM, tickmarks=[NewTickMarks , NewTickMarks ] );

The horizontal tickmarks are displayed as expected: why the vertical tickmarks do not appear?

PS : HeatMap( RM, tickmarks=[NewTickMarks , default] ) changes the horizontal tickmarks without removing the vertical ones.

Thnks for the help
 

Hello!

Is there any chance to bring the expression x2+xy+y2 to the form like x2+y2+xy (i.e. to set/define exact order of monomials) with Maple? What syntax (i.e. commands, packages, etc.) should I use? Many thaks in advance for any useful advice

 

When dsolve throws an error, is it always due to invalid user input, such as parsing error of some sort related to the input given to it, or could it throw an error not related to the parsing part? And if so, how would one know, in code, the difference between an error thrown due to parsing error, vs. something else?

For example, this will throw an error due to parsing

 

ode:=diff(y(x),x)+y;
try
   dsolve(ode,y(x));
catch:    
    print(StringTools:-FormatMessage( lastexception[2..-1] )); 
end try;

   "y(x) and y cannot both appear in the given ODE."

I want to check programmatically, if and when an error thrown by dsolve, if it is due to input itself being invalid, such as parsing error, or invalid initial conditions, and such bad input from the user, vs. other possible error that could be generated internally for other reasons when the input is valid.

I looked at help and there is no mention of what type of exceptions dsolve can throw, or how would would determine the type of exception, as Maple exceptions seem to be just strings and there is no actual identifier or type associated with them to use to check on.

I also looked at https://www.maplesoft.com/support/help/Maple/view.aspx?path=ErrorMessageGuideOverview  and seen nothing there that helps. It just says
 

There are three circumstances that would generate an error in Maple:

1. 	User Errors - the user has supplied incorrect input
2. 	No Solution - in some cases, a Maple routine will issue an error, indicating that the given problem has no solution
3. 	Maple Errors - Maple generates an error during internal computation in response to a problem with its own code

Great., But it does not say how a would a user know which is which when an error is thrown? (using code, not by looking at the screen and then using google).

In Mathematica for example, error messages have actual names, and one could check for the actual message tag itself in the code, to find what the error actually is, instead of using just a plain string of the error message. 

Does Maple have such a thing to use to help find what class of error was thrown out the above three classes shown in the above web page?

 

Important use of the embedded components called Shortcut applied to vector mechanics exercises for engineering students. This makes each solution of each problem open independently and thus this way to explain in class. To use this worksheet, first unzip all the files in a single folder. In spanish

Equilibrium_with_Shortcut.zip

Lenin Araujo Castillo

Ambassador of Maple

x1=time, x2=rpm, x3=volu, f1=result; 
> x1=30; 
> f1:=11.921131-0.140022*x2+0.001034*x3+0.000836*x1*x1+0.001003*x2*x1-0.000052693*x2*x2+0.000177*x3*x1+0.000157*x3*x2-0.000011584*x3*x3;
> plot3d(f1,x1=15..60,x2=0..100,x3=400..800,axes=boxed);

Error, (in plot3d/options3d) unknown or bad optional argument: x3 = 400 .. 800

This is my code. and "Error, (in plot3d/options3d) unknown or bad optional argument: x3 = 400 .. 800" is my problem.

How to i get the solution???

please help me..!! 


The command L2(1,2) etc (statements 5 to 8) all are considered as valid and gives the complete list as the answer. Can anyone interpret the behaviour and logic behind the maple answers?

s := [1], [2]

[1], [2]

(1)

L2 := [s]

[[1], [2]]

(2)

type(L2, listlist)

true

(3)

L2__1

L2__1

(4)

"Following commands  give the list L2, which in my opinion is wrong."

L2(1)

[[1], [2]]

(5)

L2(1, 1)

[[1], [2]]

(6)

L2(1, 2)

[[1], [2]]

(7)

L2(2, 2)

[[1], [2]]

(8)

``

L2[2]

[2]

(9)

L2[1][2]

Error, invalid subscript selector

 

``


 

Download Doubt1.mw


 

restart; with(LinearAlgebra); with(plots)

M := 3:

for i while i <= 3 do t[i] := cos((2*i+1)*evalf(Pi)/(2^k*M)) end do;

-0.2051033808e-9

 

-.8660254038

 

-.8660254034

(1)

``

``

printlevel := 2:

-0.2051033808e-9

 

-1.000000000

 

-.8660254038

 

-2.732050808

 

-.8660254034

 

-2.732050807

 

-0.3076550712e-9*p[1](-0.2051033808e-9)-1/2

 

-1.732050808*p[1](-0.2051033808e-9)

 

-1.299038106*p[1](-.8660254038)-1/2

 

-4.732050809*p[1](-.8660254038)

 

-1.299038105*p[1](-.8660254034)-1/2

 

-4.732050808*p[1](-.8660254034)

 

-0.3418389680e-9*p[2](-0.2051033808e-9)-(2/3)*p[1](-0.2051033808e-9)

 

-2.236067977*p[2](-0.2051033808e-9)

 

-1.443375673*p[2](-.8660254038)-(2/3)*p[1](-.8660254038)

 

-6.109051323*p[2](-.8660254038)

 

-1.443375672*p[2](-.8660254034)-(2/3)*p[1](-.8660254034)

 

-6.109051321*p[2](-.8660254034)

 

-0.3589309164e-9*p[3](-0.2051033808e-9)-(3/4)*p[2](-0.2051033808e-9)

 

-2.645751310*p[3](-0.2051033808e-9)

 

-1.515544457*p[3](-.8660254038)-(3/4)*p[2](-.8660254038)

 

-7.228327004*p[3](-.8660254038)

 

-1.515544456*p[3](-.8660254034)-(3/4)*p[2](-.8660254034)

 

-7.228327002*p[3](-.8660254034)

(2)

y(t) := -1.204*phi[1, 0]+.754*phi[1, 1]+.647*phi[1, 2];

3.289389172-3.567966309*p[1](-.8660254034)-3.952556205*p[2](-.8660254034)

(3)

 

``

plot(y(t))

 plot called with arguments: 3.289389172-3.567966309*p[1](-.8660254034)-3.952556205*p[2](-.8660254034), axiscoordinates = (), coords = (), ispolarplot = false
 #(plot,7): error

Error, (in plot) cannot determine plotting variable

 

 locals defined as: cname = cname

 

``

``


 

Download us3.mw

Do not have a working activation code for Maple17.  Have these 2, but neither works.
Y3KKTP32PLF9PXFU 

ZJLL59SMMXQSE8MU

 

I am running Ubuntu 18 (linux).

Thanks

Tom Vawter

(John Vawter)

 

How can I quickly construct a lower triangular matrix?

I tried the following:

restart;

n := 4;

M1 := Matrix(Vector([seq(k, k = 1 .. n)]), shape = diagonal);

M2 := Matrix(Vector([seq(1, k = 1 .. n-1)]), shape = diagonal);

M := Matrix([M1, M2], shape = triangular[lower])

 

 

 

In this case the diagonal has value 1,2,3,4 while the line below 1,1,1.

 

edit: Actually I managed with

M := Matrix([[1], seq([seq(0, i = 1 .. k-2), 1, k], k = 2 .. n)], shape = triangular[lower])

 

 

 

but I was wondering if it is also possible to use Matrices to fill parts of a bigger matrix?

First 765 766 767 768 769 770 771 Last Page 767 of 2219