real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + (exp((y * log((y / (z + y))))) / y)
end function
↓
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x + (1.0d0 / y)
t_1 = x + (exp((y * log((y / (y + z))))) / y)
if (t_1 <= (-4d-140)) then
tmp = t_0
else if (t_1 <= 1d-80) then
tmp = x + (exp(-z) / y)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
return x + (Math.exp((y * Math.log((y / (z + y))))) / y);
}
↓
public static double code(double x, double y, double z) {
double t_0 = x + (1.0 / y);
double t_1 = x + (Math.exp((y * Math.log((y / (y + z))))) / y);
double tmp;
if (t_1 <= -4e-140) {
tmp = t_0;
} else if (t_1 <= 1e-80) {
tmp = x + (Math.exp(-z) / y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z):
return x + (math.exp((y * math.log((y / (z + y))))) / y)
if (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y)) < -3.9999999999999999e-140 or 9.99999999999999961e-81 < (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y))
(+.f64 x (/.f64 (pow.f64 (/.f64 y (+.f64 y z)) y) y)): 0 points increase in error, 0 points decrease in error
(+.f64 x (/.f64 (pow.f64 (/.f64 y (Rewrite<= +-commutative_binary64 (+.f64 z y))) y) y)): 0 points increase in error, 0 points decrease in error
(+.f64 x (/.f64 (Rewrite=> sqr-pow_binary64 (*.f64 (pow.f64 (/.f64 y (+.f64 z y)) (/.f64 y 2)) (pow.f64 (/.f64 y (+.f64 z y)) (/.f64 y 2)))) y)): 0 points increase in error, 1 points decrease in error
(+.f64 x (/.f64 (Rewrite<= sqr-pow_binary64 (pow.f64 (/.f64 y (+.f64 z y)) y)) y)): 1 points increase in error, 0 points decrease in error
(+.f64 x (/.f64 (Rewrite<= exp-to-pow_binary64 (exp.f64 (*.f64 (log.f64 (/.f64 y (+.f64 z y))) y))) y)): 0 points increase in error, 0 points decrease in error
(+.f64 x (/.f64 (exp.f64 (Rewrite<= *-commutative_binary64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y)))))) y)): 0 points increase in error, 0 points decrease in error
Taylor expanded in z around 0 0.9
\[\leadsto \color{blue}{\frac{1}{y} + x}
\]
if -3.9999999999999999e-140 < (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y)) < 9.99999999999999961e-81
(+.f64 x (/.f64 (pow.f64 (/.f64 y (+.f64 y z)) y) y)): 0 points increase in error, 0 points decrease in error
(+.f64 x (/.f64 (pow.f64 (/.f64 y (Rewrite<= +-commutative_binary64 (+.f64 z y))) y) y)): 0 points increase in error, 0 points decrease in error
(+.f64 x (/.f64 (Rewrite=> sqr-pow_binary64 (*.f64 (pow.f64 (/.f64 y (+.f64 z y)) (/.f64 y 2)) (pow.f64 (/.f64 y (+.f64 z y)) (/.f64 y 2)))) y)): 0 points increase in error, 1 points decrease in error
(+.f64 x (/.f64 (Rewrite<= sqr-pow_binary64 (pow.f64 (/.f64 y (+.f64 z y)) y)) y)): 1 points increase in error, 0 points decrease in error
(+.f64 x (/.f64 (Rewrite<= exp-to-pow_binary64 (exp.f64 (*.f64 (log.f64 (/.f64 y (+.f64 z y))) y))) y)): 0 points increase in error, 0 points decrease in error
(+.f64 x (/.f64 (exp.f64 (Rewrite<= *-commutative_binary64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y)))))) y)): 0 points increase in error, 0 points decrease in error
Taylor expanded in y around inf 6.1
\[\leadsto x + \color{blue}{\frac{e^{-1 \cdot z}}{y}}
\]
Simplified6.1
\[\leadsto x + \color{blue}{\frac{e^{-z}}{y}}
\]
Proof
(/.f64 (exp.f64 (neg.f64 z)) y): 0 points increase in error, 0 points decrease in error
(/.f64 (exp.f64 (Rewrite<= mul-1-neg_binary64 (*.f64 -1 z))) y): 0 points increase in error, 0 points decrease in error
herbie shell --seed 2022317
(FPCore (x y z)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, G"
:precision binary64
:herbie-target
(if (< (/ y (+ z y)) 7.11541576e-315) (+ x (/ (exp (/ -1.0 z)) y)) (+ x (/ (exp (log (pow (/ y (+ y z)) y))) y)))
(+ x (/ (exp (* y (log (/ y (+ z y))))) y)))