MaplePrimes Questions

Hi!

Is it possible to create a vector, say

phi := Vector(2);
phi[1] := x[1]+2*x[2];
phi[2] := x[2]**2+x[1];

and then save it in a file that you can use in Matlab as a function handle?

I want to be able to create the phi vector in Maple but use it in Matlab.

Thanks for help!

 

Hi, 

Could the Maplesoft staff change the definition of the GammaDistribution in package Statistics?

In the all the papers or courses in the fiels of Probability or Statistics, the shape parameter is the first parameter of this distribution, while the scale (or "rate") parameter is the second.

From versions to versions the Maple definition of this distribution switches these parameters.
It's really a pain in the ass when you want to implement algorithms that use this distribution*

Thanks for your understanding


* for specialists, the Clayton copula uses as an ingredient a sample from Gamma(1/theta, 1) where theta is an adhoc parameter.
In Maple you must code s:=Sample(GammaDistribution(1, 1/theta)).

OK, you could reply me that once I know the trick it is the simplest thing at world to do the switch myself: nevertheless it's really boring, to say the least

1) start cmaple.exe;

2) type "proc(x, x);", and watch Maple die;

3) Request a refund from Maplesoft.

I am using command-line Maple cmaple.exe, I have been trying several hours to type the correct several characters to create a lambda function (anonymous function), but Maple's documentation is only for people using the GUI and gives no hint how to translate the right-arrow symbol into ASCII.

What is the secret, undocumented sequence of ASCII characters for defining an anonymous function via the command-line interface? (Why not document it in the user-manual, for those of who can't stand Maple's bad GUI?)

I have a maple code that has two output blocks giving a large number of numerical values for my experiment. I need these values to compare the output in both the code blocks and also to draw several figures using the data. On a single run of the program, a large number of values are obtained and then I manually copy them to excel sheet for further analysis. It takes a lot of my time to copy and paste the results on each run. I want to export the outputs of both the code blocks to a excel sheet. Any suggestion on this problem will be helpful to me. Thanks.

The link to my code is  maple-excel.mw.

I want the output in this format Book1.xlsx

Dear All,

I am having trouble with doing integration of a complex integrand with Maple 2016. The code is shown below. For simplicity, I have used a real function Psi00, but in general, it should be a complex function. Although I have assumed r to be real, in the final output, there is still an overhead bar on r^1/4. It is not recognized as real and is not multiplied on the r^5/4 factor to give r^3/2. May I ask you for help in solving this problem? Any of your help is highly appreciated!

Best,

Toby

assume(r, real); assume(phi, real);
Psi00 := exp(-(1/2)*r^2)/sqrt(Pi);
                             /  1  2\
                          exp|- - r |
                             \  2   /
                          -----------
                              (1/2)  
                            Pi       

int(int(conjugate(Psi00*r^(1/4))*Psi00*r^(1/4)*r, r = 0 .. infinity), phi = 0 .. 2*Pi);
    /   /             2 ______                          \\   
    |   |/   /  1  2\\   (1/4)  (5/4)                   ||   
    |   ||exp|- - r ||  r      r                        ||   
    |   |\   \  2   //                                  ||   
  2 |int|----------------------------, r = 0 .. infinity|| Pi
    \   \             Pi                                //   

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

 

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?

 

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..!! 

First 777 778 779 780 781 782 783 Last Page 779 of 2428