搜索
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?
The error is different for each input; if the input number is small, the error condition can be reached quickly, say 1e-6; if the input number is large, we need more terms in the polynomial equation, i.e. more iteration; how can I make the threshold dynamic so that I don't have a fixed error tolerance number?
What I want to know is how to make the threshold dynamic so that I can decrease the polynomial's order and lower the number of terms, which will speed up execution time.
Any assistance would be greatly appreciated.
format long e
[exp(log(2)/2), 1+log(2)/2 + (log(2)/2)^2/factorial(2) + (log(2)/2)^3/factorial(3) + (log(2)/2)^4/factorial(4),(exp(log(2)/2) - 1+log(2)/2 + (log(2)/2)^2/factorial(2) + (log(2)/2)^3/factorial(3) + (log(2)/2)^4/factorial(4))]
[exp(-log(2)/2), 1+(-log(2)/2) + (-log(2)/2)^2/factorial(2) + (-log(2)/2)^3/factorial(3) + (-log(2)/2)^4/factorial(4),(exp(log(2)/2) - 1+log(2)/2 + (log(2)/2)^2/factorial(2) + (log(2)/2)^3/factorial(3) + (log(2)/2)^4/factorial(4))]