# Finding the truncation error in an infinite sequence

24 vues (au cours des 30 derniers jours)
Life is Wonderful le 6 Avr 2023
Hi there,
Truncation error happens when an infinite series is ignored except for a small subset of its values. For instance, the exponential function e^x could be written as the infinite series total of 1 + x + x^2/2 + x^3/6 +... + x^n/n! +....
Any finite number of n will result in an approximation of the value of e^x that is inaccurate, but by increasing n, the error can be reduced to the desired level but this increase computation time.
How can I speed up the calculation by determining the dynamic level where error can be reduced to the barest minimum?
Any assistance would be greatly appreciated.
Many thanks
##### 6 commentairesAfficher 4 commentaires plus anciensMasquer 4 commentaires plus anciens
Walter Roberson le 13 Avr 2023
Modifié(e) : Walter Roberson le 13 Avr 2023
The following discusses range reduction of the base for calculating exponentiation.
The context for why people were looking for that has to do with an algorithm called CORDIC. MATLAB already has a fixed-point CORDIC exponential.
To put it another way: people do not use taylor series for exp() for FPGA purposes, they use a different successive-approximation approach that is well suited for FPGA.
Life is Wonderful le 14 Avr 2023
Modifié(e) : Life is Wonderful le 14 Avr 2023
Thank you @Walter Roberson,
insight and much-needed input. To me, it sounds good.

Connectez-vous pour commenter.

### Réponses (1)

Torsten le 6 Avr 2023
How can I speed up the calculation by determining the dynamic level where error can be reduced to the barest minimum?
You mean you want to stop adding x^n / n! when the sum of the rest series is smaller than a prescribed value ? And you ask how you can do this ?
This can only be done theoretically beforehand without the use of MATLAB.
##### 35 commentairesAfficher 33 commentaires plus anciensMasquer 33 commentaires plus anciens
Walter Roberson le 16 Avr 2023
Nothing in the symbolic toolbox can be compiled. If you were to use the symbolic taylor series then you would need to matlabFunction() in a different session asking to write to file, and then in the other section to be compiled you would invoke the function by file name.
Note that if you go beyond 15 terms of taylor then the factorial(15) will exceed double precision resolution and your calculation will become unreliable. This gets to be a serious problem for transcendental functions.
Life is Wonderful le 18 Avr 2023
Modifié(e) : Life is Wonderful le 18 Avr 2023
Yes, I am aware that factorial 20 would be the final one since, if your data type has a 64-bit width, it cannot fit beyond this amount.
But I'm not doing anything on the implementation front.

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Get Started with Curve Fitting Toolbox dans Help Center et File Exchange

R2023a

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by