I want to use a straightforward iteration method to calculate a function which depends on itself at the previous step. It was able to solve it as a recursion function for a small value of steps, but they are far from where I want to go and it takes a long time to solve it.
Maybe you can help me.
The code for the recursion function is given (here the most essential part) by:
f[L2_][t_] := 0 /; L2 < 0;
f[ t_] :=a*(Exp[-4 Log (t/tt)^2]);
f[t_] := a*(f[t]] - b*(f[t])^k)*10^-9) ;
f[L2][t] = f[L2 - 1][ t] - b*(f[L2-1][t])^k)*10^-9);
a,b,k,tt are constants.
Already for values of L2>15 the calculation takes a long long time. So far away from what I want L2 > 1000.
So I would like to have just a simple iteration method:
Solving f for a certain L2 use the solution to calculate another function and then put the solution of f[...,L2,...] into the calculation of f[...,L2+1,...]. And so on.. so that at the end I got a table of the values of f in dependency of L2..
But even using For-Loops it did not work.
So is there a way that Mathematica is able to solve this problem?
Thank you very much in advance!
b = 1.67575*10^-85; a = 1*10^18: tt=35*10^-15;
t goes from -100*10^-15 to 100*10^-15; k=6
Maybe it is also important to know that usualy I use the solution as an input function for a differential equation. Furtheremore f is usualy also dependent on the solution of the differential equation (from a step before). Thats why I want an iterative method.
Okay, it looks like you are building a nested expression. It might be getting huge and that could account for the speed issue. Given the use of machine doubles, large scales, and high degree exponents, I would be surprised if this was not numerically very poorly behaved in any case.
Your (unbalanced) parenthesization makes this not parse. Which means it is difficult to determine what might be the issue(s).