MATLAB: Find finverse of cumtrapz()

functionintegrationMATLABnumerical integration

Hi,
I have to invert the function that calculates cumtrapz of an equation as follows:
mu = 0;
var = 1;
%x = -9:0.01:9;
syms x
f(x) = cumtrapz((2*pi*(v))^(-0.5)* exp(-((x-mu).^2)/(2*(v))))
i = finverse(f)
fplot(i)
But this gives me :
f(x) =
0
Warning: Unable to find functional inverse.
> In symengine
In sym/privBinaryOp (line 1032)
In sym/finverse (line 40)
In inverse_cdf (line 7)
i(x) =
Empty sym: 0-by-1
However the cumtrapz function does work:
mu = 0;
var = 1;
x = -9:0.01:9;
y = (2*pi*(v))^(-0.5)* exp(-((x-mu).^2)/(2*(v)));
i = cumtrapz(y);
plot(i)
what can i do to invert this function

Best Answer

Since ‘f’:
mu = 0;
v = 1;
syms x
f(x) = int((2*pi*(v))^(-0.5)* exp(-((x-mu).^2)/(2*(v))))
evaluates to:
f(x) =
(7186705221432913*2^(1/2)*pi^(1/2)*erf((2^(1/2)*x)/2))/36028797018963968
you will need to use the erfinv function to calculate the inverse.