
(FPCore (x y z) :precision binary64 (/ (+ x y) (- 1.0 (/ y z))))
double code(double x, double y, double z) {
return (x + y) / (1.0 - (y / z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + y) / (1.0d0 - (y / z))
end function
public static double code(double x, double y, double z) {
return (x + y) / (1.0 - (y / z));
}
def code(x, y, z): return (x + y) / (1.0 - (y / z))
function code(x, y, z) return Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))) end
function tmp = code(x, y, z) tmp = (x + y) / (1.0 - (y / z)); end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y}{1 - \frac{y}{z}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (+ x y) (- 1.0 (/ y z))))
double code(double x, double y, double z) {
return (x + y) / (1.0 - (y / z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + y) / (1.0d0 - (y / z))
end function
public static double code(double x, double y, double z) {
return (x + y) / (1.0 - (y / z));
}
def code(x, y, z): return (x + y) / (1.0 - (y / z))
function code(x, y, z) return Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))) end
function tmp = code(x, y, z) tmp = (x + y) / (1.0 - (y / z)); end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y}{1 - \frac{y}{z}}
\end{array}
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (+ x y) (- 1.0 (/ y z)))))
(if (or (<= t_0 -5e-292) (not (<= t_0 2e-214)))
t_0
(- (/ (* (- z) x) y) z))))
double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -5e-292) || !(t_0 <= 2e-214)) {
tmp = t_0;
} else {
tmp = ((-z * x) / y) - z;
}
return tmp;
}
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) :: tmp
t_0 = (x + y) / (1.0d0 - (y / z))
if ((t_0 <= (-5d-292)) .or. (.not. (t_0 <= 2d-214))) then
tmp = t_0
else
tmp = ((-z * x) / y) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -5e-292) || !(t_0 <= 2e-214)) {
tmp = t_0;
} else {
tmp = ((-z * x) / y) - z;
}
return tmp;
}
def code(x, y, z): t_0 = (x + y) / (1.0 - (y / z)) tmp = 0 if (t_0 <= -5e-292) or not (t_0 <= 2e-214): tmp = t_0 else: tmp = ((-z * x) / y) - z return tmp
function code(x, y, z) t_0 = Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))) tmp = 0.0 if ((t_0 <= -5e-292) || !(t_0 <= 2e-214)) tmp = t_0; else tmp = Float64(Float64(Float64(Float64(-z) * x) / y) - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x + y) / (1.0 - (y / z)); tmp = 0.0; if ((t_0 <= -5e-292) || ~((t_0 <= 2e-214))) tmp = t_0; else tmp = ((-z * x) / y) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -5e-292], N[Not[LessEqual[t$95$0, 2e-214]], $MachinePrecision]], t$95$0, N[(N[(N[((-z) * x), $MachinePrecision] / y), $MachinePrecision] - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-292} \lor \neg \left(t\_0 \leq 2 \cdot 10^{-214}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-z\right) \cdot x}{y} - z\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -4.99999999999999981e-292 or 1.99999999999999983e-214 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) Initial program 99.9%
if -4.99999999999999981e-292 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < 1.99999999999999983e-214Initial program 23.4%
lift-/.f64N/A
lift-+.f64N/A
flip-+N/A
associate-/l/N/A
difference-of-squaresN/A
lift-+.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower--.f6423.2
Applied rewrites23.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
*-inversesN/A
lift-/.f6423.3
Applied rewrites23.3%
Taylor expanded in y around inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
associate--l-N/A
*-lft-identityN/A
metadata-evalN/A
div-addN/A
fp-cancel-sub-sign-invN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
Applied rewrites100.0%
Taylor expanded in x around inf
Applied rewrites100.0%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.4e-34) (not (<= y 2.25e-5))) (* z (- -1.0 (/ x y))) (+ (fma (+ y x) (/ y z) y) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.4e-34) || !(y <= 2.25e-5)) {
tmp = z * (-1.0 - (x / y));
} else {
tmp = fma((y + x), (y / z), y) + x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -1.4e-34) || !(y <= 2.25e-5)) tmp = Float64(z * Float64(-1.0 - Float64(x / y))); else tmp = Float64(fma(Float64(y + x), Float64(y / z), y) + x); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.4e-34], N[Not[LessEqual[y, 2.25e-5]], $MachinePrecision]], N[(z * N[(-1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y + x), $MachinePrecision] * N[(y / z), $MachinePrecision] + y), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{-34} \lor \neg \left(y \leq 2.25 \cdot 10^{-5}\right):\\
\;\;\;\;z \cdot \left(-1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y + x, \frac{y}{z}, y\right) + x\\
\end{array}
\end{array}
if y < -1.39999999999999998e-34 or 2.25000000000000014e-5 < y Initial program 81.8%
Taylor expanded in z around 0
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
div-addN/A
distribute-neg-inN/A
mul-1-negN/A
*-inversesN/A
metadata-evalN/A
distribute-lft-inN/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
associate-/l*N/A
*-commutativeN/A
mul-1-negN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
*-commutativeN/A
*-commutativeN/A
associate-/l*N/A
Applied rewrites74.0%
if -1.39999999999999998e-34 < y < 2.25000000000000014e-5Initial program 99.9%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f6479.0
Applied rewrites79.0%
Final simplification76.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.4e-34) (not (<= y 2.25e-5))) (* z (- -1.0 (/ x y))) (* (+ y x) (+ (/ y z) 1.0))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.4e-34) || !(y <= 2.25e-5)) {
tmp = z * (-1.0 - (x / y));
} else {
tmp = (y + x) * ((y / z) + 1.0);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-1.4d-34)) .or. (.not. (y <= 2.25d-5))) then
tmp = z * ((-1.0d0) - (x / y))
else
tmp = (y + x) * ((y / z) + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.4e-34) || !(y <= 2.25e-5)) {
tmp = z * (-1.0 - (x / y));
} else {
tmp = (y + x) * ((y / z) + 1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.4e-34) or not (y <= 2.25e-5): tmp = z * (-1.0 - (x / y)) else: tmp = (y + x) * ((y / z) + 1.0) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.4e-34) || !(y <= 2.25e-5)) tmp = Float64(z * Float64(-1.0 - Float64(x / y))); else tmp = Float64(Float64(y + x) * Float64(Float64(y / z) + 1.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.4e-34) || ~((y <= 2.25e-5))) tmp = z * (-1.0 - (x / y)); else tmp = (y + x) * ((y / z) + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.4e-34], N[Not[LessEqual[y, 2.25e-5]], $MachinePrecision]], N[(z * N[(-1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y + x), $MachinePrecision] * N[(N[(y / z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{-34} \lor \neg \left(y \leq 2.25 \cdot 10^{-5}\right):\\
\;\;\;\;z \cdot \left(-1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y + x\right) \cdot \left(\frac{y}{z} + 1\right)\\
\end{array}
\end{array}
if y < -1.39999999999999998e-34 or 2.25000000000000014e-5 < y Initial program 81.8%
Taylor expanded in z around 0
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
div-addN/A
distribute-neg-inN/A
mul-1-negN/A
*-inversesN/A
metadata-evalN/A
distribute-lft-inN/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
associate-/l*N/A
*-commutativeN/A
mul-1-negN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
*-commutativeN/A
*-commutativeN/A
associate-/l*N/A
Applied rewrites74.0%
if -1.39999999999999998e-34 < y < 2.25000000000000014e-5Initial program 99.9%
lift-/.f64N/A
lift-+.f64N/A
flip-+N/A
associate-/l/N/A
difference-of-squaresN/A
lift-+.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower--.f6497.3
Applied rewrites97.3%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6479.0
Applied rewrites79.0%
Final simplification76.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.4e-34) (not (<= y 2.25e-5))) (* z (- -1.0 (/ x y))) (fma x (/ y z) (+ y x))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.4e-34) || !(y <= 2.25e-5)) {
tmp = z * (-1.0 - (x / y));
} else {
tmp = fma(x, (y / z), (y + x));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -1.4e-34) || !(y <= 2.25e-5)) tmp = Float64(z * Float64(-1.0 - Float64(x / y))); else tmp = fma(x, Float64(y / z), Float64(y + x)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.4e-34], N[Not[LessEqual[y, 2.25e-5]], $MachinePrecision]], N[(z * N[(-1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(y / z), $MachinePrecision] + N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{-34} \lor \neg \left(y \leq 2.25 \cdot 10^{-5}\right):\\
\;\;\;\;z \cdot \left(-1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{y}{z}, y + x\right)\\
\end{array}
\end{array}
if y < -1.39999999999999998e-34 or 2.25000000000000014e-5 < y Initial program 81.8%
Taylor expanded in z around 0
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
div-addN/A
distribute-neg-inN/A
mul-1-negN/A
*-inversesN/A
metadata-evalN/A
distribute-lft-inN/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
associate-/l*N/A
*-commutativeN/A
mul-1-negN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
*-commutativeN/A
*-commutativeN/A
associate-/l*N/A
Applied rewrites74.0%
if -1.39999999999999998e-34 < y < 2.25000000000000014e-5Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
fp-cancel-sub-sign-invN/A
distribute-rgt-inN/A
*-lft-identityN/A
associate-+l+N/A
lower-+.f64N/A
lower-fma.f64N/A
metadata-evalN/A
*-lft-identityN/A
lower-/.f6474.7
Applied rewrites74.7%
Applied rewrites78.9%
Final simplification76.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.7e-34) (not (<= y 230.0))) (* z (- -1.0 (/ x y))) (* (+ y x) 1.0)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.7e-34) || !(y <= 230.0)) {
tmp = z * (-1.0 - (x / y));
} else {
tmp = (y + x) * 1.0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-1.7d-34)) .or. (.not. (y <= 230.0d0))) then
tmp = z * ((-1.0d0) - (x / y))
else
tmp = (y + x) * 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.7e-34) || !(y <= 230.0)) {
tmp = z * (-1.0 - (x / y));
} else {
tmp = (y + x) * 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.7e-34) or not (y <= 230.0): tmp = z * (-1.0 - (x / y)) else: tmp = (y + x) * 1.0 return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.7e-34) || !(y <= 230.0)) tmp = Float64(z * Float64(-1.0 - Float64(x / y))); else tmp = Float64(Float64(y + x) * 1.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.7e-34) || ~((y <= 230.0))) tmp = z * (-1.0 - (x / y)); else tmp = (y + x) * 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.7e-34], N[Not[LessEqual[y, 230.0]], $MachinePrecision]], N[(z * N[(-1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y + x), $MachinePrecision] * 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.7 \cdot 10^{-34} \lor \neg \left(y \leq 230\right):\\
\;\;\;\;z \cdot \left(-1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y + x\right) \cdot 1\\
\end{array}
\end{array}
if y < -1.7e-34 or 230 < y Initial program 81.5%
Taylor expanded in z around 0
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
div-addN/A
distribute-neg-inN/A
mul-1-negN/A
*-inversesN/A
metadata-evalN/A
distribute-lft-inN/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
associate-/l*N/A
*-commutativeN/A
mul-1-negN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
*-commutativeN/A
*-commutativeN/A
associate-/l*N/A
Applied rewrites74.4%
if -1.7e-34 < y < 230Initial program 99.9%
lift-/.f64N/A
lift-+.f64N/A
flip-+N/A
associate-/l/N/A
difference-of-squaresN/A
lift-+.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower--.f6496.5
Applied rewrites96.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
*-inversesN/A
lift-/.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
Applied rewrites77.7%
Final simplification75.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.7e-34) (not (<= y 230.0))) (- (fma (/ z y) x z)) (* (+ y x) 1.0)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.7e-34) || !(y <= 230.0)) {
tmp = -fma((z / y), x, z);
} else {
tmp = (y + x) * 1.0;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -1.7e-34) || !(y <= 230.0)) tmp = Float64(-fma(Float64(z / y), x, z)); else tmp = Float64(Float64(y + x) * 1.0); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.7e-34], N[Not[LessEqual[y, 230.0]], $MachinePrecision]], (-N[(N[(z / y), $MachinePrecision] * x + z), $MachinePrecision]), N[(N[(y + x), $MachinePrecision] * 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.7 \cdot 10^{-34} \lor \neg \left(y \leq 230\right):\\
\;\;\;\;-\mathsf{fma}\left(\frac{z}{y}, x, z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y + x\right) \cdot 1\\
\end{array}
\end{array}
if y < -1.7e-34 or 230 < y Initial program 81.5%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower--.f64N/A
Applied rewrites71.9%
Taylor expanded in y around 0
Applied rewrites11.3%
Taylor expanded in z around 0
Applied rewrites72.4%
if -1.7e-34 < y < 230Initial program 99.9%
lift-/.f64N/A
lift-+.f64N/A
flip-+N/A
associate-/l/N/A
difference-of-squaresN/A
lift-+.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower--.f6496.5
Applied rewrites96.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
*-inversesN/A
lift-/.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
Applied rewrites77.7%
Final simplification74.9%
(FPCore (x y z) :precision binary64 (if (<= y -6.6e+24) (- (fma (/ z y) z z)) (if (<= y 3.2e+108) (* (+ y x) 1.0) (- z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6.6e+24) {
tmp = -fma((z / y), z, z);
} else if (y <= 3.2e+108) {
tmp = (y + x) * 1.0;
} else {
tmp = -z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -6.6e+24) tmp = Float64(-fma(Float64(z / y), z, z)); elseif (y <= 3.2e+108) tmp = Float64(Float64(y + x) * 1.0); else tmp = Float64(-z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -6.6e+24], (-N[(N[(z / y), $MachinePrecision] * z + z), $MachinePrecision]), If[LessEqual[y, 3.2e+108], N[(N[(y + x), $MachinePrecision] * 1.0), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.6 \cdot 10^{+24}:\\
\;\;\;\;-\mathsf{fma}\left(\frac{z}{y}, z, z\right)\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+108}:\\
\;\;\;\;\left(y + x\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -6.5999999999999998e24Initial program 79.6%
lift-/.f64N/A
lift-+.f64N/A
flip-+N/A
associate-/l/N/A
difference-of-squaresN/A
lift-+.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower--.f6456.8
Applied rewrites56.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
*-inversesN/A
lift-/.f6479.5
Applied rewrites79.5%
Taylor expanded in y around inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
associate--l-N/A
*-lft-identityN/A
metadata-evalN/A
div-addN/A
fp-cancel-sub-sign-invN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
Applied rewrites72.8%
Taylor expanded in x around 0
Applied rewrites65.0%
if -6.5999999999999998e24 < y < 3.1999999999999999e108Initial program 98.7%
lift-/.f64N/A
lift-+.f64N/A
flip-+N/A
associate-/l/N/A
difference-of-squaresN/A
lift-+.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower--.f6494.9
Applied rewrites94.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
*-inversesN/A
lift-/.f6498.6
Applied rewrites98.6%
Taylor expanded in y around 0
Applied rewrites69.6%
if 3.1999999999999999e108 < y Initial program 72.0%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6463.0
Applied rewrites63.0%
Final simplification67.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.6e+24) (not (<= y 3.2e+108))) (- z) (* (+ y x) 1.0)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.6e+24) || !(y <= 3.2e+108)) {
tmp = -z;
} else {
tmp = (y + x) * 1.0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-6.6d+24)) .or. (.not. (y <= 3.2d+108))) then
tmp = -z
else
tmp = (y + x) * 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -6.6e+24) || !(y <= 3.2e+108)) {
tmp = -z;
} else {
tmp = (y + x) * 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.6e+24) or not (y <= 3.2e+108): tmp = -z else: tmp = (y + x) * 1.0 return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.6e+24) || !(y <= 3.2e+108)) tmp = Float64(-z); else tmp = Float64(Float64(y + x) * 1.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -6.6e+24) || ~((y <= 3.2e+108))) tmp = -z; else tmp = (y + x) * 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.6e+24], N[Not[LessEqual[y, 3.2e+108]], $MachinePrecision]], (-z), N[(N[(y + x), $MachinePrecision] * 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.6 \cdot 10^{+24} \lor \neg \left(y \leq 3.2 \cdot 10^{+108}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\left(y + x\right) \cdot 1\\
\end{array}
\end{array}
if y < -6.5999999999999998e24 or 3.1999999999999999e108 < y Initial program 76.0%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6463.9
Applied rewrites63.9%
if -6.5999999999999998e24 < y < 3.1999999999999999e108Initial program 98.7%
lift-/.f64N/A
lift-+.f64N/A
flip-+N/A
associate-/l/N/A
difference-of-squaresN/A
lift-+.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower--.f6494.9
Applied rewrites94.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
*-inversesN/A
lift-/.f6498.6
Applied rewrites98.6%
Taylor expanded in y around 0
Applied rewrites69.6%
Final simplification67.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.9e-36) (not (<= y 7.5e-53))) (- z) (* (- x) -1.0)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.9e-36) || !(y <= 7.5e-53)) {
tmp = -z;
} else {
tmp = -x * -1.0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-4.9d-36)) .or. (.not. (y <= 7.5d-53))) then
tmp = -z
else
tmp = -x * (-1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -4.9e-36) || !(y <= 7.5e-53)) {
tmp = -z;
} else {
tmp = -x * -1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4.9e-36) or not (y <= 7.5e-53): tmp = -z else: tmp = -x * -1.0 return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4.9e-36) || !(y <= 7.5e-53)) tmp = Float64(-z); else tmp = Float64(Float64(-x) * -1.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -4.9e-36) || ~((y <= 7.5e-53))) tmp = -z; else tmp = -x * -1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4.9e-36], N[Not[LessEqual[y, 7.5e-53]], $MachinePrecision]], (-z), N[((-x) * -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.9 \cdot 10^{-36} \lor \neg \left(y \leq 7.5 \cdot 10^{-53}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\left(-x\right) \cdot -1\\
\end{array}
\end{array}
if y < -4.8999999999999997e-36 or 7.5000000000000001e-53 < y Initial program 83.2%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6451.7
Applied rewrites51.7%
if -4.8999999999999997e-36 < y < 7.5000000000000001e-53Initial program 99.9%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower--.f64N/A
Applied rewrites99.8%
Taylor expanded in y around 0
Applied rewrites70.0%
Final simplification59.1%
(FPCore (x y z) :precision binary64 (- z))
double code(double x, double y, double z) {
return -z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -z
end function
public static double code(double x, double y, double z) {
return -z;
}
def code(x, y, z): return -z
function code(x, y, z) return Float64(-z) end
function tmp = code(x, y, z) tmp = -z; end
code[x_, y_, z_] := (-z)
\begin{array}{l}
\\
-z
\end{array}
Initial program 90.0%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6434.4
Applied rewrites34.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ (+ y x) (- y)) z)))
(if (< y -3.7429310762689856e+171)
t_0
(if (< y 3.5534662456086734e+168) (/ (+ x y) (- 1.0 (/ y z))) t_0))))
double code(double x, double y, double z) {
double t_0 = ((y + x) / -y) * z;
double tmp;
if (y < -3.7429310762689856e+171) {
tmp = t_0;
} else if (y < 3.5534662456086734e+168) {
tmp = (x + y) / (1.0 - (y / z));
} else {
tmp = t_0;
}
return tmp;
}
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) :: tmp
t_0 = ((y + x) / -y) * z
if (y < (-3.7429310762689856d+171)) then
tmp = t_0
else if (y < 3.5534662456086734d+168) then
tmp = (x + y) / (1.0d0 - (y / z))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((y + x) / -y) * z;
double tmp;
if (y < -3.7429310762689856e+171) {
tmp = t_0;
} else if (y < 3.5534662456086734e+168) {
tmp = (x + y) / (1.0 - (y / z));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = ((y + x) / -y) * z tmp = 0 if y < -3.7429310762689856e+171: tmp = t_0 elif y < 3.5534662456086734e+168: tmp = (x + y) / (1.0 - (y / z)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(y + x) / Float64(-y)) * z) tmp = 0.0 if (y < -3.7429310762689856e+171) tmp = t_0; elseif (y < 3.5534662456086734e+168) tmp = Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((y + x) / -y) * z; tmp = 0.0; if (y < -3.7429310762689856e+171) tmp = t_0; elseif (y < 3.5534662456086734e+168) tmp = (x + y) / (1.0 - (y / z)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(y + x), $MachinePrecision] / (-y)), $MachinePrecision] * z), $MachinePrecision]}, If[Less[y, -3.7429310762689856e+171], t$95$0, If[Less[y, 3.5534662456086734e+168], N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y + x}{-y} \cdot z\\
\mathbf{if}\;y < -3.7429310762689856 \cdot 10^{+171}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y < 3.5534662456086734 \cdot 10^{+168}:\\
\;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
herbie shell --seed 2024337
(FPCore (x y z)
:name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A"
:precision binary64
:alt
(! :herbie-platform default (if (< y -3742931076268985600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (* (/ (+ y x) (- y)) z) (if (< y 3553466245608673400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ (+ x y) (- 1 (/ y z))) (* (/ (+ y x) (- y)) z))))
(/ (+ x y) (- 1.0 (/ y z))))