MaplePrimes Questions

Suppose we want to compute the following derivate:

x := [x__1, x__2, x__3]

f := [x__1]

Gradf := Matrix(1, 3, (i,j) -> diff(f[i], x[j]));

Gradf2 := Matrix(3, 3, (i,j) -> diff(Gradf[i], x[j]));

 

my question is how to convert Gradf from [1  0 0] to [1,0,0]?

 

Hello there, 

Would you allow me to ask this question?

What I tried in the worksheet below is to map an expression to x-axis and another expression to y-axis, while both expressions have the same input (or independent variable). However, the resulting plot still shows those two expressions as two separate curves. Would you tell me how to map or assign the expressions to each axis?


 

restart;

with(LinearAlgebra):

Digits := 6:

j := I:

L__adpu := 1.66;
L__aqpu := 1.61;
L__lpu := 0.15;
R__apu := 0.003;
E__tpu := 1.0;
MVA := 555;

1.66

 

1.61

 

.15

 

0.3e-2

 

1.0

 

555

(1)

A__sat := 0.0312500:
B__sat := 6.93147:

I__tpu_compare := (P__t - j* Q__t) / E__tpu;

-(1.00000*I)*Q__t+1.00000*P__t

(2)

I__tpu_a := abs(I__tpu_compare);

abs(-(1.00000*I)*Q__t+1.00000*P__t)

(3)

Phi := arccos(P__t / (I__tpu_a * E__tpu));

arccos(1.00000*P__t/abs(-(1.00000*I)*Q__t+1.00000*P__t))

(4)

E__a__tilde := E__tpu + (R__apu + j * L__lpu) * I__tpu_compare;

1.0+(0.3e-2+.15*I)*(-(1.00000*I)*Q__t+1.00000*P__t)

(5)

psi__at := abs(E__a__tilde);

abs(1.0+(0.3e-2+.15*I)*(-(1.00000*I)*Q__t+1.00000*P__t))

(6)

psi__I := A__sat * exp(B__sat * (psi__at - 0.8));

0.312500e-1*exp(6.93147*abs(1.0+(0.3e-2+.15*I)*(-(1.00000*I)*Q__t+1.00000*P__t))-5.54518)

(7)

K__sd := psi__at / (psi__at + psi__I);

abs(1.0+(0.3e-2+.15*I)*(-(1.00000*I)*Q__t+1.00000*P__t))/(abs(1.0+(0.3e-2+.15*I)*(-(1.00000*I)*Q__t+1.00000*P__t))+0.312500e-1*exp(6.93147*abs(1.0+(0.3e-2+.15*I)*(-(1.00000*I)*Q__t+1.00000*P__t))-5.54518))

(8)

K__sq := K__sd;

abs(1.0+(0.3e-2+.15*I)*(-(1.00000*I)*Q__t+1.00000*P__t))/(abs(1.0+(0.3e-2+.15*I)*(-(1.00000*I)*Q__t+1.00000*P__t))+0.312500e-1*exp(6.93147*abs(1.0+(0.3e-2+.15*I)*(-(1.00000*I)*Q__t+1.00000*P__t))-5.54518))

(9)

X__ad := K__sd * L__adpu:

X__d := X__ad + L__lpu:

X__aq := K__sq * L__aqpu:

X__q := X__aq + L__lpu:

delta__i := arctan((X__q * I__tpu_a * cos(Phi) - R__apu * I__tpu_a * sin(Phi))/(E__tpu + R__apu * I__tpu_a * cos(Phi) + X__q * I__tpu_a * sin(Phi))):

e__q := E__tpu * cos(delta__i):

i__d := I__tpu_a * sin(delta__i + Phi):

i__q := I__tpu_a * cos(delta__i + Phi):

i__fd := (e__q + R__apu * i__q + X__d * i__d)/(X__ad):

i_armature := sqrt(i__d^2 + i__q^2):

i_armature2 := subs(P__t = 0, i_armature):

i_armature3 := subs(P__t = 0.5, i_armature):

i_armature4 := subs(P__t = 1.0, i_armature):

plotA := plot(i_armature2, Q__t = -0.6..0.6):

plotB := plot(i_armature3, Q__t = -0.6..0.6):

plotC := plot(i_armature4, Q__t = -0.6..0.6):

plots:-display([plotA, plotB, plotC]);

 

i__fd2 := subs(P__t = 0, i__fd):

i__fd3 := subs(P__t = 0.5, i__fd):

i__fd4 := subs(P__t = 1.0, i__fd):

 

plotD := plot(i__fd2, Q__t = -0.6..0.6):

plotE := plot(i__fd3, Q__t = -0.6..0.6):

plotF := plot(i__fd4, Q__t = -0.6..0.6):

plots:-display([plotD, plotE, plotF]);

 

plot([i__fd2, i_armature2, Q__t = -0.6..0.6]); #failed, two expressions are plotted seperately.

 

 

 


Best Regards, 

In Kwon Park 

Download Q20210416.mw

What is the reason for the warning?

restart;
f := (x, y, z) -> 1 - x^4 + ln(x^4) + z^4 - y^4 - y^4*(ln(z^4) - ln(y^4));


with(Optimization);
Minimize(f(x, y, z), {x^2 + y^2 - z^2 - 1 = 0, 0 <= x - 1, 0 <= y - x, 0 <= z - y});
Warning, no iterations performed as initial point satisfies first-order conditions
                 [0., [x = 1., y = 1., z = 1.]]

Suppose we have a state vector x=[x_1,y_1,theta_1,x_2,y_2,theta_2] and a vector field f=[cos(theta_1),sin(theta_1),0,0,0,0]

How we can define a vector field with 6 dimentions?

with(VectorCalculus);
f := VectorField([cos(theta__1),sin(theta__1),0,0,0,0],'cartesian ??? '[x__1,y__1,z__1,x__2,y__2,z__2]);

I need to compute the Jacobian of f wrt x:

Jacobian(f, [x_1,y_1,theta_1,x_2,y_2,theta_2]

In an answer to an earlier question

https://mapleprimes.com/questions/232067-Error-Invalid-Neutral-Operator

I inadvertently used the "Insert Contents" link - AND IT WORKED

Anybody know how long this has been fixed?

Dear all

How can I plot vector using maple

Maple return the following error

Error, invalid neutral operator
plotvector.mw

Thank you

In trying to create a plot that shades the region between two concentric circles, I decided to try using the Picture procedure found here: https://www.mapleprimes.com/posts/145922-Perimeter-Area-And-Visualization-Of-A-Plane-Figure-

This is as far as I got.


 

"Picture := proc (L, C, N::posint := 100, Boundary::list := [linestyle = 1])    local i, var, var1, var2, e, e1, e2, P, Q, h;    global Border;    for i to nops(L) do    if type(L[i], listlist(algebraic)) then P[i] := op(L[i]) else    var := lhs(L[i, 2]); var1 := lhs(rhs(L[i, 2])); var2 := rhs(rhs(L[i, 2])); h := (var2-var1)/N;    if type(L[i, 1], algebraic) then e := L[i, 1];    if nops(L[i]) = 3 then P[i] := seq(subs(var = var1+h*i, [e*cos(var), e*sin(var)]), i = 0 .. N) else    P[i] := seq([var1+h*i, subs(var = var1+h*i, e)], i = 0 .. N) end if else    e1 := L[i, 1, 1]; e2 := L[i, 1, 2]; P[i] := seq(subs(var = var1+h*i, [e1, e2]), i = 0 .. N) end if end if    end do;    Q := [seq(P[i], i = 1 .. nops(L))];    Border := plottools[curve]([op(Q), Q[1]], op(Boundary));    [plottools[polygon](Q, C), Border];    end proc:"

L := [[3, t = 0 .. 2*Pi, polar], [2, t = 0 .. 2*Pi, polar]]; plots[display](Picture(L, color = yellow, [color = brown, thickness = 3]), scaling = constrained, view = [-4 .. 4, -4 .. 4])

 

NULL


Clearly, this is not what I want. I am probably missing something simple here. How can I get only the region between the two circles to be shaded?

Download shading_annular_regions.mw

 

 

 

Hello friends
PLEASE HELP 

I have the following issue 

I want to make one plot with specific values of argument 

here is an example of 2d plot ,


what i want is to plot the same graph only with specific values of x for example x =-pi..pi/2  , -pi/4..pi/4  and so on 

but this has to be in one plot , could please tell me the options how I can manage this problem .  

 

At the end its a 3Dplot , x is a function of y and t  

so actually i want to make 3d plot in a different ares of y and t 

something like this plot3d(u ,x=-1..1,t=-1..1 , x=2..3 , t=2..3 .... ) 
or maybe in opposite way ,to restrict some values of x and t 

( idea is that function is periodic but I dont want to get crazy high values of the function, especially where functuon goes to infinity  ) 

PLEASE HELP 

thank you very much in advance 

Hi

 

Can anyone please help me Ive been stuck on this program for ages and cant see what I'm doing wrong?

Here is the code:

restart;
randomize();
npaths := 10;
nsteps := 1;
S0 := 100.0;
K := 100;
T := 0.25;
r := 0.05;
sig := 0.15;
lambda := 0.1;
a := -0.9;
nu := 0.45;
m := exp(a + (0.5*nu)*nu);
mu := r - (m - 1.0)*lambda;
dt := T/nsteps;
with(Statistics);
N := RandomVariable(Poisson(lambda*dt));
Z := RandomVariable(Normal(0, 1));
                           1059210787

                            K := 100

                           T := 0.25

                           r := 0.05

                          sig := 0.15

                         

Xsum:=0.0: #`Initialise sum of payoffs over all paths` Asum:= 0.0:   for i from 1 to npaths do    S[0]:=S0 : #` initialise`   lnS:=ln(S[0]):    Stot := 0.0:    for i from 1 to nsteps do  N1:=Sample(N,1)[1]: #` sample number from poisson distribution`  Z1:=Sample(Z,1)[1]: #` sample number from normal distribution`   dlnS:=r*dt+(mu-r)*dt-0.5*sig^(2)*dt+N1*ln(m)-0.5*nu^(2)*N1+sqrt(sig^(2)*dt+nu^(2)*N1) *Z1: #` Joshi 15.12`   lnS:=lnS+dlnS:  #print(cal,N1*ln(m)-0.5*nu^(2)*N1);  S[i]:=exp(lnS):  Stot:= Stot + S[i]:     end do:    #`European Call Option (Parrott)`  X1:=max(0.0,K-S[nsteps]):  Xsum:=Xsum+X1:    #`Asian Call Option`  Save := Stot/(nsteps):  A1 :=max(0.0, K-Save):  Asum := Asum + A1:     if(k mod 10 = 0) then print (k, Euro Call,X1, Asian  Call, A1)end if:   if (k=1) then Sp1:=copy(S) end if:   if (k=2) then Sp2:=copy(S) end if:   if (k=3) then Sp3:=copy(S) end if:     end do:    #`Euro Call`  X0:=exp(-r*T)*(  Xsum)/(npaths);   print("Euro call price at t=0",X0, "actual",3.1490);       #`Asian Call`  A0:=exp(-r*T)*(  Asum)/(npaths);   print("Asian call price at t=0",X0, "actual", A0);   #`Plot of three sample paths: to generate decent looking paths, set npaths=3, and nsteps=1000 above and rerun`    data1:=[seq([ i*dt,Sp1[i]],i=0..nsteps)]:  data2:=[seq([ i*dt,Sp2[i]],i=0..nsteps)]:  data3:=[seq([ i*dt,Sp3[i]],i=0..nsteps)]:  plot([data1,data2,data3]);               ;

 

The errors i get are unterminated loop and parse.

 

Thank you
 

Hello friends,

I'm trying to get the exact result from the following operation:

I'm getting:

for i=0,

for i=1,

for i=2,

I want to get:

for i=0, 1

for i=1, -1/2 + sqrt(3)/2 i

for i=2, -1/2 - sqrt(3)/2 i

Thanks for the light.

Maple has issues integrating products of Bessel functions over an infinite range, and in fact, this extends to trig functions. The integrals in the attached should return as delta functions but don't. 

Spherical_Bessel_identity.mw

Is there like https://oeis.org/   Library available in maple for enumerate in for loop?

i would like to like shift 9 times and create 100 mapping for each sequence 

Hello Users!

I want to assign some specific names of elements in a vector A:

A:=Vector[row](19, {(1) = 14.9057064333276, (2) = 14.4384716751962, (3) = 14.0155569170648, (4) = 13.6381346589334, (5) = 13.3075724008020, (6) = 13.0254476426706, (7) = 12.7935628845392, (8) = 12.6139606264079, (9) = 12.4889383682765, (10) = 12.4210636101451, (11) = 12.4131888520137, (12) = 12.4684665938823, (13) = 12.5903643357509, (14) = 12.7826795776196, (15) = 13.0495548194882, (16) = 13.3954925613568, (17) = 13.8253703032254, (18) = 14.3444555450940, (19) = 14.9584207869626});

like

y[1,1]:=14.9057064333276;

y[1,2]:=14.4384716751962;

y[1,3]:=14.0155569170648;

...

y[1,19]:=14.9584207869626;

Later, I have to use y[1,1], y[1,2],...,y[1,19] for further calculations. I used op command but it does not work. Please help me how I can assign the name. 

I am waiting for your respone. Thanks in advance.

when I define piecwise function as

f := x -> piecewise(0 <= t, 1, t < 0, t - 1)

and I define his antiderivative

F := x -> int(f(t), t = 1 .. x)

F(x)

Maple gives

x - 1

which is obviously wrong (but I guess it's ok only for x=>0)

what to do to be correct?

f := n->local p := round(n) mod 2; 1/2 + (-1)^p/n/2^p;
f := proc (n) options operator, arrow; `if`(1 < modr(n-1/2, 2),

   1/2+1/n, 1/2-(1/2)/n) end proc


     f := proc (n) local p; options operator, arrow; p :=

f := n->local p := round(n) mod 2; 1/2 + (-1)^p/n/2^p;

f~([$1..10]);

Correct plot
plot('f'(n),n=1..10,0..1);

 

Wrong plot

plot(f(n),n=1..10,0..1);

 

Can someone explain why I have to put ' ' around f to get the right plot? Clearly it has something to do with round and/or mod. Why does maple have this stupid issues? Cause it seems like it is very error prone. I know it's wrong only cause I know what to expect.

First 296 297 298 299 300 301 302 Last Page 298 of 2308