
(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.75e+210)
(- z)
(if (<= y -6.5e-52)
t_0
(if (<= y 1.05e-26) (+ x y) (if (<= y 5.8e+192) t_0 (- z)))))))
double code(double x, double y, double z) {
double t_0 = y / (1.0 - (y / z));
double tmp;
if (y <= -1.75e+210) {
tmp = -z;
} else if (y <= -6.5e-52) {
tmp = t_0;
} else if (y <= 1.05e-26) {
tmp = x + y;
} else if (y <= 5.8e+192) {
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.75d+210)) then
tmp = -z
else if (y <= (-6.5d-52)) then
tmp = t_0
else if (y <= 1.05d-26) then
tmp = x + y
else if (y <= 5.8d+192) 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.75e+210) {
tmp = -z;
} else if (y <= -6.5e-52) {
tmp = t_0;
} else if (y <= 1.05e-26) {
tmp = x + y;
} else if (y <= 5.8e+192) {
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.75e+210: tmp = -z elif y <= -6.5e-52: tmp = t_0 elif y <= 1.05e-26: tmp = x + y elif y <= 5.8e+192: 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.75e+210) tmp = Float64(-z); elseif (y <= -6.5e-52) tmp = t_0; elseif (y <= 1.05e-26) tmp = Float64(x + y); elseif (y <= 5.8e+192) 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.75e+210) tmp = -z; elseif (y <= -6.5e-52) tmp = t_0; elseif (y <= 1.05e-26) tmp = x + y; elseif (y <= 5.8e+192) 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.75e+210], (-z), If[LessEqual[y, -6.5e-52], t$95$0, If[LessEqual[y, 1.05e-26], N[(x + y), $MachinePrecision], If[LessEqual[y, 5.8e+192], t$95$0, (-z)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{1 - \frac{y}{z}}\\
\mathbf{if}\;y \leq -1.75 \cdot 10^{+210}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -6.5 \cdot 10^{-52}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{-26}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq 5.8 \cdot 10^{+192}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -1.75e210 or 5.8000000000000003e192 < y Initial program 59.6%
Taylor expanded in y around inf 84.7%
mul-1-neg84.7%
Simplified84.7%
if -1.75e210 < y < -6.5e-52 or 1.05000000000000004e-26 < y < 5.8000000000000003e192Initial program 88.6%
Taylor expanded in x around 0 70.9%
if -6.5e-52 < y < 1.05000000000000004e-26Initial program 99.9%
Taylor expanded in z around inf 80.8%
+-commutative80.8%
Simplified80.8%
Final simplification77.6%
(FPCore (x y z)
:precision binary64
(if (or (<= y -1.75e+129)
(not
(or (<= y 2.2e-18) (and (not (<= y 1.42e+134)) (<= y 1.05e+158)))))
(- z)
(+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.75e+129) || !((y <= 2.2e-18) || (!(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 <= (-1.75d+129)) .or. (.not. (y <= 2.2d-18) .or. (.not. (y <= 1.42d+134)) .and. (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 <= -1.75e+129) || !((y <= 2.2e-18) || (!(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 <= -1.75e+129) or not ((y <= 2.2e-18) or (not (y <= 1.42e+134) and (y <= 1.05e+158))): tmp = -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.75e+129) || !((y <= 2.2e-18) || (!(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 <= -1.75e+129) || ~(((y <= 2.2e-18) || (~((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, -1.75e+129], N[Not[Or[LessEqual[y, 2.2e-18], And[N[Not[LessEqual[y, 1.42e+134]], $MachinePrecision], LessEqual[y, 1.05e+158]]]], $MachinePrecision]], (-z), N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.75 \cdot 10^{+129} \lor \neg \left(y \leq 2.2 \cdot 10^{-18} \lor \neg \left(y \leq 1.42 \cdot 10^{+134}\right) \land y \leq 1.05 \cdot 10^{+158}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -1.7499999999999999e129 or 2.1999999999999998e-18 < y < 1.42000000000000002e134 or 1.0499999999999999e158 < y Initial program 76.2%
Taylor expanded in y around inf 65.3%
mul-1-neg65.3%
Simplified65.3%
if -1.7499999999999999e129 < y < 2.1999999999999998e-18 or 1.42000000000000002e134 < y < 1.0499999999999999e158Initial program 97.5%
Taylor expanded in z around inf 74.9%
+-commutative74.9%
Simplified74.9%
Final simplification71.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -8.4e+24) (not (<= z 1.4e-52))) (+ x y) (/ (* (- z) (+ x y)) y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -8.4e+24) || !(z <= 1.4e-52)) {
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 <= (-8.4d+24)) .or. (.not. (z <= 1.4d-52))) 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 <= -8.4e+24) || !(z <= 1.4e-52)) {
tmp = x + y;
} else {
tmp = (-z * (x + y)) / y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -8.4e+24) or not (z <= 1.4e-52): tmp = x + y else: tmp = (-z * (x + y)) / y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -8.4e+24) || !(z <= 1.4e-52)) 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 <= -8.4e+24) || ~((z <= 1.4e-52))) tmp = x + y; else tmp = (-z * (x + y)) / y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -8.4e+24], N[Not[LessEqual[z, 1.4e-52]], $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 -8.4 \cdot 10^{+24} \lor \neg \left(z \leq 1.4 \cdot 10^{-52}\right):\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-z\right) \cdot \left(x + y\right)}{y}\\
\end{array}
\end{array}
if z < -8.4000000000000005e24 or 1.39999999999999997e-52 < z Initial program 99.2%
Taylor expanded in z around inf 78.5%
+-commutative78.5%
Simplified78.5%
if -8.4000000000000005e24 < z < 1.39999999999999997e-52Initial program 76.1%
flip--50.2%
associate-/r/47.9%
metadata-eval47.9%
pow247.9%
Applied egg-rr47.9%
unpow247.9%
clear-num47.8%
un-div-inv47.9%
Applied egg-rr47.9%
Taylor expanded in z around 0 74.6%
mul-1-neg74.6%
+-commutative74.6%
Simplified74.6%
Final simplification76.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.25e+23) (not (<= z 1.45e-52))) (+ x y) (/ (- z) (/ y (+ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.25e+23) || !(z <= 1.45e-52)) {
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 <= (-1.25d+23)) .or. (.not. (z <= 1.45d-52))) 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 <= -1.25e+23) || !(z <= 1.45e-52)) {
tmp = x + y;
} else {
tmp = -z / (y / (x + y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.25e+23) or not (z <= 1.45e-52): tmp = x + y else: tmp = -z / (y / (x + y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.25e+23) || !(z <= 1.45e-52)) 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 <= -1.25e+23) || ~((z <= 1.45e-52))) tmp = x + y; else tmp = -z / (y / (x + y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.25e+23], N[Not[LessEqual[z, 1.45e-52]], $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 -1.25 \cdot 10^{+23} \lor \neg \left(z \leq 1.45 \cdot 10^{-52}\right):\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;\frac{-z}{\frac{y}{x + y}}\\
\end{array}
\end{array}
if z < -1.25e23 or 1.4500000000000001e-52 < z Initial program 99.2%
Taylor expanded in z around inf 78.5%
+-commutative78.5%
Simplified78.5%
if -1.25e23 < z < 1.4500000000000001e-52Initial program 76.1%
Taylor expanded in z around 0 74.6%
mul-1-neg74.6%
associate-/l*76.6%
distribute-neg-frac76.6%
+-commutative76.6%
Simplified76.6%
Final simplification77.7%
(FPCore (x y z) :precision binary64 (if (<= z -1.22e+23) (* (+ x y) (+ 1.0 (/ y z))) (if (<= z 2.8e-53) (/ (- z) (/ y (+ x y))) (+ x y))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.22e+23) {
tmp = (x + y) * (1.0 + (y / z));
} else if (z <= 2.8e-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 <= (-1.22d+23)) then
tmp = (x + y) * (1.0d0 + (y / z))
else if (z <= 2.8d-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 <= -1.22e+23) {
tmp = (x + y) * (1.0 + (y / z));
} else if (z <= 2.8e-53) {
tmp = -z / (y / (x + y));
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.22e+23: tmp = (x + y) * (1.0 + (y / z)) elif z <= 2.8e-53: tmp = -z / (y / (x + y)) else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.22e+23) tmp = Float64(Float64(x + y) * Float64(1.0 + Float64(y / z))); elseif (z <= 2.8e-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 <= -1.22e+23) tmp = (x + y) * (1.0 + (y / z)); elseif (z <= 2.8e-53) tmp = -z / (y / (x + y)); else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.22e+23], N[(N[(x + y), $MachinePrecision] * N[(1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.8e-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 -1.22 \cdot 10^{+23}:\\
\;\;\;\;\left(x + y\right) \cdot \left(1 + \frac{y}{z}\right)\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{-53}:\\
\;\;\;\;\frac{-z}{\frac{y}{x + y}}\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if z < -1.22e23Initial program 99.9%
Taylor expanded in z around inf 71.4%
associate-+r+71.4%
*-lft-identity71.4%
associate-/l*84.8%
associate-/r/84.8%
distribute-rgt-in84.8%
+-commutative84.8%
Simplified84.8%
if -1.22e23 < z < 2.79999999999999985e-53Initial program 76.1%
Taylor expanded in z around 0 74.6%
mul-1-neg74.6%
associate-/l*76.6%
distribute-neg-frac76.6%
+-commutative76.6%
Simplified76.6%
if 2.79999999999999985e-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 -1.3e-51) (not (<= y 5.1e-26))) (- z) x))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.3e-51) || !(y <= 5.1e-26)) {
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.3d-51)) .or. (.not. (y <= 5.1d-26))) 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.3e-51) || !(y <= 5.1e-26)) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.3e-51) or not (y <= 5.1e-26): tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.3e-51) || !(y <= 5.1e-26)) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.3e-51) || ~((y <= 5.1e-26))) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.3e-51], N[Not[LessEqual[y, 5.1e-26]], $MachinePrecision]], (-z), x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.3 \cdot 10^{-51} \lor \neg \left(y \leq 5.1 \cdot 10^{-26}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1.3e-51 or 5.09999999999999991e-26 < y Initial program 80.0%
Taylor expanded in y around inf 56.2%
mul-1-neg56.2%
Simplified56.2%
if -1.3e-51 < y < 5.09999999999999991e-26Initial program 99.9%
Taylor expanded in y around 0 60.2%
Final simplification58.0%
(FPCore (x y z) :precision binary64 (if (<= y -5.3e-61) y (if (<= y 7.5e-71) x y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.3e-61) {
tmp = y;
} else if (y <= 7.5e-71) {
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.3d-61)) then
tmp = y
else if (y <= 7.5d-71) 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.3e-61) {
tmp = y;
} else if (y <= 7.5e-71) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.3e-61: tmp = y elif y <= 7.5e-71: tmp = x else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.3e-61) tmp = y; elseif (y <= 7.5e-71) tmp = x; else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5.3e-61) tmp = y; elseif (y <= 7.5e-71) tmp = x; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.3e-61], y, If[LessEqual[y, 7.5e-71], x, y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.3 \cdot 10^{-61}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{-71}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -5.3e-61 or 7.5000000000000004e-71 < y Initial program 81.5%
Taylor expanded in x around 0 65.2%
Taylor expanded in y around 0 29.3%
if -5.3e-61 < y < 7.5000000000000004e-71Initial program 99.9%
Taylor expanded in y around 0 62.9%
Final simplification42.8%
(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 31.1%
Final simplification31.1%
(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))))