#include #include #include #include long double f( long double x, long double k ) { return expl( x ) - k; } int main(int argc, char **argv) { long double x; long double k; long double lnx; long double y; char pszString[256] = "2"; if ( argc < 2 ) { printf( "Enter a number to find exponential of:" ); fgets( pszString, sizeof( pszString ), stdin ); puts( pszString ); } else strncpy( pszString, argv[1], sizeof( pszString ) ); k = atof( pszString ); x = expl( k ) * 1.00001; /* form estimate correct to 5 digits */ lnx = logl(x); printf("answer = %30.20LeL\nx = %30.20LeL\n", expl( k ), x - x*lnx + x*k ); y = lnx - k; x -= 3. * x * ( 2 + 3 * y + 2 * y * y ) * y / ( 6 + 12 * y + 11 * y * y + 6 * y * y * y ); printf("answer = %30.20LeL\nx = %30.20LeL\n", expl( k ), x ); return 0; }