Under the risk-neutral measure, a stock's price at expiry T is uniformly distributed on [a, b]. The continuously compounded risk-free rate is r.
Compute the price of the European call with strike K and expiry T.
Five numbers a, b, K, r and T.
One real number: the call price, with absolute or relative error at most 1e-9.
0 <= a < b <= 10^4
0 <= K <= 1.5 * 10^4
-0.05 <= r <= 0.1
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 a relative tolerance of 1e-09 of the expected value.
80 120 100 0.02 1
4.900993366534e+00
100 200 50 0.05 2
9.048374180360e+01