Your t is (p/1000*10^(-a))^2/(q/1000*10^(-b))^2 = 652864/3728761*10^(-2*a+2*b) with p=1616,q=3862, you forgot the decimal powers, I guess. So you have 1 minus (t/2 + t2/8) = 1 minus (.875443612502920e-1*10^(-2*a+2*b)+ .383200759336081e-2*(10^(-2*a+2*b))^2), a=33, b=13 Both the floats can be done by ...
BTW one can do that using Excel as well, "remembering" sqrt(1-t) has the series 1 - t/2 - t^2/8 ... for t ~ 0, so it is 1 minus 1.616^2 / 3.862^2 * 0.5 * 10^(2*a-2*b) = 1 minus 0.087544361250292 * 10(-40) As a matter of taste one can fill up 1 - 0.875443612502920 = 0.1245563874970800 with ...
Yes, complexity (I lurked it up, the naive way is O(N^2), no?). But which magnitude of N you have in mind for an application (since for the usual settings it does not matter)? Or is it a 'theoretical' question?PS: 1) analytical as well and 3) well ...
Hm ... I do not quite understand "O(n)": there are only few such numbers (*) in "usual" programs. So why not simply store them?(*) 46 for type int (1 more for unsigned int), 92 for type __int64
I do not quite understand the discussion: I would check *before* calling. As Traden4Alpha for said "P.S. You'll need to check the validity of these inputs" (for 0 < time [numerical] as well, etc). For me this is the difference between a "prototypic" and a productive solution.
<r>Alan's test example can be done in double precision, with Excel, havinga good implementation. For data being more extreme there are other waysto compute prices (I sketched that at NuclearPhynance).<URL url="http://axelvogt.de/axalom/BS&Vol_CodyMiller.xls.zipFor">http://axelvogt.de/axalom/BS&a...
<t>I would combine C into y, D into x and divide by the numerators, thus forshort B=1=F and C=1, D=1 with new A, E, x, y. Then one has A = E,i.e. only 1 equation. For simplicity you can write 1/A = 1 + x*exp(y) ora = x*exp(y). That curve can be discussed like +-1 = x*Y, 0 < Y=exp(y). PS: for such a ...
It is easy to clean up the code, sorry for being lazy: there is 1 pow to get the cube root, the other are integers (i.e. a polynomial) and calling the very function now and then is not a bad idea.Anyway: a nice listing of methods.