summation of infinite series
Mostra commenti meno recenti
How I can impliment this type of infinite series in MATLAB given a function as
where
,
, and
. Here l,γ,R are constant.
where
,
. Here l,γ,R are constant.6 Commenti
Walter Roberson
il 15 Feb 2021
You can implement it using symsum(), but I would be rather surprised if it is able to come up with a formula for it; chances are it will just leave it as a symsum()
You mention those three variables as constants, but you do not mention
? Is that the input variable?
Sudhir Sahoo
il 15 Feb 2021
Modificato: Sudhir Sahoo
il 15 Feb 2021
Walter Roberson
il 16 Feb 2021
I am not interested in doing that much typing.
I already showed in https://www.mathworks.com/matlabcentral/answers/742277-implementation-of-infinite-series-in-matlab that you have three choices:
- Use an infinite limit but do not use double. Use vpa() with a large number of digits. You might need 150 or more digits to prevent vpa() from having problems; OR
- Use a finite limit, in which case double() appears to do a nice job; OR
- Use vpa() with a large number of digits and double() the result.
Sudhir Sahoo
il 16 Feb 2021
Walter Roberson
il 16 Feb 2021
Post your code.
In terms of the code I posted earlier, the way forward would be to comment out that line that produces the error message, as I showed in the code how to get outputs without the error; I left the call to double() in to demonstrate that double() itself could not be used for the situation.
Sudhir Sahoo
il 17 Feb 2021
Risposte (2)
Walter Roberson
il 17 Feb 2021
1 voto
You did not give a value or range for R. My suspicion is that if R is not -1 or less, that the sum is infinite when the upper bound is infinite.
The code you were using required evaluation at over 1500 digits of precision to stableize the output when using 200 terms. However once I looked more closely at the code, I realized that some of it was being evaluated in pure double precision, so the answers it was getting were effectively numeric nonsense.
Unfortunately, the revised version is very slow.
I had to completely invent a value of R for testing purpose. As I had no guidance as to a proper value, I used 7 in the code.
With 200 terms, and using 5000 decimal places, the result is over 10^3000 . As the number of terms goes up, the result goes up quickly.
If you use fewer DIGITS, and the answer you get out for ev is in scientific notation, starting with a digit followed by a period, then you need to increase the DIGITS: whatever result you got out has been compromised. If the result you get out is negative, then you need to increase the DIGITS. If you do get out an actual number without scientific notation, then you might still need to increase the DIGITS
3 Commenti
Walter Roberson
il 17 Feb 2021
Note that I had to change all of your functions, so make sure you create a new directory to download these versions into.
Sudhir Sahoo
il 17 Feb 2021
Modificato: Sudhir Sahoo
il 17 Feb 2021
Walter Roberson
il 17 Feb 2021
Note: going beyond 500 terms for the upper limit will make the calculation unbearably slow. I do not mean a gradual deterioration, I mean a sharp deterioration. vpa(factorial(sym(1001)),2600) is very very slow, but 1000 instead is fast.
Sudhir Sahoo
il 16 Feb 2021
Categorie
Scopri di più su Waveform Generation in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





