Items tagged with syntax

Feed

Hi I was wondering if you can help me with some maple commands about using Euler's method. My professor created a tutorial on using some commands to calculate the value via Euler's method. 

Her commands in the tutorial for using Euler's method  for a differential equation- dy/dx= x+y   y(0)=1

x0:=0:y0:=1:xf:=1:n:=10:

h:=evalf((xf-x0)/n);

f:=(x,y) -> x+y

x:=x0:y:=y0:

This next step confuses me the most, my professor uses this syntax to compute the values of approximation via Euler's method. N represents the number of pieces we want to approximate the value with. X0 is initial and XF is final. 

forifrom1tondo k:=f(x,y):y:=y+h*k:x:=x+h:print(x,y):od:

I tried replicating this syntax on the exact same problem, copying the syntax commands word for word. Yet, I keep getting the same error "unable to parce" error, with the "od" being highlighted. But on her tutorial, it gave her an two columns with the intervals (n) and all it's values. She even did the same did for only wanting 1 loop printed 

forifrom1tondo k:=f(x,y):y:=y+h*k:x:=x+h:od:print(x,y):.   And it gave her only 1 loop.

I tried both and still got the error. Please Help, Thanks in advance

 helo my friends,

i try to do this code, please help me to understant what is the problem

מציג את image.png

I am tying to compute the wronskian of a fourth order DE: y=C1e2x+ C2e-x +C3xe-x+ C4x2e-x Here's what I did:

with(VectorCalculus):
with(LinearAlgebra):

Determinant(Wronskian([e^(2*x), e^(-x), xe^(-x), x^2*e^(-x)], x)):

which gave nothing.
Can anyone please help?

Thanks in advance,

AJ

I can't get the Real and Imaginary parts of matrix to seperate out as required. It is an SU(2) matrix. Want to convert is to a 4 Vector (quaternion). I think because Maple doesnt know what psi(t) is being conservative so to speak. Tried assume, assuming...
 

restart

assume*{psi(t), 'real'}

assume*{real, psi(t)}

(1)

V := Matrix(2, 2, {(1, 1) = (1/4)*cos((1/2)*psi(t))*sqrt(2)*sqrt(4-2*sech((1/6)*sqrt(3)*t))-I*cos((1/2)*psi(t))*sqrt(2)*tanh((1/6)*sqrt(3)*t)/sqrt(4-2*sech((1/6)*sqrt(3)*t))-((1/2)*I)*sin((1/2)*psi(t))*sqrt(2)*sqrt(3)*sech((1/6)*sqrt(3)*t)/sqrt(4-2*sech((1/6)*sqrt(3)*t)), (1, 2) = (1/2)*cos((1/2)*psi(t))*sqrt(2)*sqrt(3)*sech((1/6)*sqrt(3)*t)/sqrt(4-2*sech((1/6)*sqrt(3)*t))+((1/4)*I)*sin((1/2)*psi(t))*sqrt(2)*sqrt(4-2*sech((1/6)*sqrt(3)*t))-sin((1/2)*psi(t))*sqrt(2)*tanh((1/6)*sqrt(3)*t)/sqrt(4-2*sech((1/6)*sqrt(3)*t)), (2, 1) = ((1/4)*I)*sin((1/2)*psi(t))*sqrt(2)*sqrt(4-2*sech((1/6)*sqrt(3)*t))+sin((1/2)*psi(t))*sqrt(2)*tanh((1/6)*sqrt(3)*t)/sqrt(4-2*sech((1/6)*sqrt(3)*t))-(1/2)*cos((1/2)*psi(t))*sqrt(2)*sqrt(3)*sech((1/6)*sqrt(3)*t)/sqrt(4-2*sech((1/6)*sqrt(3)*t)), (2, 2) = ((1/2)*I)*sin((1/2)*psi(t))*sqrt(2)*sqrt(3)*sech((1/6)*sqrt(3)*t)/sqrt(4-2*sech((1/6)*sqrt(3)*t))+(1/4)*cos((1/2)*psi(t))*sqrt(2)*sqrt(4-2*sech((1/6)*sqrt(3)*t))+I*cos((1/2)*psi(t))*sqrt(2)*tanh((1/6)*sqrt(3)*t)/sqrt(4-2*sech((1/6)*sqrt(3)*t))})

Matrix(%id = 18446744074495800014)

(2)

``

``

v := Vector(4, [Re(V[1, 1]), Im(V[1, 2]), Re(V[2, 1]), Im(V[1, 1])])

Vector[column](%id = 18446744074531387982)

(3)

``


 

Download extract_R_and_I.mw

Where I made a mistake I got this error in for loop and how to fix it?


 

restart

Error, invalid input: with expects its 1st argument, pname, to be of type {`module`, package}, but received shareman

 

N := 5:

c__1 := Matrix([[c1__11, c1__12, 0], [c1__12, c1__22, 0], [0, 0, c1__66]]):

c__2 := Matrix([[c2__11, c2__12, 0], [c2__12, c2__22, 0], [0, 0, c2__66]]):

c__3 := Matrix([[c3__11, c3__12, 0], [c3__12, c3__22, 0], [0, 0, c3__66]]):

c__4 := Matrix([[c4__11, c4__12, 0], [c4__12, c4__22, 0], [0, 0, c4__66]]):

c__5 := Matrix([[c5__11, c5__12, 0], [c5__12, c5__22, 0], [0, 0, c5__66]]):

NULL

Q := Array(1 .. 3, 1 .. 3, 1 .. N):

A := Matrix([[0, 0, 0], [0, 0, 0], [0, 0, 0]]):

Z := Matrix([[h__1], [h__2], [h__3], [h__4], [h__5], [h__6]]):

for ii to 3 do for jj to 3 do Q(ii, jj, 1) := c__1(ii, jj); Q(ii, jj, 2) := c__2(ii, jj); Q(ii, jj, 3) := c__3(ii, jj); Q(ii, jj, 4) := c__4(ii, jj); Q(ii, jj, 5) := c__5(ii, jj) end do end do

"for i from 1  to 3 do for j from 1 to 3 do Ar:=0:for k from 1 to N do  Ar:=(Q (i,j,k)*(Z(k+1)-Z(k)))+Ar: end do A(i,j):=Ar: end do end do"

Error, invalid loop statement termination

"for i from 1  to 3 do for j from 1 to 3 do Ar:=0:for k from 1 to N do Ar:=(Q (i,j,k)*(Z(k+1)-Z(k)))+Ar: end do A(i,j):=Ar: end do end do"

 

``

``


 

Download quest.mw

i got this code, but for any n = 2N (par) i get some high errors, my M goes nuts.  anyone knwos wheres my mistake?

With(CurveFitting); Digits; 5; f := proc (x) options operator, arrow; abs(x) end proc; n := 8; h := 2/n; for i from 0 to n do x[i] := h*i-1 end do; for i from 0 to n-1 do L[i] := (product((x-x[j])/(x[i]-x[j]), j = 0 .. i-1))*(product((x-x[k])/(x[i]-x[k]), k = i+1 .. n-1)) end do; lagr := sum(f(x[p])*L[p], p = 0 .. n-1); P := expand(lagr); plot({P, f(x)}, x = -1 .. 1, y = 0 .. 2); M := maximize(abs(abs(x)-P), x = -1 .. 1); M1 := numapprox:-infnorm(abs(abs(x)-P),

x = -1 .. 1)

 

Thanks in advance

I was trying to solve a system of ODE using Maple, but to my surprise, Maple recognizes diff((phi(t), t)) as a variable which is different than t. 

My code is as following:

dsys := {2*m1*(a+l*sin(phi(t)))^2*(diff(diff(theta(t), t), t))+4*m1*(a+l*sin(phi(t)))*l*cos(phi(t))*(diff(theta(t), t))*(diff(phi(t), t)) = M, 2*m1*l^2*(diff(diff(phi(t), t), t))+4*m2*l^2*sin(2*phi(t))*(diff(phi(t), t))*(diff(phi(t), t))+4*m2*l^2*sin(phi(t))^2*(diff(diff(phi(t), t), t))-2*m1*(a+l*sin(phi(t)))*l*cos(phi(t))*(diff(theta(t), t))*(diff(theta(t), t))-2*m2*l^2*(sin(2*phi(t)))(diff(phi(t), t))*(diff(phi(t), t)) = -(2*(m1+m2))*g*l*sin(phi(t))-2*k*l^2*sin(2*phi(t)), phi(0) = 0, theta(0) = 0, (D(phi))(0) = 0, (D(theta))(0) = 0}

subs({M = 10, a = .5, g = 9.81, k = .1, l = .5, m1 = 10, m2 = 1}, dsys);

dsn1 := dsolve(dsys, numeric)

The error I got was Error, (in dsolve/numeric/process_input) input system must be an ODE system, got independent variables {t, diff(phi(t), t)}

I don't get why this is happening. Could you show me what's going on?

Please Sir/Ma, I'm trying to generate a recurrent relations of this series and I try to use "if" "else" condition but I didn't get it right. Any one with useful suggestions. Appreciate 

 

restart;
Y[0] := A; Y[1] := B;
if k = a then delta(k-a) := 1 else 0 end if;
                               0
for k from 0 to 10 do Y[k+2] := solve(add(delta(i-1)*(k-i+1)*(k-i+2)*Y[k-i+2], i = 0 .. k)+add((delta(i)-delta(i-1))*(k-i+1)*Y[k-i+1], i = 0 .. k)+lambda*Y[k] = 0, Y[k+2]) end do;
y := sum(Y[j]*x^j, j = 0 .. 10);
 

Hello, I have a function defined as

                                                   g :=  (x, y)->diff(u1(x, y), x, x)+diff(u2(x, y), x, y). 

I want to define another function as follows

                                                           f :=  (y) ->subs(x = 0, g(x, y)) ,

Now, when I want to calculate numerical values for the new function f(0), f(0.1), f(0.2),..... and so on. The following massage appear

Error, (in f) invalid input: diff received 0, which is not valid for its 2nd argument.

What is the problem here.

Amr
 

 

 

HI, I'm new to maple and am having trouble taking partial derivitives. I couldn't find anything in the documentation that seemed to resolve the situation, and can't be the first person to stumble through this part of Maple.

Namely, it seems like the exponential function causes an extra "ln()" term to show up in the solution. I've tried with e^(y) and exp^(y) but nothing seems to be working. When i use the same markup up in wolfram and matlab and Ti-CAS i get the "correct" solution.

I attached a screen showing my input and output.

thanks for any insight!

 

 

 

Hello,

I'm trying to solve a system of 9 ODE in a model of a chemical reactor. But, unfortunately, when I try to plot the curves, I get the following error message: Error, (in f) unable to store '[Float(undefined)]+8.5809018712796' when datatype=float[8]

Can anyone help me please? I read some related problems here, but couldnt find a solution yet.

Thanks for your time

Best regards

This is what I'm trying to solve:

I literally just want it to plug in those values for n and spit out a value. This is easy enough for me to do by hand, but I obviously wanted to speed up the process by doing it with Maple. What's wrong here? I clicked the pink links and that didn't help.


 

restart

G := 6.6743*10^(-8); 1; R := 1336599.126346; 1; rho := 2.2450*10^14; 1; c := 2.9799*10^10; 1; a := 1/(8/3*(6.67*10^(-8)*Pi*rho/c^2))^.5

0.6674300000e-7

 

1336599.126346

 

0.2245000000e15

 

0.2979900000e11

 

4715700.713/Pi^.5

(1)

y(x) = rho*c((1-(x/a)^2)^(1/2)-(1-(R/a)^2)^(1/2))^2/(3*(1-(R/a)^2)^(1/2)-(1-(x/a)^2)^(1/2))

y(x) = 0.1993516000e36/(3*(1-0.8033593953e-1*Pi^1.0)^(1/2)-(1-0.4496840993e-13*x^2*Pi^1.0)^(1/2))

(2)

``


 

Download y(x).mw

hi

how i can remove this error?

1) ''Error, invalid input: lhs received diff(diff(diff(diff(w(x, y, t), x), x), x), x)+.12*(diff(diff(diff(diff(w(x, y, t), x), x), y), y))+0.11e-2*(diff(diff(diff(diff(w(x, y, t), y), y), y), y))+10-.4*(diff(diff(w(x, y, t), x), x))-0.4e-2*(diff(diff(w(x, y, t), y), y))+diff(diff(w(x, y, t), t), t)-w(x, y, t)-tau, which is not valid for its 1st argument, expr'''''

2)'' Error, incorrect number of extra arguments in select''

thanks

scale.mw
 

 

NULL

restart:Digits := 15: beta := 1: alpha := 0.1: Upsilon := .1: xi := 10: eta := .1: N_X := .4: N_Y := .4: psi:NULL=4.73:tau = 10

tau = 10

(1)

A5 := 1; A6 := 2*alpha^2; A7 := alpha^4; A8 := xi; A9 := xi*alpha^2; A10 := xi*alpha^4; A11 := -N_X; A12 := -N_Y*alpha^2; A13 := 1; A14 := -beta; A15 := -tau

-tau

(2)

EOM := A5*(diff(w(x, y, t), x, x, x, x))+A6*(diff(w(x, y, t), x, x, y, y))+A7*(diff(w(x, y, t), y, y, y, y))+A8(diff(w(x, y, t), x, x, x, x))+A9*(diff(w(x, y, t), x, x, y, y))+A10*(diff(w(x, y, t), y, y, y, y))+A11*(diff(w(x, y, t), x, x))+A12*(diff(w(x, y, t), y, y))+A13*(diff(w(x, y, t), t, t))+A14*w(x, y, t)+A15

diff(diff(diff(diff(w(x, y, t), x), x), x), x)+.12*(diff(diff(diff(diff(w(x, y, t), x), x), y), y))+0.11e-2*(diff(diff(diff(diff(w(x, y, t), y), y), y), y))+10-.4*(diff(diff(w(x, y, t), x), x))-0.4e-2*(diff(diff(w(x, y, t), y), y))+diff(diff(w(x, y, t), t), t)-w(x, y, t)-tau

(3)

BC := w(0, y, t) = 0, (D[1, 1](w))(0, y, t) = 0, w(a, y, t) = 0, (D[1, 1](w))(a, y, t) = 0, w(x, 0, t) = 0, (D[2, 2](w))(x, 0, t) = 0, w(x, b, t) = 0, (D[2, 2](w))(x, b, t) = 0

w(0, y, t) = 0, (D[1, 1](w))(0, y, t) = 0, w(a, y, t) = 0, (D[1, 1](w))(a, y, t) = 0, w(x, 0, t) = 0, (D[2, 2](w))(x, 0, t) = 0, w(x, b, t) = 0, (D[2, 2](w))(x, b, t) = 0

(4)

 

 

BC1:=subs(a=1,b=1,[BC])

[w(0, y, t) = 0, (D[1, 1](w))(0, y, t) = 0, w(1, y, t) = 0, (D[1, 1](w))(1, y, t) = 0, w(x, 0, t) = 0, (D[2, 2](w))(x, 0, t) = 0, w(x, 1, t) = 0, (D[2, 2](w))(x, 1, t) = 0]

(5)

We use the method of multiple scales to directly attack EOM1 and BC1. To transform the time derivatives in EOM1 in terms of the scales  and , we let

timeScales:=T[0],T[1]

T[0], T[1]

(6)

dt[1]:=expr->add(epsilon^i*diff(expr,timeScales[i+1]),i=0..1)

proc (expr) options operator, arrow; add(epsilon^i*(diff(expr, timeScales[i+1])), i = 0 .. 1) end proc

(7)

msForm:={w(x,y,t)=w(x,y,timeScales),seq(diff(w(x,y,t),t$i)=dt[i](w(x,y,timeScales)),i=1..2)}

{diff(diff(w(x, y, t), t), t) = dt[2](w(x, y, T[0], T[1])), diff(w(x, y, t), t) = diff(w(x, y, T[0], T[1]), T[0])+epsilon*(diff(w(x, y, T[0], T[1]), T[1])), w(x, y, t) = w(x, y, T[0], T[1])}

(8)

multiScales:=`union`(map(s->subs(w=s,msForm),[w])[])

{diff(diff(w(x, y, t), t), t) = dt[2](w(x, y, T[0], T[1])), diff(w(x, y, t), t) = diff(w(x, y, T[0], T[1]), T[0])+epsilon*(diff(w(x, y, T[0], T[1]), T[1])), w(x, y, t) = w(x, y, T[0], T[1])}

(9)

Then, we seek a second-order approximate solution in the form

solRule:=w(x,y,timeScales)=add(epsilon^j*w[j](x,y,timeScales),j=1..3)

w(x, y, T[0], T[1]) = epsilon*w[1](x, y, T[0], T[1])+epsilon^2*w[2](x, y, T[0], T[1])+epsilon^3*w[3](x, y, T[0], T[1])

(10)

We introduce the detuning  to describe the nearness of the edge lengths  and , consider the case of primary resonance, and hence let

tau=epsilon^3*tau(x,y)*convert(cos(Omega*T[0]),exp)

tau = epsilon^3*tau(x, y)*((1/2)*exp(I*Omega*T[0])+(1/2)*exp(-I*Omega*T[0]))

(11)

lhs(EOM)

Error, invalid input: lhs received diff(diff(diff(diff(w(x, y, t), x), x), x), x)+.12*(diff(diff(diff(diff(w(x, y, t), x), x), y), y))+0.11e-2*(diff(diff(diff(diff(w(x, y, t), y), y), y), y))+10-.4*(diff(diff(w(x, y, t), x), x))-0.4e-2*(diff(diff(w(x, y, t), y), y))+diff(diff(w(x, y, t), t), t)-w(x, y, t)-tau, which is not valid for its 1st argument, expr

 

Substituting multiScales, solRule, and scaleRule2 into EOM1, expanding the result for small , and discarding terms of order higher than , we obtain

expr83a:=seq(convert(series(value(subs(multiScales,solRule,lhs(EOM))),epsilon,4),polynom),i=1)

Error, invalid input: lhs received diff(diff(diff(diff(w(x, y, t), x), x), x), x)+.12*(diff(diff(diff(diff(w(x, y, t), x), x), y), y))+0.11e-2*(diff(diff(diff(diff(w(x, y, t), y), y), y), y))+10-.4*(diff(diff(w(x, y, t), x), x))-0.4e-2*(diff(diff(w(x, y, t), y), y))+diff(diff(w(x, y, t), t), t)-w(x, y, t)-tau, which is not valid for its 1st argument, expr

 

NULL

NULL

t0 := time(); ST1_like := map(combine, select(has, select(has, ST, sin(m*Pi*x)), sin(n*Pi*y))); time_taken := time()-t0

.187

 

Error, incorrect number of extra arguments in select

 

0.

(12)

``


 

Download scale.mw

 

Hi!

In Maple, is it possible to define an element of a series like that:

a[n] = n^2

(i actually tried to enter := instead of =, but html editor told me its not valid maple expression)

So at any moment i enter a[5] and maple give me 5^2, or a[70] -> 70^2 ?

1 2 3 4 5 6 7 Page 2 of 9