Finding the truncation error in an infinite sequence

29 ビュー (過去 30 日間)
Life is Wonderful
Life is Wonderful 2023 年 4 月 6 日
編集済み: Life is Wonderful 2023 年 4 月 18 日
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 Center および File ExchangeQuadratic Programming and Cone Programming についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by