
(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 -2e-304) (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 <= -2e-304) || !(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 <= (-2d-304)) .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 <= -2e-304) || !(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 <= -2e-304) 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 <= -2e-304) || !(t_0 <= 0.0)) tmp = t_0; else tmp = Float64(z * Float64(Float64(Float64(-y) - 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-304) || ~((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, -2e-304], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], t$95$0, N[(z * N[(N[((-y) - x), $MachinePrecision] / y), $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^{-304} \lor \neg \left(t\_0 \leq 0\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{\left(-y\right) - x}{y}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -1.99999999999999994e-304 or 0.0 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) Initial program 99.8%
if -1.99999999999999994e-304 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < 0.0Initial program 6.0%
Taylor expanded in z around 0 99.9%
mul-1-neg99.9%
associate-/l*99.9%
distribute-rgt-neg-in99.9%
distribute-neg-frac299.9%
+-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ y z))))
(if (<= y -2.15e+129)
(- z)
(if (<= y -6.5e-41)
(/ y t_0)
(if (<= y 3.4e-27) (/ x t_0) (if (<= y 2.8e+95) (+ x y) (- z)))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double tmp;
if (y <= -2.15e+129) {
tmp = -z;
} else if (y <= -6.5e-41) {
tmp = y / t_0;
} else if (y <= 3.4e-27) {
tmp = x / t_0;
} else if (y <= 2.8e+95) {
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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (y / z)
if (y <= (-2.15d+129)) then
tmp = -z
else if (y <= (-6.5d-41)) then
tmp = y / t_0
else if (y <= 3.4d-27) then
tmp = x / t_0
else if (y <= 2.8d+95) then
tmp = x + y
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double tmp;
if (y <= -2.15e+129) {
tmp = -z;
} else if (y <= -6.5e-41) {
tmp = y / t_0;
} else if (y <= 3.4e-27) {
tmp = x / t_0;
} else if (y <= 2.8e+95) {
tmp = x + y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) tmp = 0 if y <= -2.15e+129: tmp = -z elif y <= -6.5e-41: tmp = y / t_0 elif y <= 3.4e-27: tmp = x / t_0 elif y <= 2.8e+95: tmp = x + y else: tmp = -z return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y / z)) tmp = 0.0 if (y <= -2.15e+129) tmp = Float64(-z); elseif (y <= -6.5e-41) tmp = Float64(y / t_0); elseif (y <= 3.4e-27) tmp = Float64(x / t_0); elseif (y <= 2.8e+95) tmp = Float64(x + y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y / z); tmp = 0.0; if (y <= -2.15e+129) tmp = -z; elseif (y <= -6.5e-41) tmp = y / t_0; elseif (y <= 3.4e-27) tmp = x / t_0; elseif (y <= 2.8e+95) tmp = x + y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.15e+129], (-z), If[LessEqual[y, -6.5e-41], N[(y / t$95$0), $MachinePrecision], If[LessEqual[y, 3.4e-27], N[(x / t$95$0), $MachinePrecision], If[LessEqual[y, 2.8e+95], N[(x + y), $MachinePrecision], (-z)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
\mathbf{if}\;y \leq -2.15 \cdot 10^{+129}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -6.5 \cdot 10^{-41}:\\
\;\;\;\;\frac{y}{t\_0}\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{-27}:\\
\;\;\;\;\frac{x}{t\_0}\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{+95}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -2.1500000000000001e129 or 2.7999999999999998e95 < y Initial program 71.0%
Taylor expanded in y around inf 68.7%
mul-1-neg68.7%
Simplified68.7%
if -2.1500000000000001e129 < y < -6.5000000000000004e-41Initial program 94.7%
Taylor expanded in x around 0 62.1%
if -6.5000000000000004e-41 < y < 3.3999999999999997e-27Initial program 99.9%
Taylor expanded in x around inf 80.9%
if 3.3999999999999997e-27 < y < 2.7999999999999998e95Initial program 96.4%
Taylor expanded in z around inf 64.8%
+-commutative64.8%
Simplified64.8%
Final simplification72.9%
(FPCore (x y z) :precision binary64 (if (<= z -5.4e+39) (+ x y) (if (<= z 9.2e+33) (* z (/ (- (- y) x) y)) (* (+ x y) (+ 1.0 (/ y z))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -5.4e+39) {
tmp = x + y;
} else if (z <= 9.2e+33) {
tmp = z * ((-y - x) / y);
} else {
tmp = (x + y) * (1.0 + (y / z));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-5.4d+39)) then
tmp = x + y
else if (z <= 9.2d+33) then
tmp = z * ((-y - x) / y)
else
tmp = (x + y) * (1.0d0 + (y / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -5.4e+39) {
tmp = x + y;
} else if (z <= 9.2e+33) {
tmp = z * ((-y - x) / y);
} else {
tmp = (x + y) * (1.0 + (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -5.4e+39: tmp = x + y elif z <= 9.2e+33: tmp = z * ((-y - x) / y) else: tmp = (x + y) * (1.0 + (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -5.4e+39) tmp = Float64(x + y); elseif (z <= 9.2e+33) tmp = Float64(z * Float64(Float64(Float64(-y) - x) / y)); else tmp = Float64(Float64(x + y) * Float64(1.0 + Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -5.4e+39) tmp = x + y; elseif (z <= 9.2e+33) tmp = z * ((-y - x) / y); else tmp = (x + y) * (1.0 + (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -5.4e+39], N[(x + y), $MachinePrecision], If[LessEqual[z, 9.2e+33], N[(z * N[(N[((-y) - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(N[(x + y), $MachinePrecision] * N[(1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.4 \cdot 10^{+39}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 9.2 \cdot 10^{+33}:\\
\;\;\;\;z \cdot \frac{\left(-y\right) - x}{y}\\
\mathbf{else}:\\
\;\;\;\;\left(x + y\right) \cdot \left(1 + \frac{y}{z}\right)\\
\end{array}
\end{array}
if z < -5.40000000000000007e39Initial program 100.0%
Taylor expanded in z around inf 84.9%
+-commutative84.9%
Simplified84.9%
if -5.40000000000000007e39 < z < 9.20000000000000042e33Initial program 82.7%
Taylor expanded in z around 0 72.6%
mul-1-neg72.6%
associate-/l*74.5%
distribute-rgt-neg-in74.5%
distribute-neg-frac274.5%
+-commutative74.5%
Simplified74.5%
if 9.20000000000000042e33 < z Initial program 99.9%
Taylor expanded in z around inf 73.1%
associate-+r+73.1%
*-rgt-identity73.1%
*-commutative73.1%
associate-/l*79.5%
distribute-lft-in79.5%
+-commutative79.5%
Simplified79.5%
Final simplification77.9%
(FPCore (x y z) :precision binary64 (if (<= y -2.9e+65) (- z) (if (<= y 1e-26) (/ x (- 1.0 (/ y z))) (if (<= y 2.5e+95) (+ x y) (- z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.9e+65) {
tmp = -z;
} else if (y <= 1e-26) {
tmp = x / (1.0 - (y / z));
} else if (y <= 2.5e+95) {
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 <= (-2.9d+65)) then
tmp = -z
else if (y <= 1d-26) then
tmp = x / (1.0d0 - (y / z))
else if (y <= 2.5d+95) 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 <= -2.9e+65) {
tmp = -z;
} else if (y <= 1e-26) {
tmp = x / (1.0 - (y / z));
} else if (y <= 2.5e+95) {
tmp = x + y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.9e+65: tmp = -z elif y <= 1e-26: tmp = x / (1.0 - (y / z)) elif y <= 2.5e+95: tmp = x + y else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.9e+65) tmp = Float64(-z); elseif (y <= 1e-26) tmp = Float64(x / Float64(1.0 - Float64(y / z))); elseif (y <= 2.5e+95) tmp = Float64(x + y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.9e+65) tmp = -z; elseif (y <= 1e-26) tmp = x / (1.0 - (y / z)); elseif (y <= 2.5e+95) tmp = x + y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.9e+65], (-z), If[LessEqual[y, 1e-26], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.5e+95], N[(x + y), $MachinePrecision], (-z)]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.9 \cdot 10^{+65}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 10^{-26}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{+95}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -2.9e65 or 2.50000000000000012e95 < y Initial program 73.1%
Taylor expanded in y around inf 65.3%
mul-1-neg65.3%
Simplified65.3%
if -2.9e65 < y < 1e-26Initial program 99.9%
Taylor expanded in x around inf 74.1%
if 1e-26 < y < 2.50000000000000012e95Initial program 96.4%
Taylor expanded in z around inf 64.8%
+-commutative64.8%
Simplified64.8%
Final simplification70.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.15e+40) (not (<= z 4.2e+33))) (+ x y) (* z (/ (- (- y) x) y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.15e+40) || !(z <= 4.2e+33)) {
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.15d+40)) .or. (.not. (z <= 4.2d+33))) 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.15e+40) || !(z <= 4.2e+33)) {
tmp = x + y;
} else {
tmp = z * ((-y - x) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.15e+40) or not (z <= 4.2e+33): tmp = x + y else: tmp = z * ((-y - x) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.15e+40) || !(z <= 4.2e+33)) tmp = Float64(x + y); else tmp = Float64(z * Float64(Float64(Float64(-y) - x) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.15e+40) || ~((z <= 4.2e+33))) tmp = x + y; else tmp = z * ((-y - x) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.15e+40], N[Not[LessEqual[z, 4.2e+33]], $MachinePrecision]], N[(x + y), $MachinePrecision], N[(z * N[(N[((-y) - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.15 \cdot 10^{+40} \lor \neg \left(z \leq 4.2 \cdot 10^{+33}\right):\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{\left(-y\right) - x}{y}\\
\end{array}
\end{array}
if z < -2.1500000000000001e40 or 4.2000000000000001e33 < z Initial program 99.9%
Taylor expanded in z around inf 82.2%
+-commutative82.2%
Simplified82.2%
if -2.1500000000000001e40 < z < 4.2000000000000001e33Initial program 82.7%
Taylor expanded in z around 0 72.6%
mul-1-neg72.6%
associate-/l*74.5%
distribute-rgt-neg-in74.5%
distribute-neg-frac274.5%
+-commutative74.5%
Simplified74.5%
Final simplification77.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.5e+18) (not (<= y 2.8e+95))) (- z) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.5e+18) || !(y <= 2.8e+95)) {
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+18)) .or. (.not. (y <= 2.8d+95))) 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+18) || !(y <= 2.8e+95)) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.5e+18) or not (y <= 2.8e+95): tmp = -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.5e+18) || !(y <= 2.8e+95)) 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+18) || ~((y <= 2.8e+95))) tmp = -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.5e+18], N[Not[LessEqual[y, 2.8e+95]], $MachinePrecision]], (-z), N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{+18} \lor \neg \left(y \leq 2.8 \cdot 10^{+95}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -6.5e18 or 2.7999999999999998e95 < y Initial program 76.8%
Taylor expanded in y around inf 61.6%
mul-1-neg61.6%
Simplified61.6%
if -6.5e18 < y < 2.7999999999999998e95Initial program 99.3%
Taylor expanded in z around inf 70.1%
+-commutative70.1%
Simplified70.1%
Final simplification66.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -8e-44) (not (<= y 5.3e+85))) (- z) x))
double code(double x, double y, double z) {
double tmp;
if ((y <= -8e-44) || !(y <= 5.3e+85)) {
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 <= (-8d-44)) .or. (.not. (y <= 5.3d+85))) 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 <= -8e-44) || !(y <= 5.3e+85)) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -8e-44) or not (y <= 5.3e+85): tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -8e-44) || !(y <= 5.3e+85)) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -8e-44) || ~((y <= 5.3e+85))) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -8e-44], N[Not[LessEqual[y, 5.3e+85]], $MachinePrecision]], (-z), x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8 \cdot 10^{-44} \lor \neg \left(y \leq 5.3 \cdot 10^{+85}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -7.99999999999999962e-44 or 5.2999999999999999e85 < y Initial program 78.7%
Taylor expanded in y around inf 57.3%
mul-1-neg57.3%
Simplified57.3%
if -7.99999999999999962e-44 < y < 5.2999999999999999e85Initial program 99.9%
Taylor expanded in y around 0 59.9%
Final simplification58.7%
(FPCore (x y z) :precision binary64 (if (<= y -2.3e-34) y x))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.3e-34) {
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 (y <= (-2.3d-34)) 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 (y <= -2.3e-34) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.3e-34: tmp = y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.3e-34) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.3e-34) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.3e-34], y, x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.3 \cdot 10^{-34}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -2.30000000000000011e-34Initial program 81.8%
Taylor expanded in x around 0 61.2%
Taylor expanded in y around 0 18.5%
if -2.30000000000000011e-34 < y Initial program 93.4%
Taylor expanded in y around 0 46.6%
Final simplification39.2%
(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.3%
Taylor expanded in y around 0 36.2%
Final simplification36.2%
(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 2024055
(FPCore (x y z)
:name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A"
:precision binary64
:alt
(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))))