Gianluca, I thank you very much, all funktionetes!
|
|
|
This variant with delayed definition seems faster:
With[{n = 20000}, EX = RandomReal[{0, 1}, n];
AX = RandomReal[{0, 1}, n];
BX = RandomReal[{0, 1}, n];
CX = RandomReal[{0, 1}, n];
DX = RandomReal[{0, 1}, n];
FX[f_, g_] := Most@FoldList[#1 + 2 (f/g)*(#2 - #1) &, EX[[1]], EX];
Manipulate[
ListLinePlot[a*(AX - b) + c*BX + d*CX + f*(DX - FX[f, g]),
Frame -> True, PlotRange -> All, ImageSize -> 1000], {{g, 5}, 5,
700, 1}, {{f, 1}, 1, 20, 0.01}, {{a, 0.}, 0, 500, 1}, {{c, 0.}, 0,
5, 0.01}, {{b, 0.}, -0.1, 0.1, 0.001}, {{d, 400.}, 400, 800, 5}]]
Check out my use of Most, which may not be what you mean.
|
|
|
I would use FoldList to build your FX. For vectors of length 1000 the following is not too slow:
With[{n = 1000},
EX = RandomReal[{0, 1}, n];
AX = RandomReal[{0, 1}, n];
BX = RandomReal[{0, 1}, n];
CX = RandomReal[{0, 1}, n];
DX = RandomReal[{0, 1}, n];
FX[f_, g_] =
Most@FoldList[Expand[#1 + 2 (f/g)*(#2 - #1)] &, EX[[1]], EX];
Manipulate[
ListLinePlot[a*(AX - b) + c*BX + d*CX + f*(DX - FX[f, g]),
Frame -> True, PlotRange -> All, ImageSize -> 1000], {{g, 5}, 5,
700, 1}, {{f, 1}, 1, 20, 0.01}, {{a, 0}, 0, 500, 1}, {{c, 0}, 0, 5,
0.01}, {{b, 0}, -0.1, 0.1, 0.001}, {{d, 400}, 400, 800, 5}]]
|
|
|
Thanks for your interesting variant. It really works for n=1000, but for 15000-20000 it's running until now... I've just noted (f/g) is marked with dark blue and not light blue as all constants. So if I give values for f and g it works. But I want to manipulate these parameters.
Attachments:
|
|
|
Good morning Hans (I am from Germany too), thank you for your help. RSolve and even RecurrenceTable doesn't work (error; s. Attachments). If I use RecurrenceTable for Length about 20000 an error message arises.
Attachments:
|
|
|
Good morning Leo (here it is about 11 am), perhaps this will help you a bit:
In[21]:= RSolve[{F1X[i] == F1X[i - 1] + 2 f/g (E1X[i - 1] - F1X[i - 1]), F1X[1] == E1}, F1X[i], i]
To get rid of the somewhat annyoing K[1]
RSolve[{F1X[i] == F1X[i - 1] + 2 f/g (E1X[i - 1] - F1X[i - 1]), F1X[1] == E1}, F1X[i], i] /. K[1] -> j
and even a bit more simplified
RSolve[{F1X[i] == F1X[i - 1] + 2 f/g (E1X[i - 1] - F1X[i - 1]), F1X[1] == E1}, F1X[i], i] //. {-g Sum[XX_, YY_] :> Sum[g XX, YY],
K[1] -> j}
Attachments:
|
|
|
It's a nice idea. But how do I define j?
|
|
|
hmmmm. perhaps you can construct a function of a, b, ... for each i. a * (AX - b) + BX * c + d * CX is I think sort of linear in a, b, c, ... Now look af FFX. Each component seems to be a polynomial in f / g. perhaps one can figure out a recursion relation for ( f / g )^j for each j. In this case you could avoid the really big tables....?
|
|
|
I think your construction of FX ist not the real thing. What about ( with EX = {3, 6, 4, 8} for example )
FX[1] = EX[[1]];
FX[i_] := FX[i - 1] + 2 f/g (EX[[i - 1]] - FX[i - 1])
Which yields
In[10]:= FFX =
Table[FX[i + 1] = FX[i] + 2 (f/g)*(EX[[i]] - FX[i]), {i, 1, Length[EX]}] // Simplify
Out[10]= {3, 3 + (6 f)/g, 3 - (12 f^2)/g^2 + (8 f)/g, 3 + (24 f^3)/g^3 - (28 f^2)/g^2 + (18 f)/g}
and try your ListlinePlot with FFX (but don't use the definitions of FX in the Manipulate Object)
|
|
|
Hey Hans, thank you so much for your quick reply!
You're right - it works if "i" is not so large. But in my case "i" equates about 20000 and Mathematica is always running...
|
|
|
Reply to this discussion
in reply to
|