A stock trades at S_0 and pays a continuous dividend yield q. The continuously compounded risk-free rate is r. A forward contract expiring at T obliges its holder to buy one share at expiry for the delivery price agreed today.
Compute the fair delivery price: the one that makes the contract worth zero today.
Four numbers S_0, r, q and T.
One real number: the delivery price, with absolute or relative error at most 1e-9.
0 < S_0 <= 10^4
-0.05 <= r <= 0.1
0 <= q <= 0.12
0.001 <= T <= 30
This is a standard problem: a submission scores full points if it produces the correct output for every test case, and zero otherwise.
Numeric answers are accepted if they are within an absolute tolerance of 1e-09 or a relative tolerance of 1e-09 of the expected value.
100 0.05 0.02 1
1.030454533954e+02
250 0.03 0.08 2
2.262093545090e+02