MaplePrimes Questions

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.

I'm trying to lad a comma separated data set and I get an "Invalid minus error".  Neither the filename nor the data set has a minus anywhere in them.  See attached file:  SST Gm Stats.mw  

Download SST_Gm_Stats.mwDownload SST_Gm_Stats.mw

Since I can't upload a .csv file here are its contents:

5248.65,5178.95,5231.01,5161.78,5329.23,5258.52,5311.33,5241.1,5268.2,5198.26,5250.5,5181.03,5348.75,5277.8,5330.79,5260.32,5248.91,5179.21,5231.27,5162.03,5329.49,5258.77,5311.59,5241.35,5268.47,5198.53,5250.77,5181.29,5349.02,5278.06,5331.06,5260.58,5238.16,5168.61,5220.56,5151.47,5318.58,5248.01,5300.72,5230.63,5257.68,5187.88,5240.02,5170.68,5338.06,5267.25,5320.15,5249.81,5238.42,5168.86,5220.82,5151.72,5318.84,5248.27,5300.98,5230.88,5257.95,5188.14,5240.28,5170.94,5338.33,5267.52,5320.41,5250.07,5249.41

Where's the "minus" let alone an invalid one?

John

 

Let's say I have an mpl file and in this file there are several lines $include<~/~/~.mpl> and in some of those called mpl files, there are also some more include lines. And assume the paths of these files are given relative to a specific folder. Now I guess this specific folder has to be mentioned by modifying includepath. But looking at the help pages related to includepath (here and here) I get this sentence "it can be modified by calling kernelopts(includepath)", but I tired typing things like kernelopts(includepath):="C:\\Homes\\testFolder"; and still I see "" for kernelopts(includepath);. How can I tell Maple to look for the files relative to this location either by typing something at the Maple worksheet before typing read("C:\\Home\\testFolder\\main.mpl); or by adding a line at my main mpl file?

Is there a Maple command to obtain a Taylor series and partial sums of exp(A) where A is a square matrix ?

Hi everyone, i want to draw 3d graphics of fractional solution with given by Mittag Leffler function in cantor sets. I want to see like this graphic. I added maple file. Thanks in advance.

3D_graphic.mw3D_graphic.mw

Dear all

I tried to used insert code edit region, to write many subcodes 

but no return varibales names.

example, x:=3;

when I run the code, I get only the number affected to x, I would like to get 

x:=3

No_return_variable.mw

Thank you 

 

 

Dear all

I compute the integral of continuous function but maple return a complexe number. 

continuous_function.mw

A continuous function defined on a closed interval its integral is a number, why maple in my case return a complex number

thank your for your help 

 

Dear all

When I compute 
int( sin(log(x)),x=0..2) 
I obtain an exact value of the integral 
but one I compute 
int( sin(log(x+1)),x=-1..1) 
I obtain undefined integral

The two integrals are the same, using the change of variable z=x+1

Many thinks

Hello everyone!

I'm not experienced user since I am new to maple, right now I am struggling with partial derivatives.

I want to derivative formula L over diff(x(t), t). Im using dot notation.

 

Variable diff(x(t), t) is hidden under the name predkosc_x but using this variable name instead of x(t) with a dot also is not working.

 

What am I doing wrong that I cant derivative over few varaibles?

 

 

 

 

Also when im trying it this way

I also fail

First 416 417 418 419 420 421 422 Last Page 418 of 2427