erf and trapezoidal method for volume
6 views (last 30 days)
trying to determine volume for the following Y=5(1-erf(x) for x=0:1 Y=0 for X=1:29 Y=5(1-erf(3x+25) for x=29:30 Using the trapezoidal method. Have the following code but am completely stuck. Any hints please?? h is intervals and x is above. Currently when i run it there is no volume being spat out for the 0-1 range (haven't got any further) so not even sure where to go for the 1:29 and >29 values
y = @(x) 5*(1-erf(x));
X0 = 0;
X30 = 1;
Xn = 4;
h = ((X30-X0)/Xn);
Area = 0;
Area = Area+(h/2)*(y(X0)+y(X0+h));
X0 = X0+h;
Rachana Reddy Mamilla on 6 Nov 2018
It is an Error function. Y = erf(X) is the error function for each element of X. X must be real. The error function is defined as:
erf(x) = 2/sqrt(pi) * integral from 0 to x of exp(-t^2) dt.
Trapezoidal method is a popular method for numerical integration of various functions. This method is mainly applicable to estimate the area under a curve by splitting the entire area into a number of trapeziums of known area.
You are also creating a function handle , splitting the area under your function into finite trapezoids[4 in number] and then finding the cumulative area of all the trapezoids.
This way you can just find the area under each y and not the volume using this method. Hope this link would be helpful to you.