Name: Anonymous 2010-09-23 7:50
/prog/ Exercise
Write an implementation of that gives the numeric approximation of a smooth function (infinitely differentiable) such as tangent(x), cosine(x), or log(x) with an adjustable level of precision in a desired programming language. Please briefly describe the method or algorithm used in your
EXAMPLE.
Function ex
Method Maclaurin
Language ANSI C
Write an implementation of that gives the numeric approximation of a smooth function (infinitely differentiable) such as tangent(x), cosine(x), or log(x) with an adjustable level of precision in a desired programming language. Please briefly describe the method or algorithm used in your
code to approximate the function. If desired, it is acceptable to not reply.EXAMPLE.
Function ex
Method Maclaurin
Language ANSI C
#include <stdio.h>
double e(double e, int p)
{
double x=1,y=1; int i=1,j=1;
for(;i<p;++i) {
y*=e,j*=i;
x+=y/j;
}
return x;
}
int main()
{
double x = 1;
int p = 11;
printf("e^%f ≈ %.8f\n| Error | ≤ %f^%d/%d!\n", x, e(x,p), x, ++p, p);
}