Looking to numerically solve the function erf (x). I searched the internet, I find resolutions, like that proposed by wikipedia http://en.wikipedia.org/wiki/Error_function
But what I would like to have is a way to make a resolution without using these solutions, probably one can use the algorithm Horner, but I do not see how. an idea?
Basically I want an algorithm to solve this integral, without going through already existing solutions.
Otherwise I also seek an alternative to scanf to read the value the user enters. I want to detect for example if it returns a character in place of a value to exit the program. To give something like that,
Code:
#include <stdio.h>
int main()
{
float erf;
float x;
do
{
printf("enter a value for x, or q if you want to quit\n" );
scanf ("%f",&x); //scanf does not seem very appropriate for what I do (detect "q" to quit)
erf=x; //was replaced by an algorithm allowing me to get erf, I am still looking
printf("erf=%f\n",erf);
}
while () ; //condition in a while ... if I can detect when a user enters q...
return 0;
}
The code here is not of great importance, it's just to give a general idea. What I need is an alternative to scanf, and a way to solve erf (horner algorithm, trapezoidal method ...)
Bookmarks