There is no closed form solution for the error function erfa

There is no closed form solution for the error function erf(a) = 2/squareroot pi integral^2_0 e^-x^2 dx Use the (a) two-point and (b) three-point Gauss-Legendre formulas to estimate erf(1.5). Determine the percent relative error for each case based on the true value, which can be determined with MATLAB\'s built-in function erf.

Solution

myerf = @(x)2/sqrt(pi)*exp(-x.^2);
a=0;
b=1.5;
x(1) = -1.0/sqrt(3);
x(2) = -x(1);
xm = (b+a)/2.0 +(b-a)*x/2.0;
intg2 = (myerf(xm(1))+myerf(xm(2)))*(b-a)/2.0;

actual = erf(1.5);
error2 = (abs(actual-intg2)/actual)*100;

disp([\'Error for two point Gauss-Legrende: \', num2str(error2)]);

a = 0;
b = 1.5;
x(1) = -sqrt(0.6);
x(2) = 0;
x(3) = -x(1);
xm = (b+a)/2.0 +(b-a)*x/2.0;
k(1) = 5/9;
K(2) = 8/9;
k(3) = 5/9;
intg3 = myerf(xm)*k\'*(b-a)/2;

error3 = (abs(actual-intg3)/actual)*100;
disp([\'Error for three point Gauss-Legrende: \', num2str(error3)]);

 There is no closed form solution for the error function erf(a) = 2/squareroot pi integral^2_0 e^-x^2 dx Use the (a) two-point and (b) three-point Gauss-Legendr

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site