Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'my Mathematica code' topicStudent Support Forum > General > "my Mathematica code"

Next Comment >Help | Reply To Topic
Author Comment/Response
Vedat Suat ERTURK
11/24/08 07:00am

Hello ,

It takes too much time to run the following code.
Is there any way to speed it's running?
Thank you in advance.

Vedat
+++++++++++++++++++++++++++++++++++++++++++++
n = 25;
Y[0] = 0;
Y[1] = 1;
Y[2] = a;
Y[3] = b;
δ = Function[t, If[t == 0, 1, 0]];
Z[k_] := Exp[-4*Y[0]] /; k == 0
Z[k_] := -4*Sum[((m + 1)/k)*Y[m + 1]*Z[k - m - 1], {m, 0, k - 1}] /; k >= 1
F[k_] := 12*δ[k]
G[k_] := δ[k] + 4*δ[k - 1] + 6*δ[k - 2] + 4*δ[k - 3] + δ[k - 4]
H[k_] := (1/G[0])*(F[k] - Sum[H[m]*G[k - m], {m, 0, k - 1}])
For[k = 0, k <= n, ++k,
Y[k + 4] = Expand[(6*Z[k] - H[k])/((k + 1)*(k + 2)*(k + 3)*(k + 4))]; ]
sol = FindRoot[{Sum[Y[k], {k, 0, n}] == Log[2], Sum[k*Y[k], {k, 0, n}] ==
0.5}, {a, -(1/2)}, {b, 1/3}];
a = sol[[1,2]];
b = sol[[2,2]];
y = Function[x, Sum[Y[k]*x^k, {k, 0, n}]];
y[x]

Attachment: Example1.nb, URL: ,

Subject (listing for 'my Mathematica code')
Author Date Posted
my Mathematica code Vedat Suat E... 11/24/08 07:00am
Re: my Mathematica code yehuda ben-s... 11/27/08 04:22am
Next Comment >Help | Reply To Topic