Home > Software engineering >  Nonlinear equation problem # value?
Nonlinear equation problem # value?

Time:09-27

Solution of the nonlinear equations, the calculation of implied volatility, VBA function set sigma satisfy the following equation:


. Write a function to the C, S, X, r, T as input parameters, calculation of sigma value, 0 & lt; Sigma & lt;=1,
My code is like this, can you tell me where is wrong?
 Function f (c, s, x, r, t As Double) 
Dim d1, d2, z, delta, temp, tempz As Double
Temp=1
For z=0.1 To 1 Step 0.1
D1=(((Log (s/x)) + 1/2 * * z z (r *) * t))/(z * Sqr (t))
D2=d1 - z * Sqr (t)
Y=s * Norm. Spyware doctor ist (d1) - x * Exp (-) r * t * Norm in spyware doctor ist (d2)
Delta - y=c
If the delta & lt; Then delta=0 - delta
If temp & gt; The delta Then temp=delta: tempz=z
Next z
F=tempz
End the Function
  •  Tags:  
  • VBA
  • Related