MaplePrimes Questions

Dear reader,

Have to create digital questions in Mobius on quaternions. Aim is to teach students of robot engineering about rotations besides the matrix rotations. Made some code, it works but very simplistic. I could not load a quarternion-toolbox.

Any suggestions?

# quaternion product
# define two vecotrs p and q:
$p0=range(3,3,1);
$px=range(1,1,1);
$py=range(-2,-2,1);
$pz=range(1,1,1);
$q0=range(2,2,1);
$qx=range(-1,-1,1);
$qy=range(2,2,1);
$qz=range(3,3,1);
$p=maple("Vector([$px,$py,$pz])");
$q=maple("Vector([$qx,$qy,$qz])");
$displayp=maple("printf(MathML:-ExportPresentation($p))");
$displayq=maple("printf(MathML:-ExportPresentation($q))");
# p.q=p0.q0-(p.q)+p0.q+q0.p+p*q
# scalar part
$dot=maple("LinearAlgebra[DotProduct]($p,$q,conjugate=false)");
$scalar_part=$p0*$q0-$dot;
# vector part
$cross=maple("LinearAlgebra[CrossProduct]($p,$q)");
$p0q=maple("LinearAlgebra[MatrixMatrixMultiply]($p0,$q)");
$q0p=maple("LinearAlgebra[MatrixMatrixMultiply]($q0,$p)");
$pq=maple("LinearAlgebra[VectorAdd]($p0q,$q0p)");
$vector_part=maple("LinearAlgebra[VectorAdd]($pq,$cross)");
$displayvector_part=maple("printf(MathML:-ExportPresentation($vector_part))");
# unit vectors
$i=maple("Vector([1,0,0])");
$j=maple("Vector([0,1,0])");
$k=maple("Vector([0,0,1])");
# generate answers
$x=maple("LinearAlgebra[DotProduct]($vector_part,$i)");
$y=maple("LinearAlgebra[DotProduct]($vector_part,$j)");
$z=maple("LinearAlgebra[DotProduct]($vector_part,$k)");
 

Best regards,

Nico Booij

I have recently received a doc from my friend in privete group in maple cloud, the table showed both eye(view) icon and download icon).When I downloaded and run, the document does not run (maple 2019). 

When I sign in maple cloud and see the doc (only view button is ahow), the same document works fine. What could be the error?

I attach  a document extract showing the errors (unable to delimt   .../  identifiers).

Can any one help us please?

Thanks. Ramki.
 

``

"Refraction Demonstration          restart:with(plots):  RefractionDemo:=proc(theta1, n2)  local theta2,ainput,ainside,aoutput,box,line1,line2,H,n2text,theta1text,theta2text;   if(theta1<0)or(theta1>Pi/(2.0001)) then return end if;   #theta1:=theta01*Pi180.;   theta2:=arcsin(1/(n2)*sin(theta1));   ainput:=arrow(?&ndash;cos(theta1),&ndash;sin(theta1)?,?cos(theta1),sin(theta1)?,color="Red"):   ainside:=arrow(?0,0?,?1,tan(theta2)?,color="DarkBlue",width=[0.05,relative=false]):   aoutput:=arrow(?1,tan(theta2)?,?cos(theta1),sin(theta1)?,color="Red"):   line1:=plot(0,x=&ndash;1..0,thickness=4,color=black);   line2:=plot(tan(theta2),x=1..2,thickness=4,color=black);   H:=1.8:   box:=plottools:&ndash;rectangle([0,&ndash;H],[1,H],color="LightBlue"):   n2text:=textplot([0.5,1.5,sprintf("n_2=%1.3 g",n2)]);   theta1text:=textplot([&ndash;0.5,0.4,sprintf("theta_1=%4.3 g",theta1)]);   theta2text:=textplot([0.5,&ndash;0.4,sprintf("theta_2=%4.3 g",theta2)]);   display([ainput,ainside,aoutput,box,line1,line2,n2text,theta1text,theta2text],scaling=constrained,view=[&ndash;1..2,&ndash;1..H]);   endproc:        Light enters from the air into a medium at an angle of theta1 relative to the normal. It is refracted to an angle of theta2and travels through the medium, returning back to the air.      You can vary two parameters:       theta1the angle of incidence       n2the index of refraction of the medium*(assuming the index of refraction of the air is essentially 1.0).     To do: Let it execute and start manipulating the sliders.     >Explore(RefractionDemo(theta1,n2),parameters=[theta1=0..Pi2.0015,n2=1..3.]);6""

Error, unable to delimit strings/identifiers

"Refraction Demonstration          restart:with(plots):  RefractionDemo:=proc(theta1, n2)  local theta2,ainput,ainside,aoutput,box,line1,line2,H,n2text,theta1text,theta2text;   if(theta1<0)or(theta1>Pi/2.0001) then return end if;   #theta1:=theta01*Pi180.;   theta2:=arcsin(1/n2*sin(theta1));   ainput:=arrow(&acirc;ï¿&frac12;&uml;&ndash;cos(theta1),&ndash;sin(theta1)&acirc;ï¿&frac12;&copy;,&acirc;ï¿&frac12;&uml;cos(theta1),sin(theta1)&acirc;ï¿&frac12;&copy;,color="Red"):   ainside:=arrow(&acirc;ï¿&frac12;&uml;0,0&acirc;ï¿&frac12;&copy;,&acirc;ï¿&frac12;&uml;1,tan(theta2)&acirc;ï¿&frac12;&copy;,color="DarkBlue",width=[0.05,relative=false]):   aoutput:=arrow(&acirc;ï¿&frac12;&uml;1,tan(theta2)&acirc;ï¿&frac12;&copy;,&acirc;ï¿&frac12;&uml;cos(theta1),sin(theta1)&acirc;ï¿&frac12;&copy;,color="Red"):   line1:=plot(0,x=&ndash;1..0,thickness=4,color=black);   line2:=plot(tan(theta2),x=1..2,thickness=4,color=black);   H:=1.8:   box:=plottools:&ndash;rectangle([0,&ndash;H],[1,H],color="LightBlue"):   n2text:=textplot([0.5,1.5,sprintf("n_2=%1.3 g",n2)]);   theta1text:=textplot([&ndash;0.5,0.4,sprintf("theta_1=%4.3 g",theta1)]);   theta2text:=textplot([0.5,&ndash;0.4,sprintf("theta_2=%4.3 g",theta2)]);   display([ainput,ainside,aoutput,box,line1,line2,n2text,theta1text,theta2text],scaling=constrained,view=[&ndash;1..2,&ndash;1..H]);   endproc:        Light enters from the air into a medium at an angle of theta1 relative to the normal. It is refracted to an angle of theta2and travels through the medium, returning back to the air.      You can vary two parameters:       theta1the angle of incidence       n2the index of refraction of the medium*(assuming the index of refraction of the air is essentially 1.0).     To do: Let it execute and start manipulating the sliders.     >Explore(RefractionDemo(theta1,n2),parameters=[theta1=0..Pi2.0015,n2=1..3.]);"

 

``

``

``

``Dear Prof.

The following code seems not copying properly (my communication error be allowed please)

 

"ainput:=arrow(?&"

Error, unable to delimit strings/identifiers

"ainput:=arrow(&acirc;ï¿&frac12;&uml;&ndash;cos(theta1),&ndash;sin(theta1)&acirc;ï¿&frac12;&copy;,&acirc;ï¿&frac12;&uml;cos(theta1),sin(theta1)&acirc;ï¿&frac12;&copy;,color="Red"):ainside:=arrow(&acirc;ï¿&frac12;&uml;0,0&acirc;ï¿&frac12;&copy;,&acirc;ï¿&frac12;&uml;1,tan(theta2)&acirc;ï¿&frac12;&copy;,color="DarkBlue",width=[0.05,relative=false]):aoutput:=arrow(&acirc;ï¿&frac12;&uml;1,tan(theta2)&acirc;ï¿&frac12;&copy;,&acirc;ï¿&frac12;&uml;cos(theta1),sin(theta1)&acirc;ï¿&frac12;&copy;,color="Red"):"

 

``

``

"I checked by typing separately. It works as below."

``

``

a1 := arrow([-cos(theta1), -sin(theta1)], color = "LightBlue")

 

``ainput := arrow([-1, 0], color = "Red")

 

"But the copied from your code does not work."

"ainput:=arrow([-1, 0],color= "`Red"`)"

Error, unable to delimit strings/identifiers

"ainput:=arrow([-1, 0],color= "`Red"`)"

 

``


 

Download forScotgould_Error_arrow.mw

Hi,

 

I have two functions that I took the inetgral of their product (1.3 and 1). Then i multiplied the resulting naswer with the variable and integrates again however the inetgral did not evaluate (3,4, and 5). 

I was able to calculate both inegrals using tables of integrals, MATLAB & Mathematica were able to evaluate.

any insights on why this may happening?

Integrals_Sheet2.mw

Hi,

 

I am trying to use Maple to evaluate the recursion series as below, but I am getting an error when I try to call c: Error, (in depends) too many levels of recursion

Recursion.mw

 


 

 

b := proc (k) options operator, arrow; (-1)^k*GAMMA(1+(1/2)*k)^2/factorial(k) end proc

proc (k) options operator, arrow; (-1)^k*GAMMA(1+(1/2)*k)^2/factorial(k) end proc

(1)

c := proc (k) options operator, arrow; piecewise(k = 0, b(0)^N, 1 <= k, (sum((q*(N+1)-k)*b(q)*c(k-q), q = 1 .. k))/(k*b(0))) end proc

proc (k) options operator, arrow; piecewise(k = 0, b(0)^N, 1 <= k, (sum((q*(N+1)-k)*b(q)*c(k-q), q = 1 .. k))/(k*b(0))) end proc

(2)

b(2)^N

(1/2)^N

(3)

c(1)

Error, (in depends) too many levels of recursion

 

 

F := proc (s, kmax, N) options operator, arrow; sum(c(k)*s^k, k = 0 .. kmax) end proc

proc (s, kmax, N) options operator, arrow; sum(c(k)*s^k, k = 0 .. kmax) end proc

(4)

powcreate(c(k) = (sum((q*(N+1)-k)*b(q)*c(k-q), q = 1 .. k))/(k*b(0)), c(0) = b(0)^N)

Error, (in depends) too many levels of recursion

 

c := rsolve({c(0) = b(0)^N, c(k) = (sum((q*(N+1)-k)*b(q)*c(k-q), q = 1 .. k))/(k*b(0))}, c(k), makeproc)

Error, (in depends) too many levels of recursion

 

c := proc (k) if k = 0 then return b(0)^N else return (sum((q*(N+1)-k)*b(q)*c(k-q), q = 1 .. k))/(k*b(0)) end if end proc

proc (k) if k = 0 then return b(0)^N else return (sum((q*(N+1)-k)*b(q)*c(k-q), q = 1 .. k))/(k*b(0)) end if end proc

(5)

c(1)

Error, (in _factorial) too many levels of recursion

 

F := proc (s, kmax, N) options operator, arrow; sum(c(k)*s^k, k = 0 .. kmax) end proc

proc (s, kmax, N) options operator, arrow; sum(c(k)*s^k, k = 0 .. kmax) end proc

(6)

F(1, 2, 2)

Error, (in unknown) too many levels of recursion

 

NULL


 

Download Recursion.mw

I have this equation 

 

x3l := -(1/2)*g*(f[3]*m[3]+f[2]*(m[2]+m[3])+f[1]*(m[1]+m[2]+m[3]))*tau^2/(m[1]+m[2]+m[3])+x30

 

f_i are Heaviside function of x3l, so I get  recrusive error

how can i avoid it ? 

A fouth order system is described by the differential equation

          (d^4 y)/(dt)^4 + a_3  (d^3 y)/(dt)^3 + a_2  (d^2 y)/(dt)^2 + a_1  dy/dt+ a_0 y(t)=u(t)      

Where y(t) is the output and u(t) is any input

  • Determine the matrix A.
  • Using the condition det[A – λI ]

Determine the eigen values λ.

  • Compute the state transition matrix using maple.

I'm plotting some simple plots such as

plot(frac(x^2/3)*3,x=-5..5, discont=true);

 

Some discontinuities are connected. Using numpoints, resolution, and Digits doesn't help. Sometimes it will produce a plot with no connections but then other times it does. I need a general solution that is simple. Is there any way to refine the quality of discont?

 

discont=[usefdiscont=[bins=35]],

 

I have tried that and it seems to work but I haven't put it through the ringer. Is that all I have?

 

I'm using MAPLE 2019 and I'm sometimes surprised by its behaviour.  For example, I appear to have an example where it evaluates the integral of each of two terms but not their sum...  What's going on?  Please see the attached.

restart

g0 := exp(r*cos(theta))/Pi

exp(r*cos(theta))/Pi

(1)

G0 := `assuming`([int(g0, theta = 0 .. Pi)], [r > 0])

BesselI(0, r)

(2)

g1 := exp(r*cos(theta))*cos(theta)/Pi

exp(r*cos(theta))*cos(theta)/Pi

(3)

G1 := `assuming`([int(g1, theta = 0 .. Pi)], [r > 0])

BesselI(1, r)

(4)

g := g0+g1

exp(r*cos(theta))/Pi+exp(r*cos(theta))*cos(theta)/Pi

(5)

G := `assuming`([int(g, theta = 0 .. Pi)], [r > 0])

int(exp(r*cos(theta))/Pi+exp(r*cos(theta))*cos(theta)/Pi, theta = 0 .. Pi)

(6)

``


 

Download Maplesumint.mw

I wrote a code.mw for a numerical method for a PDE. (You can find the numerical method, exact solution and error between them in the code.)

The method depends on parameters k, M, which are any positive integers, and also depends on teta, beta>-1 which are real numbers.

According to the used method,

when k and M increase, we expect that the error (exact-numeric) generally decreases. 

In the code, I selected k=2, M=2, teta=1 and beta=1. And so k=2, M=2, CPU time is low. Error is not bad.

But for k=4, M=3 and also for bigger values of them, CPU time is high. I can' t get the solution.

Question 1: 

I don't know, but it may be possible to simplify the code in order to calculate for k=4, M=4?

Question 2:

I want to find optimal values of teta and beta for minimizing the error between numerical and exact solution, when k=2, M=2, or k=3, M=1 etc.

How can we write a Maple code for finding optimal values of teta and beta?

You can download the code.mw

 

 

 
 
 
 
 

Hello, I'm using free 15 day trial Maple 2019.2 on my Macbook (Macos 10.15.3).

I can't work Maple. I enter some inputs (2+3) and press enter. It works. But when I write plot, version(), f, sin.. or something else it didn't works. And no response. When I click enter, nothind happen. What is the problem? Please help me.. 

   I download one  file about  all 5 connected graphs with graph6  (total 21 graphs). format from http://users.cecs.anu.edu.au/~bdm/data/graphs.html,and I want to import it in Maple. Since platform restrictions , I can not attach the file .   Please download it by yourself,very thanks to you ! 

   I put the file  in the installation path of  Maple in my computer:D:\\ Program Files\Maple 2019. (my computer system is Window 10 )  And I import it like following: 

  But it  only imports the graph of  the first row in the file. How to import all graphs in a file of graph6 format one time?

 

I get quite an annoying "bug" that messes up all the presentation aspect of my document.

I want to assume some variable is real so that calculation are simplified at several parts of the document.

 

But I get this:

 

Whener I use U__LL I always end up with this ugly form that would make anybody think U__LL is multiplied by itself.

How do I get around this?

I'd like to populate a listbox from elements of a matrix, but need some help.

I created an empty listbox with name ListBox0, and try to add a name from the matrix.

DataSet := Matrix(3, 3, [[Tim, 21, 80], [Tom, 23, 86], [Tinker, 25, 90]])

with*DocumentTools

SetProperty("ListBox0", DataSet[1, 1])

Hi,

I want to optimize a function f(g(e(x),x))  where g(x) is interpolated and e(x) is not known when the interpolation object is created. I found the intpolation Methods of Maple 2018 very helpful to quickly change the inpterpolation method.

Unfotunately the optimization fails when the interpolation object receives an expression as input.

It works if I just use x. Do you know my the first approach fails?

Is there maybe a way to convert the interpolation object to a piecewise function?

 

Thank you for your help
 

# Optimize with Interpolation Object


points :=  <<0.4000|  10.0000>,
            <0.7000|   10.0000>,
            <1.0000|   10.0000>,
            <0.3000|   30.0000>,
            <0.4000|   30.0000>,
            <0.5000|   30.0000>>;

Data := <0617,0767,0220,0444,0692,0789>*0.001;

intmethod := LinearInterpolation;

g := Interpolation[intmethod](points(1..-1,1),Data):

Matrix(6, 2, {(1, 1) = .4000, (1, 2) = 10.0000, (2, 1) = .7000, (2, 2) = 10.0000, (3, 1) = 1.0000, (3, 2) = 10.0000, (4, 1) = .3000, (4, 2) = 30.0000, (5, 1) = .4000, (5, 2) = 30.0000, (6, 1) = .5000, (6, 2) = 30.0000})

 

Vector[column](%id = 18446884324022199230)

 

LinearInterpolation

(1)

plot(g(x),x=0..1)

 

e := x/sqrt(2);

(1/2)*x*2^(1/2)

(2)

f := 5+g(e)*x^2

"5+(module() ... end module)(module() ... end module,1/2 x sqrt(2)) x^2"

(3)

f_simple := 5+g(x)*x^2

"f_simple:=5+[[["a linear interpolation object"],["with 6 points in 1-D"]]](x) x^2"

(4)

op_f := Optimization[Minimize](f(x),x=0 .. 1);

Error, (in Optimization:-NLPSolve) non-numeric result encountered

 

op_f_simple := Optimization[Minimize](f_simple(x),x=0 .. 1);

[HFloat(4.999979117244145), [x = HFloat(0.028901647183245588)]]

(5)

 

NULL


 

Download convert_interpolation_object.mw

 

 

I received an (automated) email, which called attention to an update.

Where can I find the update?

Thank you, Jan Drösler

 

First 425 426 427 428 429 430 431 Last Page 427 of 2261