Math2.org Math Tables: Recursive Formulas for B / A |
(Math) |
Explicit form:
Find B/A where B and A are real numbers and B > 0Recursive form:
Convert B and A to scientific notation base 2 (C++ has function "frexp" for this). Note: mantissa is ³ .5 and < 1.Example: 314.51 / 5.6789Let
a = mantissa of AReiterate x until desired precision reached. Result only has to be close, not perfect. I suggest about 5 times.
b = mantissa of B
exp = exponent of b - exponent of a
x0 = 1
xn+1 = xn(2 - a xn)
y0 = b xnReiterate y until desired precision reached.
yi+1 = yi + xn(b - a yi)B / A = yi * 2exp
Written in base-2 scientific notation:Source: Jeff Yates, et al.
B = 0.61357421875 * 29
A = 0.7098625 * 23
exp = 9 - 3 = 6
iteration value x0 1 x1 1.2901375 x2 1.398740976607287 x3 1.408652781763906 x4 1.408723516847958
(will use this value for x)iteration value y0 0.864356431284738 y1 0.864356433463227 y2 0.864356433463227 y3 0.864356433463227 y4 0.864356433463227 y5 0.864356433463227
B / A = 0.864356433463227 * 26 =
55.31881174171053855.318811741710538 (true value)