
(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 -2e-266) (not (<= t_0 2e-215)))
t_0
(- (- z) (* z (/ x y))))))
double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -2e-266) || !(t_0 <= 2e-215)) {
tmp = t_0;
} else {
tmp = -z - (z * (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 <= (-2d-266)) .or. (.not. (t_0 <= 2d-215))) then
tmp = t_0
else
tmp = -z - (z * (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 <= -2e-266) || !(t_0 <= 2e-215)) {
tmp = t_0;
} else {
tmp = -z - (z * (x / y));
}
return tmp;
}
def code(x, y, z): t_0 = (x + y) / (1.0 - (y / z)) tmp = 0 if (t_0 <= -2e-266) or not (t_0 <= 2e-215): tmp = t_0 else: tmp = -z - (z * (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 <= -2e-266) || !(t_0 <= 2e-215)) tmp = t_0; else tmp = Float64(Float64(-z) - Float64(z * 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 <= -2e-266) || ~((t_0 <= 2e-215))) tmp = t_0; else tmp = -z - (z * (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, -2e-266], N[Not[LessEqual[t$95$0, 2e-215]], $MachinePrecision]], t$95$0, N[((-z) - N[(z * 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 -2 \cdot 10^{-266} \lor \neg \left(t_0 \leq 2 \cdot 10^{-215}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - z \cdot \frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -2e-266 or 2.00000000000000008e-215 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) Initial program 99.9%
if -2e-266 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < 2.00000000000000008e-215Initial program 18.6%
clear-num18.6%
associate-/r/18.6%
Applied egg-rr18.6%
Taylor expanded in z around 0 91.1%
mul-1-neg91.1%
associate-/l*99.7%
+-commutative99.7%
associate-/r/21.9%
distribute-rgt-in21.9%
distribute-neg-in21.9%
*-commutative21.9%
associate-*l/75.5%
associate-/l*84.3%
*-inverses84.3%
/-rgt-identity84.3%
unsub-neg84.3%
associate-*r/99.2%
unsub-neg99.2%
mul-1-neg99.2%
+-commutative99.2%
unsub-neg99.2%
mul-1-neg99.2%
associate-/l*82.8%
distribute-neg-frac82.8%
Simplified82.8%
frac-2neg82.8%
associate-/r/99.9%
frac-2neg99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ y z))) (t_1 (/ x t_0)) (t_2 (* z (- -1.0 (/ x y)))))
(if (<= y -5e+46)
t_2
(if (<= y -540000000000.0)
t_1
(if (<= y -7.5e-34)
(/ y t_0)
(if (<= y -1.05e-163) t_1 (if (<= y 1.95e+14) (+ x y) t_2)))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = x / t_0;
double t_2 = z * (-1.0 - (x / y));
double tmp;
if (y <= -5e+46) {
tmp = t_2;
} else if (y <= -540000000000.0) {
tmp = t_1;
} else if (y <= -7.5e-34) {
tmp = y / t_0;
} else if (y <= -1.05e-163) {
tmp = t_1;
} else if (y <= 1.95e+14) {
tmp = x + y;
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: tmp
t_0 = 1.0d0 - (y / z)
t_1 = x / t_0
t_2 = z * ((-1.0d0) - (x / y))
if (y <= (-5d+46)) then
tmp = t_2
else if (y <= (-540000000000.0d0)) then
tmp = t_1
else if (y <= (-7.5d-34)) then
tmp = y / t_0
else if (y <= (-1.05d-163)) then
tmp = t_1
else if (y <= 1.95d+14) then
tmp = x + y
else
tmp = t_2
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 = x / t_0;
double t_2 = z * (-1.0 - (x / y));
double tmp;
if (y <= -5e+46) {
tmp = t_2;
} else if (y <= -540000000000.0) {
tmp = t_1;
} else if (y <= -7.5e-34) {
tmp = y / t_0;
} else if (y <= -1.05e-163) {
tmp = t_1;
} else if (y <= 1.95e+14) {
tmp = x + y;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) t_1 = x / t_0 t_2 = z * (-1.0 - (x / y)) tmp = 0 if y <= -5e+46: tmp = t_2 elif y <= -540000000000.0: tmp = t_1 elif y <= -7.5e-34: tmp = y / t_0 elif y <= -1.05e-163: tmp = t_1 elif y <= 1.95e+14: tmp = x + y else: tmp = t_2 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y / z)) t_1 = Float64(x / t_0) t_2 = Float64(z * Float64(-1.0 - Float64(x / y))) tmp = 0.0 if (y <= -5e+46) tmp = t_2; elseif (y <= -540000000000.0) tmp = t_1; elseif (y <= -7.5e-34) tmp = Float64(y / t_0); elseif (y <= -1.05e-163) tmp = t_1; elseif (y <= 1.95e+14) tmp = Float64(x + y); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y / z); t_1 = x / t_0; t_2 = z * (-1.0 - (x / y)); tmp = 0.0; if (y <= -5e+46) tmp = t_2; elseif (y <= -540000000000.0) tmp = t_1; elseif (y <= -7.5e-34) tmp = y / t_0; elseif (y <= -1.05e-163) tmp = t_1; elseif (y <= 1.95e+14) tmp = x + y; else tmp = t_2; 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[(x / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(z * N[(-1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5e+46], t$95$2, If[LessEqual[y, -540000000000.0], t$95$1, If[LessEqual[y, -7.5e-34], N[(y / t$95$0), $MachinePrecision], If[LessEqual[y, -1.05e-163], t$95$1, If[LessEqual[y, 1.95e+14], N[(x + y), $MachinePrecision], t$95$2]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
t_1 := \frac{x}{t_0}\\
t_2 := z \cdot \left(-1 - \frac{x}{y}\right)\\
\mathbf{if}\;y \leq -5 \cdot 10^{+46}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;y \leq -540000000000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -7.5 \cdot 10^{-34}:\\
\;\;\;\;\frac{y}{t_0}\\
\mathbf{elif}\;y \leq -1.05 \cdot 10^{-163}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 1.95 \cdot 10^{+14}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if y < -5.0000000000000002e46 or 1.95e14 < y Initial program 76.3%
clear-num76.1%
associate-/r/76.1%
Applied egg-rr76.1%
Taylor expanded in z around 0 63.2%
mul-1-neg63.2%
associate-/l*77.9%
+-commutative77.9%
associate-/r/55.3%
distribute-rgt-in55.4%
distribute-neg-in55.4%
*-commutative55.4%
associate-*l/59.4%
associate-/l*73.5%
*-inverses73.5%
/-rgt-identity73.5%
unsub-neg73.5%
associate-*r/73.1%
unsub-neg73.1%
mul-1-neg73.1%
+-commutative73.1%
unsub-neg73.1%
mul-1-neg73.1%
associate-/l*73.1%
distribute-neg-frac73.1%
Simplified73.1%
Taylor expanded in x around 0 73.1%
neg-mul-173.1%
mul-1-neg73.1%
associate-*l/78.0%
distribute-lft-neg-in78.0%
cancel-sign-sub-inv78.0%
neg-mul-178.0%
distribute-rgt-out--78.0%
Simplified78.0%
if -5.0000000000000002e46 < y < -5.4e11 or -7.5000000000000004e-34 < y < -1.04999999999999999e-163Initial program 99.8%
Taylor expanded in x around inf 84.2%
if -5.4e11 < y < -7.5000000000000004e-34Initial program 99.8%
Taylor expanded in x around 0 85.9%
if -1.04999999999999999e-163 < y < 1.95e14Initial program 100.0%
Taylor expanded in z around inf 86.2%
+-commutative86.2%
Simplified86.2%
Final simplification82.5%
(FPCore (x y z)
:precision binary64
(if (<= y -1.36e+51)
(- z)
(if (<= y 2.7e+28)
(+ x y)
(if (<= y 9e+85) (/ (- z) (/ y x)) (if (<= y 8e+130) (+ x y) (- z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.36e+51) {
tmp = -z;
} else if (y <= 2.7e+28) {
tmp = x + y;
} else if (y <= 9e+85) {
tmp = -z / (y / x);
} else if (y <= 8e+130) {
tmp = x + 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 <= (-1.36d+51)) then
tmp = -z
else if (y <= 2.7d+28) then
tmp = x + y
else if (y <= 9d+85) then
tmp = -z / (y / x)
else if (y <= 8d+130) then
tmp = x + y
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.36e+51) {
tmp = -z;
} else if (y <= 2.7e+28) {
tmp = x + y;
} else if (y <= 9e+85) {
tmp = -z / (y / x);
} else if (y <= 8e+130) {
tmp = x + y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.36e+51: tmp = -z elif y <= 2.7e+28: tmp = x + y elif y <= 9e+85: tmp = -z / (y / x) elif y <= 8e+130: tmp = x + y else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.36e+51) tmp = Float64(-z); elseif (y <= 2.7e+28) tmp = Float64(x + y); elseif (y <= 9e+85) tmp = Float64(Float64(-z) / Float64(y / x)); elseif (y <= 8e+130) tmp = Float64(x + y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.36e+51) tmp = -z; elseif (y <= 2.7e+28) tmp = x + y; elseif (y <= 9e+85) tmp = -z / (y / x); elseif (y <= 8e+130) tmp = x + y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.36e+51], (-z), If[LessEqual[y, 2.7e+28], N[(x + y), $MachinePrecision], If[LessEqual[y, 9e+85], N[((-z) / N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8e+130], N[(x + y), $MachinePrecision], (-z)]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.36 \cdot 10^{+51}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{+28}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq 9 \cdot 10^{+85}:\\
\;\;\;\;\frac{-z}{\frac{y}{x}}\\
\mathbf{elif}\;y \leq 8 \cdot 10^{+130}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -1.3599999999999999e51 or 8.0000000000000005e130 < y Initial program 73.6%
Taylor expanded in y around inf 73.7%
mul-1-neg73.7%
Simplified73.7%
if -1.3599999999999999e51 < y < 2.7000000000000002e28 or 9.00000000000000013e85 < y < 8.0000000000000005e130Initial program 98.2%
Taylor expanded in z around inf 77.8%
+-commutative77.8%
Simplified77.8%
if 2.7000000000000002e28 < y < 9.00000000000000013e85Initial program 79.2%
Taylor expanded in x around inf 41.5%
Taylor expanded in y around inf 47.2%
mul-1-neg47.2%
associate-*r/41.8%
distribute-lft-neg-out41.8%
*-commutative41.8%
Simplified41.8%
Taylor expanded in z around 0 47.2%
associate-*r/47.2%
*-commutative47.2%
neg-mul-147.2%
distribute-lft-neg-out47.2%
associate-/l*46.9%
Simplified46.9%
Final simplification74.5%
(FPCore (x y z)
:precision binary64
(if (<= y -1.65e+52)
(- z)
(if (<= y 2.7e+28)
(+ x y)
(if (<= y 8.5e+85) (/ (* x z) (- y)) (if (<= y 6e+129) (+ x y) (- z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.65e+52) {
tmp = -z;
} else if (y <= 2.7e+28) {
tmp = x + y;
} else if (y <= 8.5e+85) {
tmp = (x * z) / -y;
} else if (y <= 6e+129) {
tmp = x + 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 <= (-1.65d+52)) then
tmp = -z
else if (y <= 2.7d+28) then
tmp = x + y
else if (y <= 8.5d+85) then
tmp = (x * z) / -y
else if (y <= 6d+129) then
tmp = x + y
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.65e+52) {
tmp = -z;
} else if (y <= 2.7e+28) {
tmp = x + y;
} else if (y <= 8.5e+85) {
tmp = (x * z) / -y;
} else if (y <= 6e+129) {
tmp = x + y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.65e+52: tmp = -z elif y <= 2.7e+28: tmp = x + y elif y <= 8.5e+85: tmp = (x * z) / -y elif y <= 6e+129: tmp = x + y else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.65e+52) tmp = Float64(-z); elseif (y <= 2.7e+28) tmp = Float64(x + y); elseif (y <= 8.5e+85) tmp = Float64(Float64(x * z) / Float64(-y)); elseif (y <= 6e+129) tmp = Float64(x + y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.65e+52) tmp = -z; elseif (y <= 2.7e+28) tmp = x + y; elseif (y <= 8.5e+85) tmp = (x * z) / -y; elseif (y <= 6e+129) tmp = x + y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.65e+52], (-z), If[LessEqual[y, 2.7e+28], N[(x + y), $MachinePrecision], If[LessEqual[y, 8.5e+85], N[(N[(x * z), $MachinePrecision] / (-y)), $MachinePrecision], If[LessEqual[y, 6e+129], N[(x + y), $MachinePrecision], (-z)]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.65 \cdot 10^{+52}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{+28}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{+85}:\\
\;\;\;\;\frac{x \cdot z}{-y}\\
\mathbf{elif}\;y \leq 6 \cdot 10^{+129}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -1.65e52 or 6.0000000000000006e129 < y Initial program 73.6%
Taylor expanded in y around inf 73.7%
mul-1-neg73.7%
Simplified73.7%
if -1.65e52 < y < 2.7000000000000002e28 or 8.4999999999999994e85 < y < 6.0000000000000006e129Initial program 98.2%
Taylor expanded in z around inf 77.8%
+-commutative77.8%
Simplified77.8%
if 2.7000000000000002e28 < y < 8.4999999999999994e85Initial program 79.2%
Taylor expanded in x around inf 41.5%
Taylor expanded in y around inf 47.2%
mul-1-neg47.2%
associate-*r/41.8%
distribute-lft-neg-out41.8%
*-commutative41.8%
Simplified41.8%
add-sqr-sqrt29.6%
sqrt-unprod20.4%
sqr-neg20.4%
sqrt-unprod1.3%
add-sqr-sqrt3.9%
associate-*l/3.8%
associate-*r/3.8%
frac-2neg3.8%
associate-*r/3.8%
add-sqr-sqrt2.5%
sqrt-unprod8.9%
sqr-neg8.9%
sqrt-unprod11.9%
add-sqr-sqrt47.2%
Applied egg-rr47.2%
Final simplification74.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -4e+48) (not (<= y 1.38e+14))) (* z (- -1.0 (/ x y))) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4e+48) || !(y <= 1.38e+14)) {
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 <= (-4d+48)) .or. (.not. (y <= 1.38d+14))) 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 <= -4e+48) || !(y <= 1.38e+14)) {
tmp = z * (-1.0 - (x / y));
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4e+48) or not (y <= 1.38e+14): tmp = z * (-1.0 - (x / y)) else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4e+48) || !(y <= 1.38e+14)) 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 <= -4e+48) || ~((y <= 1.38e+14))) tmp = z * (-1.0 - (x / y)); else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4e+48], N[Not[LessEqual[y, 1.38e+14]], $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 -4 \cdot 10^{+48} \lor \neg \left(y \leq 1.38 \cdot 10^{+14}\right):\\
\;\;\;\;z \cdot \left(-1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -4.00000000000000018e48 or 1.38e14 < y Initial program 76.1%
clear-num75.9%
associate-/r/75.9%
Applied egg-rr75.9%
Taylor expanded in z around 0 63.8%
mul-1-neg63.8%
associate-/l*78.6%
+-commutative78.6%
associate-/r/55.8%
distribute-rgt-in55.8%
distribute-neg-in55.8%
*-commutative55.8%
associate-*l/59.9%
associate-/l*74.1%
*-inverses74.1%
/-rgt-identity74.1%
unsub-neg74.1%
associate-*r/73.7%
unsub-neg73.7%
mul-1-neg73.7%
+-commutative73.7%
unsub-neg73.7%
mul-1-neg73.7%
associate-/l*73.7%
distribute-neg-frac73.7%
Simplified73.7%
Taylor expanded in x around 0 73.7%
neg-mul-173.7%
mul-1-neg73.7%
associate-*l/78.7%
distribute-lft-neg-in78.7%
cancel-sign-sub-inv78.7%
neg-mul-178.7%
distribute-rgt-out--78.7%
Simplified78.7%
if -4.00000000000000018e48 < y < 1.38e14Initial program 99.9%
Taylor expanded in z around inf 80.5%
+-commutative80.5%
Simplified80.5%
Final simplification79.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.5e+51) (not (<= y 1.3e+133))) (- z) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.5e+51) || !(y <= 1.3e+133)) {
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+51)) .or. (.not. (y <= 1.3d+133))) 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+51) || !(y <= 1.3e+133)) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.5e+51) or not (y <= 1.3e+133): tmp = -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.5e+51) || !(y <= 1.3e+133)) 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+51) || ~((y <= 1.3e+133))) tmp = -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.5e+51], N[Not[LessEqual[y, 1.3e+133]], $MachinePrecision]], (-z), N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{+51} \lor \neg \left(y \leq 1.3 \cdot 10^{+133}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -6.5e51 or 1.2999999999999999e133 < y Initial program 73.6%
Taylor expanded in y around inf 73.7%
mul-1-neg73.7%
Simplified73.7%
if -6.5e51 < y < 1.2999999999999999e133Initial program 96.3%
Taylor expanded in z around inf 72.6%
+-commutative72.6%
Simplified72.6%
Final simplification72.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.45e+46) (not (<= y 1.36e+14))) (- z) x))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.45e+46) || !(y <= 1.36e+14)) {
tmp = -z;
} 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 ((y <= (-1.45d+46)) .or. (.not. (y <= 1.36d+14))) then
tmp = -z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.45e+46) || !(y <= 1.36e+14)) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.45e+46) or not (y <= 1.36e+14): tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.45e+46) || !(y <= 1.36e+14)) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.45e+46) || ~((y <= 1.36e+14))) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.45e+46], N[Not[LessEqual[y, 1.36e+14]], $MachinePrecision]], (-z), x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.45 \cdot 10^{+46} \lor \neg \left(y \leq 1.36 \cdot 10^{+14}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1.4500000000000001e46 or 1.36e14 < y Initial program 76.3%
Taylor expanded in y around inf 59.1%
mul-1-neg59.1%
Simplified59.1%
if -1.4500000000000001e46 < y < 1.36e14Initial program 99.9%
Taylor expanded in y around 0 63.9%
Final simplification61.9%
(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 90.0%
Taylor expanded in y around 0 41.0%
Final simplification41.0%
(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 2024013
(FPCore (x y z)
:name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A"
:precision binary64
:herbie-target
(if (< y -3.7429310762689856e+171) (* (/ (+ y x) (- y)) z) (if (< y 3.5534662456086734e+168) (/ (+ x y) (- 1.0 (/ y z))) (* (/ (+ y x) (- y)) z)))
(/ (+ x y) (- 1.0 (/ y z))))