Finding the truncation error in an infinite sequence

16 次查看(过去 30 天)
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 个评论
Walter Roberson
Walter Roberson 2023-4-13
编辑:Walter Roberson 2023-4-13
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 2023-4-14
编辑:Life is Wonderful 2023-4-14
Thank you @Walter Roberson,
insight and much-needed input. To me, it sounds good.

请先登录,再进行评论。

回答(1 个)

Torsten
Torsten 2023-4-6
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 个评论
Walter Roberson
Walter Roberson 2023-4-16
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 2023-4-18
编辑:Life is Wonderful 2023-4-18
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by