Finding the truncation error in an infinite sequence

8 visualizaciones (últimos 30 días)
Life is Wonderful
Life is Wonderful el 6 de Abr. de 2023
Editada: Life is Wonderful el 18 de Abr. de 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 comentarios
Walter Roberson
Walter Roberson el 13 de Abr. de 2023
Editada: Walter Roberson el 13 de Abr. de 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
Life is Wonderful el 14 de Abr. de 2023
Editada: Life is Wonderful el 14 de Abr. de 2023
Thank you @Walter Roberson,
insight and much-needed input. To me, it sounds good.

Iniciar sesión para comentar.

Respuestas (1)

Torsten
Torsten el 6 de Abr. de 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 comentarios
Walter Roberson
Walter Roberson el 16 de Abr. de 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
Life is Wonderful el 18 de Abr. de 2023
Editada: Life is Wonderful el 18 de Abr. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Quadratic Programming and Cone Programming en Help Center y File Exchange.

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by