
(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 9 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-254) (not (<= t_0 5e-290)))
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-254) || !(t_0 <= 5e-290)) {
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-254)) .or. (.not. (t_0 <= 5d-290))) 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-254) || !(t_0 <= 5e-290)) {
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-254) or not (t_0 <= 5e-290): 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-254) || !(t_0 <= 5e-290)) 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-254) || ~((t_0 <= 5e-290))) 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-254], N[Not[LessEqual[t$95$0, 5e-290]], $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^{-254} \lor \neg \left(t\_0 \leq 5 \cdot 10^{-290}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-z}{\frac{y}{x + y}}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -9.9999999999999991e-255 or 5.0000000000000001e-290 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) Initial program 99.9%
if -9.9999999999999991e-255 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < 5.0000000000000001e-290Initial program 17.4%
Taylor expanded in z around 0 94.5%
mul-1-neg94.5%
associate-/l*99.9%
distribute-neg-frac99.9%
+-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (- 1.0 (/ y z)))))
(if (<= y -1.65e+210)
(- z)
(if (<= y -1.16e-51)
t_0
(if (<= y 7.5e-29) (+ x y) (if (<= y 6.5e+194) t_0 (- z)))))))
double code(double x, double y, double z) {
double t_0 = y / (1.0 - (y / z));
double tmp;
if (y <= -1.65e+210) {
tmp = -z;
} else if (y <= -1.16e-51) {
tmp = t_0;
} else if (y <= 7.5e-29) {
tmp = x + y;
} else if (y <= 6.5e+194) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = y / (1.0d0 - (y / z))
if (y <= (-1.65d+210)) then
tmp = -z
else if (y <= (-1.16d-51)) then
tmp = t_0
else if (y <= 7.5d-29) then
tmp = x + y
else if (y <= 6.5d+194) then
tmp = t_0
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y / (1.0 - (y / z));
double tmp;
if (y <= -1.65e+210) {
tmp = -z;
} else if (y <= -1.16e-51) {
tmp = t_0;
} else if (y <= 7.5e-29) {
tmp = x + y;
} else if (y <= 6.5e+194) {
tmp = t_0;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): t_0 = y / (1.0 - (y / z)) tmp = 0 if y <= -1.65e+210: tmp = -z elif y <= -1.16e-51: tmp = t_0 elif y <= 7.5e-29: tmp = x + y elif y <= 6.5e+194: tmp = t_0 else: tmp = -z return tmp
function code(x, y, z) t_0 = Float64(y / Float64(1.0 - Float64(y / z))) tmp = 0.0 if (y <= -1.65e+210) tmp = Float64(-z); elseif (y <= -1.16e-51) tmp = t_0; elseif (y <= 7.5e-29) tmp = Float64(x + y); elseif (y <= 6.5e+194) tmp = t_0; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y / (1.0 - (y / z)); tmp = 0.0; if (y <= -1.65e+210) tmp = -z; elseif (y <= -1.16e-51) tmp = t_0; elseif (y <= 7.5e-29) tmp = x + y; elseif (y <= 6.5e+194) tmp = t_0; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.65e+210], (-z), If[LessEqual[y, -1.16e-51], t$95$0, If[LessEqual[y, 7.5e-29], N[(x + y), $MachinePrecision], If[LessEqual[y, 6.5e+194], t$95$0, (-z)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{1 - \frac{y}{z}}\\
\mathbf{if}\;y \leq -1.65 \cdot 10^{+210}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -1.16 \cdot 10^{-51}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{-29}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq 6.5 \cdot 10^{+194}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -1.64999999999999997e210 or 6.50000000000000005e194 < y Initial program 59.6%
Taylor expanded in y around inf 84.7%
mul-1-neg84.7%
Simplified84.7%
if -1.64999999999999997e210 < y < -1.1600000000000001e-51 or 7.50000000000000006e-29 < y < 6.50000000000000005e194Initial program 88.7%
Taylor expanded in x around 0 71.2%
if -1.1600000000000001e-51 < y < 7.50000000000000006e-29Initial program 99.9%
Taylor expanded in z around inf 80.7%
+-commutative80.7%
Simplified80.7%
Final simplification77.6%
(FPCore (x y z)
:precision binary64
(if (or (<= y -2.65e+129)
(and (not (<= y 19000000000.0))
(or (<= y 1.42e+134) (not (<= y 1.05e+158)))))
(- z)
(+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.65e+129) || (!(y <= 19000000000.0) && ((y <= 1.42e+134) || !(y <= 1.05e+158)))) {
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 <= (-2.65d+129)) .or. (.not. (y <= 19000000000.0d0)) .and. (y <= 1.42d+134) .or. (.not. (y <= 1.05d+158))) 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 <= -2.65e+129) || (!(y <= 19000000000.0) && ((y <= 1.42e+134) || !(y <= 1.05e+158)))) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.65e+129) or (not (y <= 19000000000.0) and ((y <= 1.42e+134) or not (y <= 1.05e+158))): tmp = -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.65e+129) || (!(y <= 19000000000.0) && ((y <= 1.42e+134) || !(y <= 1.05e+158)))) tmp = Float64(-z); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.65e+129) || (~((y <= 19000000000.0)) && ((y <= 1.42e+134) || ~((y <= 1.05e+158))))) tmp = -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.65e+129], And[N[Not[LessEqual[y, 19000000000.0]], $MachinePrecision], Or[LessEqual[y, 1.42e+134], N[Not[LessEqual[y, 1.05e+158]], $MachinePrecision]]]], (-z), N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.65 \cdot 10^{+129} \lor \neg \left(y \leq 19000000000\right) \land \left(y \leq 1.42 \cdot 10^{+134} \lor \neg \left(y \leq 1.05 \cdot 10^{+158}\right)\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -2.6499999999999999e129 or 1.9e10 < y < 1.42000000000000002e134 or 1.0499999999999999e158 < y Initial program 75.0%
Taylor expanded in y around inf 66.5%
mul-1-neg66.5%
Simplified66.5%
if -2.6499999999999999e129 < y < 1.9e10 or 1.42000000000000002e134 < y < 1.0499999999999999e158Initial program 97.6%
Taylor expanded in z around inf 73.9%
+-commutative73.9%
Simplified73.9%
Final simplification71.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.15e+24) (not (<= z 6.2e-53))) (+ x y) (/ (* (- z) (+ x y)) y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.15e+24) || !(z <= 6.2e-53)) {
tmp = x + y;
} else {
tmp = (-z * (x + y)) / 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 ((z <= (-1.15d+24)) .or. (.not. (z <= 6.2d-53))) then
tmp = x + y
else
tmp = (-z * (x + y)) / y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.15e+24) || !(z <= 6.2e-53)) {
tmp = x + y;
} else {
tmp = (-z * (x + y)) / y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.15e+24) or not (z <= 6.2e-53): tmp = x + y else: tmp = (-z * (x + y)) / y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.15e+24) || !(z <= 6.2e-53)) tmp = Float64(x + y); else tmp = Float64(Float64(Float64(-z) * Float64(x + y)) / y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.15e+24) || ~((z <= 6.2e-53))) tmp = x + y; else tmp = (-z * (x + y)) / y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.15e+24], N[Not[LessEqual[z, 6.2e-53]], $MachinePrecision]], N[(x + y), $MachinePrecision], N[(N[((-z) * N[(x + y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.15 \cdot 10^{+24} \lor \neg \left(z \leq 6.2 \cdot 10^{-53}\right):\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-z\right) \cdot \left(x + y\right)}{y}\\
\end{array}
\end{array}
if z < -1.15e24 or 6.20000000000000031e-53 < z Initial program 99.2%
Taylor expanded in z around inf 78.4%
+-commutative78.4%
Simplified78.4%
if -1.15e24 < z < 6.20000000000000031e-53Initial program 76.3%
flip--49.8%
associate-/r/47.6%
metadata-eval47.6%
pow247.6%
Applied egg-rr47.6%
unpow247.6%
clear-num47.5%
un-div-inv47.5%
Applied egg-rr47.5%
Taylor expanded in z around 0 74.8%
mul-1-neg74.8%
+-commutative74.8%
Simplified74.8%
Final simplification76.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.8e+23) (not (<= z 6.2e-53))) (+ x y) (/ (- z) (/ y (+ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.8e+23) || !(z <= 6.2e-53)) {
tmp = x + y;
} 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) :: tmp
if ((z <= (-2.8d+23)) .or. (.not. (z <= 6.2d-53))) then
tmp = x + y
else
tmp = -z / (y / (x + y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.8e+23) || !(z <= 6.2e-53)) {
tmp = x + y;
} else {
tmp = -z / (y / (x + y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.8e+23) or not (z <= 6.2e-53): tmp = x + y else: tmp = -z / (y / (x + y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.8e+23) || !(z <= 6.2e-53)) tmp = Float64(x + y); else tmp = Float64(Float64(-z) / Float64(y / Float64(x + y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.8e+23) || ~((z <= 6.2e-53))) tmp = x + y; else tmp = -z / (y / (x + y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.8e+23], N[Not[LessEqual[z, 6.2e-53]], $MachinePrecision]], N[(x + y), $MachinePrecision], N[((-z) / N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.8 \cdot 10^{+23} \lor \neg \left(z \leq 6.2 \cdot 10^{-53}\right):\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;\frac{-z}{\frac{y}{x + y}}\\
\end{array}
\end{array}
if z < -2.8e23 or 6.20000000000000031e-53 < z Initial program 99.2%
Taylor expanded in z around inf 78.4%
+-commutative78.4%
Simplified78.4%
if -2.8e23 < z < 6.20000000000000031e-53Initial program 76.3%
Taylor expanded in z around 0 74.8%
mul-1-neg74.8%
associate-/l*76.9%
distribute-neg-frac76.9%
+-commutative76.9%
Simplified76.9%
Final simplification77.7%
(FPCore (x y z) :precision binary64 (if (<= z -5.2e+24) (* (+ x y) (+ 1.0 (/ y z))) (if (<= z 9.2e-53) (/ (- z) (/ y (+ x y))) (+ x y))))
double code(double x, double y, double z) {
double tmp;
if (z <= -5.2e+24) {
tmp = (x + y) * (1.0 + (y / z));
} else if (z <= 9.2e-53) {
tmp = -z / (y / (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 (z <= (-5.2d+24)) then
tmp = (x + y) * (1.0d0 + (y / z))
else if (z <= 9.2d-53) then
tmp = -z / (y / (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 (z <= -5.2e+24) {
tmp = (x + y) * (1.0 + (y / z));
} else if (z <= 9.2e-53) {
tmp = -z / (y / (x + y));
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -5.2e+24: tmp = (x + y) * (1.0 + (y / z)) elif z <= 9.2e-53: tmp = -z / (y / (x + y)) else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if (z <= -5.2e+24) tmp = Float64(Float64(x + y) * Float64(1.0 + Float64(y / z))); elseif (z <= 9.2e-53) tmp = Float64(Float64(-z) / Float64(y / Float64(x + y))); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -5.2e+24) tmp = (x + y) * (1.0 + (y / z)); elseif (z <= 9.2e-53) tmp = -z / (y / (x + y)); else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -5.2e+24], N[(N[(x + y), $MachinePrecision] * N[(1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 9.2e-53], N[((-z) / N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.2 \cdot 10^{+24}:\\
\;\;\;\;\left(x + y\right) \cdot \left(1 + \frac{y}{z}\right)\\
\mathbf{elif}\;z \leq 9.2 \cdot 10^{-53}:\\
\;\;\;\;\frac{-z}{\frac{y}{x + y}}\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if z < -5.1999999999999997e24Initial program 99.9%
Taylor expanded in z around inf 70.9%
associate-+r+70.9%
*-lft-identity70.9%
associate-/l*84.5%
associate-/r/84.5%
distribute-rgt-in84.5%
+-commutative84.5%
Simplified84.5%
if -5.1999999999999997e24 < z < 9.2000000000000005e-53Initial program 76.3%
Taylor expanded in z around 0 74.8%
mul-1-neg74.8%
associate-/l*76.9%
distribute-neg-frac76.9%
+-commutative76.9%
Simplified76.9%
if 9.2000000000000005e-53 < z Initial program 98.9%
Taylor expanded in z around inf 75.2%
+-commutative75.2%
Simplified75.2%
Final simplification77.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.5e-55) (not (<= y 1.5e-24))) (- z) x))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.5e-55) || !(y <= 1.5e-24)) {
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 <= (-6.5d-55)) .or. (.not. (y <= 1.5d-24))) 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 <= -6.5e-55) || !(y <= 1.5e-24)) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.5e-55) or not (y <= 1.5e-24): tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.5e-55) || !(y <= 1.5e-24)) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -6.5e-55) || ~((y <= 1.5e-24))) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.5e-55], N[Not[LessEqual[y, 1.5e-24]], $MachinePrecision]], (-z), x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{-55} \lor \neg \left(y \leq 1.5 \cdot 10^{-24}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -6.50000000000000006e-55 or 1.49999999999999998e-24 < y Initial program 80.1%
Taylor expanded in y around inf 56.4%
mul-1-neg56.4%
Simplified56.4%
if -6.50000000000000006e-55 < y < 1.49999999999999998e-24Initial program 99.9%
Taylor expanded in y around 0 59.8%
Final simplification57.9%
(FPCore (x y z) :precision binary64 (if (<= y -5.2e-61) y (if (<= y 1.55e-74) x y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.2e-61) {
tmp = y;
} else if (y <= 1.55e-74) {
tmp = x;
} else {
tmp = 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 <= (-5.2d-61)) then
tmp = y
else if (y <= 1.55d-74) then
tmp = x
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5.2e-61) {
tmp = y;
} else if (y <= 1.55e-74) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.2e-61: tmp = y elif y <= 1.55e-74: tmp = x else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.2e-61) tmp = y; elseif (y <= 1.55e-74) tmp = x; else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5.2e-61) tmp = y; elseif (y <= 1.55e-74) tmp = x; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.2e-61], y, If[LessEqual[y, 1.55e-74], x, y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.2 \cdot 10^{-61}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 1.55 \cdot 10^{-74}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -5.20000000000000021e-61 or 1.5500000000000001e-74 < y Initial program 81.7%
Taylor expanded in x around 0 65.5%
Taylor expanded in y around 0 29.1%
if -5.20000000000000021e-61 < y < 1.5500000000000001e-74Initial program 99.9%
Taylor expanded in y around 0 62.6%
Final simplification42.4%
(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 88.9%
Taylor expanded in y around 0 30.7%
Final simplification30.7%
(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 2024031
(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))))