
(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 8 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 -1e-289) (not (<= t_0 0.0))) t_0 (/ (- z) (/ y (+ x y))))))
double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -1e-289) || !(t_0 <= 0.0)) {
tmp = t_0;
} else {
tmp = -z / (y / (x + y));
}
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 <= (-1d-289)) .or. (.not. (t_0 <= 0.0d0))) then
tmp = t_0
else
tmp = -z / (y / (x + y))
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 <= -1e-289) || !(t_0 <= 0.0)) {
tmp = t_0;
} else {
tmp = -z / (y / (x + y));
}
return tmp;
}
def code(x, y, z): t_0 = (x + y) / (1.0 - (y / z)) tmp = 0 if (t_0 <= -1e-289) or not (t_0 <= 0.0): tmp = t_0 else: tmp = -z / (y / (x + y)) 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 <= -1e-289) || !(t_0 <= 0.0)) tmp = t_0; else tmp = Float64(Float64(-z) / Float64(y / Float64(x + y))); 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 <= -1e-289) || ~((t_0 <= 0.0))) tmp = t_0; else tmp = -z / (y / (x + y)); 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, -1e-289], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], t$95$0, N[((-z) / N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-289} \lor \neg \left(t\_0 \leq 0\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-z}{\frac{y}{x + y}}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -1e-289 or -0.0 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) Initial program 99.9%
if -1e-289 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -0.0Initial program 6.5%
Taylor expanded in z around 0 99.8%
mul-1-neg99.8%
associate-/l*99.9%
distribute-rgt-neg-in99.9%
distribute-neg-frac299.9%
+-commutative99.9%
Simplified99.9%
associate-*r/99.8%
distribute-frac-neg299.8%
add-sqr-sqrt52.4%
sqrt-unprod25.5%
sqr-neg25.5%
sqrt-unprod2.4%
add-sqr-sqrt5.0%
associate-*r/5.0%
clear-num5.0%
un-div-inv5.0%
add-sqr-sqrt2.4%
sqrt-unprod25.4%
sqr-neg25.4%
sqrt-unprod52.5%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ y z))) (t_1 (* z (- -1.0 (/ x y)))))
(if (<= y -3.8e+19)
t_1
(if (<= y 2.25e-51)
(+ x y)
(if (<= y 1.2e+17)
(/ x t_0)
(if (<= y 1.7e+139) (* y (/ 1.0 t_0)) t_1))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = z * (-1.0 - (x / y));
double tmp;
if (y <= -3.8e+19) {
tmp = t_1;
} else if (y <= 2.25e-51) {
tmp = x + y;
} else if (y <= 1.2e+17) {
tmp = x / t_0;
} else if (y <= 1.7e+139) {
tmp = y * (1.0 / t_0);
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (y / z)
t_1 = z * ((-1.0d0) - (x / y))
if (y <= (-3.8d+19)) then
tmp = t_1
else if (y <= 2.25d-51) then
tmp = x + y
else if (y <= 1.2d+17) then
tmp = x / t_0
else if (y <= 1.7d+139) then
tmp = y * (1.0d0 / t_0)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = z * (-1.0 - (x / y));
double tmp;
if (y <= -3.8e+19) {
tmp = t_1;
} else if (y <= 2.25e-51) {
tmp = x + y;
} else if (y <= 1.2e+17) {
tmp = x / t_0;
} else if (y <= 1.7e+139) {
tmp = y * (1.0 / t_0);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) t_1 = z * (-1.0 - (x / y)) tmp = 0 if y <= -3.8e+19: tmp = t_1 elif y <= 2.25e-51: tmp = x + y elif y <= 1.2e+17: tmp = x / t_0 elif y <= 1.7e+139: tmp = y * (1.0 / t_0) else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y / z)) t_1 = Float64(z * Float64(-1.0 - Float64(x / y))) tmp = 0.0 if (y <= -3.8e+19) tmp = t_1; elseif (y <= 2.25e-51) tmp = Float64(x + y); elseif (y <= 1.2e+17) tmp = Float64(x / t_0); elseif (y <= 1.7e+139) tmp = Float64(y * Float64(1.0 / t_0)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y / z); t_1 = z * (-1.0 - (x / y)); tmp = 0.0; if (y <= -3.8e+19) tmp = t_1; elseif (y <= 2.25e-51) tmp = x + y; elseif (y <= 1.2e+17) tmp = x / t_0; elseif (y <= 1.7e+139) tmp = y * (1.0 / t_0); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[(-1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.8e+19], t$95$1, If[LessEqual[y, 2.25e-51], N[(x + y), $MachinePrecision], If[LessEqual[y, 1.2e+17], N[(x / t$95$0), $MachinePrecision], If[LessEqual[y, 1.7e+139], N[(y * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
t_1 := z \cdot \left(-1 - \frac{x}{y}\right)\\
\mathbf{if}\;y \leq -3.8 \cdot 10^{+19}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 2.25 \cdot 10^{-51}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{+17}:\\
\;\;\;\;\frac{x}{t\_0}\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{+139}:\\
\;\;\;\;y \cdot \frac{1}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -3.8e19 or 1.7000000000000001e139 < y Initial program 63.5%
Taylor expanded in z around 0 65.2%
mul-1-neg65.2%
associate-/l*88.5%
distribute-rgt-neg-in88.5%
distribute-neg-frac288.5%
+-commutative88.5%
Simplified88.5%
Taylor expanded in z around 0 65.2%
mul-1-neg65.2%
associate-/l*88.5%
+-commutative88.5%
distribute-rgt-neg-in88.5%
neg-sub088.5%
*-lft-identity88.5%
associate-*l/88.3%
distribute-rgt-in88.3%
rgt-mult-inverse88.5%
associate-*r/88.5%
*-rgt-identity88.5%
associate--r+88.5%
metadata-eval88.5%
Simplified88.5%
if -3.8e19 < y < 2.24999999999999987e-51Initial program 99.9%
Taylor expanded in z around inf 78.5%
+-commutative78.5%
Simplified78.5%
if 2.24999999999999987e-51 < y < 1.2e17Initial program 99.8%
Taylor expanded in x around inf 76.5%
if 1.2e17 < y < 1.7000000000000001e139Initial program 91.5%
Taylor expanded in x around 0 76.8%
clear-num76.6%
associate-/r/76.8%
Applied egg-rr76.8%
Final simplification81.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ y z))) (t_1 (* z (- -1.0 (/ x y)))))
(if (<= y -2e+21)
t_1
(if (<= y 8.2e-52)
(+ x y)
(if (<= y 3600000000.0)
(/ x t_0)
(if (<= y 1.7e+139) (/ y t_0) t_1))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = z * (-1.0 - (x / y));
double tmp;
if (y <= -2e+21) {
tmp = t_1;
} else if (y <= 8.2e-52) {
tmp = x + y;
} else if (y <= 3600000000.0) {
tmp = x / t_0;
} else if (y <= 1.7e+139) {
tmp = y / t_0;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (y / z)
t_1 = z * ((-1.0d0) - (x / y))
if (y <= (-2d+21)) then
tmp = t_1
else if (y <= 8.2d-52) then
tmp = x + y
else if (y <= 3600000000.0d0) then
tmp = x / t_0
else if (y <= 1.7d+139) then
tmp = y / t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = z * (-1.0 - (x / y));
double tmp;
if (y <= -2e+21) {
tmp = t_1;
} else if (y <= 8.2e-52) {
tmp = x + y;
} else if (y <= 3600000000.0) {
tmp = x / t_0;
} else if (y <= 1.7e+139) {
tmp = y / t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) t_1 = z * (-1.0 - (x / y)) tmp = 0 if y <= -2e+21: tmp = t_1 elif y <= 8.2e-52: tmp = x + y elif y <= 3600000000.0: tmp = x / t_0 elif y <= 1.7e+139: tmp = y / t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y / z)) t_1 = Float64(z * Float64(-1.0 - Float64(x / y))) tmp = 0.0 if (y <= -2e+21) tmp = t_1; elseif (y <= 8.2e-52) tmp = Float64(x + y); elseif (y <= 3600000000.0) tmp = Float64(x / t_0); elseif (y <= 1.7e+139) tmp = Float64(y / t_0); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y / z); t_1 = z * (-1.0 - (x / y)); tmp = 0.0; if (y <= -2e+21) tmp = t_1; elseif (y <= 8.2e-52) tmp = x + y; elseif (y <= 3600000000.0) tmp = x / t_0; elseif (y <= 1.7e+139) tmp = y / t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[(-1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2e+21], t$95$1, If[LessEqual[y, 8.2e-52], N[(x + y), $MachinePrecision], If[LessEqual[y, 3600000000.0], N[(x / t$95$0), $MachinePrecision], If[LessEqual[y, 1.7e+139], N[(y / t$95$0), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
t_1 := z \cdot \left(-1 - \frac{x}{y}\right)\\
\mathbf{if}\;y \leq -2 \cdot 10^{+21}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 8.2 \cdot 10^{-52}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq 3600000000:\\
\;\;\;\;\frac{x}{t\_0}\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{+139}:\\
\;\;\;\;\frac{y}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -2e21 or 1.7000000000000001e139 < y Initial program 63.5%
Taylor expanded in z around 0 65.2%
mul-1-neg65.2%
associate-/l*88.5%
distribute-rgt-neg-in88.5%
distribute-neg-frac288.5%
+-commutative88.5%
Simplified88.5%
Taylor expanded in z around 0 65.2%
mul-1-neg65.2%
associate-/l*88.5%
+-commutative88.5%
distribute-rgt-neg-in88.5%
neg-sub088.5%
*-lft-identity88.5%
associate-*l/88.3%
distribute-rgt-in88.3%
rgt-mult-inverse88.5%
associate-*r/88.5%
*-rgt-identity88.5%
associate--r+88.5%
metadata-eval88.5%
Simplified88.5%
if -2e21 < y < 8.19999999999999977e-52Initial program 99.9%
Taylor expanded in z around inf 78.5%
+-commutative78.5%
Simplified78.5%
if 8.19999999999999977e-52 < y < 3.6e9Initial program 99.8%
Taylor expanded in x around inf 76.5%
if 3.6e9 < y < 1.7000000000000001e139Initial program 91.5%
Taylor expanded in x around 0 76.8%
Final simplification81.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.7e+21) (not (<= y 1.1e+47))) (* z (- -1.0 (/ x y))) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.7e+21) || !(y <= 1.1e+47)) {
tmp = z * (-1.0 - (x / y));
} else {
tmp = x + y;
}
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+21)) .or. (.not. (y <= 1.1d+47))) then
tmp = z * ((-1.0d0) - (x / y))
else
tmp = x + y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.7e+21) || !(y <= 1.1e+47)) {
tmp = z * (-1.0 - (x / y));
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.7e+21) or not (y <= 1.1e+47): tmp = z * (-1.0 - (x / y)) else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.7e+21) || !(y <= 1.1e+47)) tmp = Float64(z * Float64(-1.0 - Float64(x / y))); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.7e+21) || ~((y <= 1.1e+47))) tmp = z * (-1.0 - (x / y)); else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.7e+21], N[Not[LessEqual[y, 1.1e+47]], $MachinePrecision]], N[(z * N[(-1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.7 \cdot 10^{+21} \lor \neg \left(y \leq 1.1 \cdot 10^{+47}\right):\\
\;\;\;\;z \cdot \left(-1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -1.7e21 or 1.1e47 < y Initial program 69.8%
Taylor expanded in z around 0 63.9%
mul-1-neg63.9%
associate-/l*81.4%
distribute-rgt-neg-in81.4%
distribute-neg-frac281.4%
+-commutative81.4%
Simplified81.4%
Taylor expanded in z around 0 63.9%
mul-1-neg63.9%
associate-/l*81.4%
+-commutative81.4%
distribute-rgt-neg-in81.4%
neg-sub081.4%
*-lft-identity81.4%
associate-*l/81.3%
distribute-rgt-in81.3%
rgt-mult-inverse81.4%
associate-*r/81.5%
*-rgt-identity81.5%
associate--r+81.5%
metadata-eval81.5%
Simplified81.5%
if -1.7e21 < y < 1.1e47Initial program 99.9%
Taylor expanded in z around inf 74.8%
+-commutative74.8%
Simplified74.8%
Final simplification77.6%
(FPCore (x y z) :precision binary64 (if (<= y -3.9) (- z) (if (<= y 0.68) x (if (<= y 1.45e+47) y (- z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.9) {
tmp = -z;
} else if (y <= 0.68) {
tmp = x;
} else if (y <= 1.45e+47) {
tmp = y;
} else {
tmp = -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) :: tmp
if (y <= (-3.9d0)) then
tmp = -z
else if (y <= 0.68d0) then
tmp = x
else if (y <= 1.45d+47) then
tmp = y
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -3.9) {
tmp = -z;
} else if (y <= 0.68) {
tmp = x;
} else if (y <= 1.45e+47) {
tmp = y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.9: tmp = -z elif y <= 0.68: tmp = x elif y <= 1.45e+47: tmp = y else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.9) tmp = Float64(-z); elseif (y <= 0.68) tmp = x; elseif (y <= 1.45e+47) tmp = y; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.9) tmp = -z; elseif (y <= 0.68) tmp = x; elseif (y <= 1.45e+47) tmp = y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.9], (-z), If[LessEqual[y, 0.68], x, If[LessEqual[y, 1.45e+47], y, (-z)]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.9:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 0.68:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.45 \cdot 10^{+47}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -3.89999999999999991 or 1.4499999999999999e47 < y Initial program 71.4%
Taylor expanded in y around inf 65.6%
neg-mul-165.6%
Simplified65.6%
if -3.89999999999999991 < y < 0.680000000000000049Initial program 99.9%
Taylor expanded in y around 0 58.7%
if 0.680000000000000049 < y < 1.4499999999999999e47Initial program 100.0%
Taylor expanded in z around inf 78.8%
+-commutative78.8%
Simplified78.8%
Taylor expanded in y around inf 64.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.5e+21) (not (<= y 1.3e+88))) (- z) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.5e+21) || !(y <= 1.3e+88)) {
tmp = -z;
} else {
tmp = x + y;
}
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.5d+21)) .or. (.not. (y <= 1.3d+88))) then
tmp = -z
else
tmp = x + y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -6.5e+21) || !(y <= 1.3e+88)) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.5e+21) or not (y <= 1.3e+88): tmp = -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.5e+21) || !(y <= 1.3e+88)) tmp = Float64(-z); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -6.5e+21) || ~((y <= 1.3e+88))) tmp = -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.5e+21], N[Not[LessEqual[y, 1.3e+88]], $MachinePrecision]], (-z), N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{+21} \lor \neg \left(y \leq 1.3 \cdot 10^{+88}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -6.5e21 or 1.3e88 < y Initial program 65.5%
Taylor expanded in y around inf 73.1%
neg-mul-173.1%
Simplified73.1%
if -6.5e21 < y < 1.3e88Initial program 99.4%
Taylor expanded in z around inf 71.9%
+-commutative71.9%
Simplified71.9%
Final simplification72.3%
(FPCore (x y z) :precision binary64 (if (<= x -7.6e-89) x (if (<= x 1.75e-196) y x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -7.6e-89) {
tmp = x;
} else if (x <= 1.75e-196) {
tmp = y;
} else {
tmp = x;
}
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 (x <= (-7.6d-89)) then
tmp = x
else if (x <= 1.75d-196) then
tmp = y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -7.6e-89) {
tmp = x;
} else if (x <= 1.75e-196) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -7.6e-89: tmp = x elif x <= 1.75e-196: tmp = y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -7.6e-89) tmp = x; elseif (x <= 1.75e-196) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -7.6e-89) tmp = x; elseif (x <= 1.75e-196) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -7.6e-89], x, If[LessEqual[x, 1.75e-196], y, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.6 \cdot 10^{-89}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.75 \cdot 10^{-196}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -7.6000000000000002e-89 or 1.75000000000000002e-196 < x Initial program 86.5%
Taylor expanded in y around 0 44.4%
if -7.6000000000000002e-89 < x < 1.75000000000000002e-196Initial program 89.9%
Taylor expanded in z around inf 55.1%
+-commutative55.1%
Simplified55.1%
Taylor expanded in y around inf 45.1%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 87.5%
Taylor expanded in y around 0 35.5%
(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 2024144
(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))))