c - Function approximation with Maclaurin series -


I need approx (1-x) ^ 0.25 with exact (0.0001 eg). I'm using (1 + x) ^ 0.25 for when the expression is less than accuracy, then I need to stop estimating.

  long double s (long double x, long double d) {long double w = 1; Long double n = 1; Long TPP = 1; // sum while the last expression is greater than accuracy (fabsl (tmp)> = d) {tmp * = (1.25 / n - 1) * (-x); // Next expression w + = tmp; // approximation is added to n ++; } Return w; }   

Do not believe long double n: P works well when I'm not checking the value of the current expression, but when I'm computing 1000 or more expressions The domain of the function am & lt; -1; 1 & gt; And S (in X) & lt; -1; ~ 0.6 & gt; Calculates approximation for The big argument is that the calculation error is large. This is more than 0.6 accuracy.

I'm not sure the problem is quite obvious because I do not know English math language well. The thing is that whenever the situation occurs and the function (s) is not correctly approximated.

Edit: The problem is mostly resolved. When x & gt; 0 I have to reduce the absolute value of consecutive expressions from 1.

  if (x   

After that accuracy becomes too much (fox x> 0 course). False error arises from dual inaccuracy for a long time, that's all. Somehow thank you for you.

Draw a graph of the function

 abs ((1.0 + x)  Alpha  - binomial_formula (alpha, x, tolerance))  Even in close range x such as [-0.5; 0.5] You will find something: Enter image details here 

This means that the implementation of your binomial extension is shaky As the X forward and beyond the accuracy given from the zero-chain, more and more words must be included. But doing so may cause existing extension implementation (some floating point error caching mechanism).

Thanks to BTW, really interesting problem!

Comments