Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

«Exercise» Numeric Est. of Smooth Functions

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 code to approximate the function. If desired, it is acceptable to not reply.

XAMPLE.

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);
}

Name: Anonymous 2010-09-24 7:36


ackermann 0 = 0
ackermann 1 = 1
ackermann n = ackermann (n-1) + ackermann (n-2)

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List