# Solving Within InverseCDF

I have the following input data:

Remove["Global*"]
x = 5/30 // N;
y = 0.8;
μ = 0.2;
T = 5;
ρ = 0.8;
σ (*to be determined*)


And this is the given equation:

Solve[CDF[
NormalDistribution[], ((1/
Sqrt[ρ])*(((Sqrt[1 - ρ])*(InverseCDF[
NormalDistribution[], (x)]) + (InverseCDF[
NormalDistribution[], (CDF[
NormalDistribution[], -(Log[y] + (μ - 0.5*σ^2)*
T)/(σ*Sqrt[T])])]))))] == 0.0158854, σ,
InverseFunctions -> True]


If I want to Solve for "ρ" it works, but whenever I try to Solve for σ i get the following error message:

"Solve was unable to solve the system with inexact coefficients or the system obtained by direct rationalization of inexact numbers present in the system. Since many of the methods used by Solve require exact input, providing Solve with an exact version of the system may help. >>"

Is here the problem that sigma is simultanously in both an inverseCDF and a CDF?

is there a formula which can be applied in order to get rid of the CDF and inverseCDF?

Or should it be done by splitting up the given equation?

Can anybody help me?

-
Please try using FindRoot rather than Solve or, if what you have is some standard derivative, you could use FinancialDerivative to calculate the "ImpliedVolatility". –  b.gatessucks Aug 19 '13 at 6:53

It is helpful to have a look at the output if you just enter your function :

CDF[NormalDistribution[], ((1/
Sqrt[ρ])*(((Sqrt[1 - ρ])*(InverseCDF[
NormalDistribution[], (x)]) + (InverseCDF[
NormalDistribution[], (CDF[
NormalDistribution[], -(Log[y] + (μ - 1/2*σ^2)*
bigT)/(σ*Sqrt[bigT])])]))))]
(* ConditionalExpression[
1/2 Erfc[-((-Sqrt[2] Sqrt[1 - ρ] InverseErfc[2 x] -
Sqrt[2] InverseErfc[Erfc[-((-bigT (μ - σ^2/2) - Log[y])/(
Sqrt[2] Sqrt[bigT] σ))]])/(Sqrt[2] Sqrt[ρ]))],
0 <= Erfc[-((-bigT (μ - σ^2/2) - Log[y])/(Sqrt[2] Sqrt[bigT] σ))] <= 2 && 0 <= x <= 1]
*)


The first constraint is always met (you can check by plotting it), the second is met in our case. σ appears inside the combination InverseErfc[Erfc[...]] which I didn't manage to simplify honestly so I used brute force. At this point Solve will work, giving two solutions; the second is the positive one.

sol[x_, y_, μ_, bigT_, ρ_, v_] =
Solve[(FullSimplify[
1/2 Erfc[-((-Sqrt[2] Sqrt[1 - ρ] InverseErfc[2 x] -
Sqrt[2] InverseErfc[Erfc[-((-bigT (μ - 1/2 σ^2) - Log[y])/(
Sqrt[2] Sqrt[bigT] σ))]])/(
Sqrt[2] Sqrt[ρ]))] ] /. InverseErfc[Erfc[z_]] -> z) ==
v, σ, InverseFunctions -> True][[All, 1, 2]];


We can check versus a numeric approach :

f[x_, y_, μ_, bigT_, ρ_, σ_] =
1/2 Erfc[-((-Sqrt[2] Sqrt[1 - ρ] InverseErfc[2 x] -
Sqrt[2] InverseErfc[Erfc[-((-bigT (μ - 1/2 σ^2) - Log[y])/(
Sqrt[2] Sqrt[bigT] σ))]])/(Sqrt[2] Sqrt[ρ]))]

output = {#,
FindRoot[
f[5/30, 0.8, 0.2, 5, 0.8, σ] == #, {σ, 0.1}][[1, 2]]} & /@
Range[10^(-3), 0.5, 10^(-2)] ;

Show[ListPlot[output, PlotStyle -> Red],
Plot[sol[5/30, 0.8, 0.2, 5, 0.8, v][[2]], {v, 0, 0.5}]]


-
@ b.gatessucks thank you, I have one more question. I am not sure, if I have understand it totally. If I fix v to be i.e. v=0.88, what exactly do I have to enter into output to get the right σ? In other words, if I do not want to see σ and v within a range but to get a nummerical output. I replaced "output" ==# by ==0.88 but I do not think that the result is correct. Could you give me please a hint? thank you –  Milan Ivica Aug 22 '13 at 12:22
You can use sol[5/30, 0.8, 0.2, 5, 0.8, 0.88] (and take the second solution) or you can use FindRoot[f[5/30, 0.8, 0.2, 5, 0.8, \[Sigma]] == 0.88, {\[Sigma], 0.5}] (notice you need to adjust the starting value). Alternatively you can use a different method with FindRoot[f[5/30, 0.8, 0.2, 5, 0.8, \[Sigma]] == 0.88, {\[Sigma], 0.1, 0.01, 2}]. –  b.gatessucks Aug 22 '13 at 12:31
@ b.gatessucks Thanks, I am still a little bit confisued, 0.88 constitutes a probability and in order to determine this probability I entered the following: probability = CDF[NormalDistribution[], ((1/ Sqrt[[Rho]])*(((Sqrt[ 1 - [Rho]])*(InverseCDF[ NormalDistribution[], (x)]) + (InverseCDF[ NormalDistribution[], (CDF[ NormalDistribution[], +(Log[y] + ([Mu] - 0.5*[Sigma]x^2)* bigT)/([Sigma]x*Sqrt[bigT])])]))))] ... whereas σx=0.2 ... so I geht around 0.886. and when I use sol[5/30, 0.8, 0.2, 5, 0.8, 0.886] i get σ=1.55..? –  Milan Ivica Aug 22 '13 at 12:59
@ b.gatessucks that cannot be true, do I have a mistake here? I am confused, because if I assume that σx=0.2 and I determine a probability of 0.886 and if I use sol[5/30, 0.8, 0.2, 5, 0.8, 0.88], I get that σ=1.55, but it should also be 0.2. thank you for your feedback and help –  Milan Ivica Aug 22 '13 at 13:01
I don't know what you mean. 1/2 Erfc[-((-Sqrt[2] Sqrt[1 - \[Rho]] InverseErfc[2 x] - Sqrt[2] InverseErfc[ Erfc[-((-bigT (\[Mu] - 1/2 \[Sigma]^2) - Log[y])/(Sqrt[2] Sqrt[bigT] \[Sigma]))]])/(Sqrt[ 2] Sqrt[\[Rho]]))] /. {x -> 5/30, y -> 0.8, \[Mu] -> 0.2, bigT -> 5, \[Rho] -> 0.8, \[Sigma] -> 1.53005} gives 0.88 which agrees with sol[5/30, 0.8, 0.2, 5, 0.8, 0.88]. –  b.gatessucks Aug 22 '13 at 14:22

This is just the left-hand side of the ==. I changed the greek to roman and removed parentheses that seemed to be redundant, but I can't promise that it's error-free. Then I used three substitutions that are useful in this sort of problem.

In[1]:=
(CDF[ NormalDistribution[],
(Sqrt[1-r]*InverseCDF[NormalDistribution[], x] +
InverseCDF[NormalDistribution[], CDF[NormalDistribution[],
-(Log[y] + (m-s^2/2)*T)/(s*Sqrt[T])] ] )/Sqrt[r]] /.
InverseCDF[NormalDistribution[],p_] -> -Sqrt@2*InverseErfc[2p] //.
CDF[NormalDistribution[],z_] -> Erfc[-z/Sqrt@2]/2 //Simplify) /.
InverseErf[Infinity, -Erfc[z_] ] -> z //InputForm

Out[1]//InputForm=
Erfc[(Sqrt[1 - r]*InverseErf[Infinity, -2*x] +
(m*T - (s^2*T)/2 + Log[y])/(Sqrt[2]*s*Sqrt[T]))/Sqrt[r]]/2


Then try taking InverseErfc on both sides of the == and evaluating with all known values in N[] form before giving the problem to Solve (or NSolve`?).

-