Message Boards Message Boards

NSolve gives nothing when solving an equation including erfc function?

Posted 1 year ago

Dear friends,
I use Mathematica to solve an equation, everything goes well, however, the NSolve gives me nothing.
What is my problem?
Your help would be highly appreciated.

POSTED BY: Daniel Niu
2 Replies
k = 0.736; i = 6.2/100; rt = 0.25; T = 3.0; sigma = 0.3; S = 116; r = 
 5.58/100; delta = 6/100;

d1 = (Log[S/X] + (r + sigma^2/2)*T)/(sigma*Sqrt[T]);
d2 = d1 - sigma*Sqrt[T];
EQ = (k*i*rt + (1 - k)*i)*(E^-r*(1 - E^(-r*T)))/(1 - E^-r) - 
  CDF[NormalDistribution[0, 1], -d2] - 
  ReplaceAll[D[CDF[NormalDistribution[0, 1], x], x], {x -> -d2}]/(
  sigma*Sqrt[T]) + 
  S*ReplaceAll[D[CDF[NormalDistribution[0, 1], x], x], {x -> -d1}]/(
   sigma*Sqrt[T])*1/X - (1 - k)*((1 + delta)^T - 1)*E^(-r*T);
Plot[EQ, {X, -10, 50}, PlotRange -> All](*One solution between: 30..50*)
NSolve[EQ == 0 && 30 < X < 50, X](*Works fine :)*)

(*{{X -> 40.5388}}*)

a = 1/2; FindRoot[EQ, {X, a}](*a is starting point.*)
(* {X -> 40.5388} *)

Regards M.I.

POSTED BY: Mariusz Iwaniuk
Posted 1 year ago

Thank you so much for your help. It works great.

POSTED BY: Daniel Niu
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract