
(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 13 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 (if (or (<= y -0.0025) (not (<= y 120000000.0))) (/ z (/ (- z y) (+ y x))) (/ (+ y x) (- 1.0 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -0.0025) || !(y <= 120000000.0)) {
tmp = z / ((z - y) / (y + x));
} else {
tmp = (y + x) / (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 ((y <= (-0.0025d0)) .or. (.not. (y <= 120000000.0d0))) then
tmp = z / ((z - y) / (y + x))
else
tmp = (y + x) / (1.0d0 - (y / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -0.0025) || !(y <= 120000000.0)) {
tmp = z / ((z - y) / (y + x));
} else {
tmp = (y + x) / (1.0 - (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -0.0025) or not (y <= 120000000.0): tmp = z / ((z - y) / (y + x)) else: tmp = (y + x) / (1.0 - (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -0.0025) || !(y <= 120000000.0)) tmp = Float64(z / Float64(Float64(z - y) / Float64(y + x))); else tmp = Float64(Float64(y + x) / Float64(1.0 - Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -0.0025) || ~((y <= 120000000.0))) tmp = z / ((z - y) / (y + x)); else tmp = (y + x) / (1.0 - (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -0.0025], N[Not[LessEqual[y, 120000000.0]], $MachinePrecision]], N[(z / N[(N[(z - y), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y + x), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.0025 \lor \neg \left(y \leq 120000000\right):\\
\;\;\;\;\frac{z}{\frac{z - y}{y + x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{y + x}{1 - \frac{y}{z}}\\
\end{array}
\end{array}
if y < -0.00250000000000000005 or 1.2e8 < y Initial program 78.5%
Taylor expanded in z around 0 78.5%
associate-/r/99.9%
add-cube-cbrt97.7%
associate-*r*97.6%
pow297.6%
Applied egg-rr97.6%
associate-*l*97.7%
clear-num97.7%
unpow297.7%
add-cube-cbrt99.8%
associate-*l/99.9%
*-un-lft-identity99.9%
Applied egg-rr99.9%
if -0.00250000000000000005 < y < 1.2e8Initial program 99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ y z))))
(if (<= y -3.2e+150)
(- z)
(if (<= y -0.00016)
(/ z (/ (- z y) x))
(if (<= y 2.7e-41)
(+ y x)
(if (<= y 9e+34) (/ x t_0) (if (<= y 6e+138) (/ y t_0) (- z))))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double tmp;
if (y <= -3.2e+150) {
tmp = -z;
} else if (y <= -0.00016) {
tmp = z / ((z - y) / x);
} else if (y <= 2.7e-41) {
tmp = y + x;
} else if (y <= 9e+34) {
tmp = x / t_0;
} else if (y <= 6e+138) {
tmp = y / 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 = 1.0d0 - (y / z)
if (y <= (-3.2d+150)) then
tmp = -z
else if (y <= (-0.00016d0)) then
tmp = z / ((z - y) / x)
else if (y <= 2.7d-41) then
tmp = y + x
else if (y <= 9d+34) then
tmp = x / t_0
else if (y <= 6d+138) then
tmp = y / t_0
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 <= -3.2e+150) {
tmp = -z;
} else if (y <= -0.00016) {
tmp = z / ((z - y) / x);
} else if (y <= 2.7e-41) {
tmp = y + x;
} else if (y <= 9e+34) {
tmp = x / t_0;
} else if (y <= 6e+138) {
tmp = y / t_0;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) tmp = 0 if y <= -3.2e+150: tmp = -z elif y <= -0.00016: tmp = z / ((z - y) / x) elif y <= 2.7e-41: tmp = y + x elif y <= 9e+34: tmp = x / t_0 elif y <= 6e+138: tmp = y / t_0 else: tmp = -z return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y / z)) tmp = 0.0 if (y <= -3.2e+150) tmp = Float64(-z); elseif (y <= -0.00016) tmp = Float64(z / Float64(Float64(z - y) / x)); elseif (y <= 2.7e-41) tmp = Float64(y + x); elseif (y <= 9e+34) tmp = Float64(x / t_0); elseif (y <= 6e+138) tmp = Float64(y / t_0); 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 <= -3.2e+150) tmp = -z; elseif (y <= -0.00016) tmp = z / ((z - y) / x); elseif (y <= 2.7e-41) tmp = y + x; elseif (y <= 9e+34) tmp = x / t_0; elseif (y <= 6e+138) tmp = y / t_0; 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, -3.2e+150], (-z), If[LessEqual[y, -0.00016], N[(z / N[(N[(z - y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.7e-41], N[(y + x), $MachinePrecision], If[LessEqual[y, 9e+34], N[(x / t$95$0), $MachinePrecision], If[LessEqual[y, 6e+138], N[(y / t$95$0), $MachinePrecision], (-z)]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
\mathbf{if}\;y \leq -3.2 \cdot 10^{+150}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -0.00016:\\
\;\;\;\;\frac{z}{\frac{z - y}{x}}\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{-41}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;y \leq 9 \cdot 10^{+34}:\\
\;\;\;\;\frac{x}{t\_0}\\
\mathbf{elif}\;y \leq 6 \cdot 10^{+138}:\\
\;\;\;\;\frac{y}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -3.20000000000000016e150 or 6.0000000000000002e138 < y Initial program 64.6%
Taylor expanded in y around inf 76.6%
neg-mul-176.6%
Simplified76.6%
if -3.20000000000000016e150 < y < -1.60000000000000013e-4Initial program 86.8%
Taylor expanded in z around 0 87.1%
associate-/r/99.7%
add-cube-cbrt97.7%
associate-*r*97.7%
pow297.7%
Applied egg-rr97.7%
associate-*l*97.7%
clear-num97.7%
unpow297.7%
add-cube-cbrt99.7%
associate-*l/99.9%
*-un-lft-identity99.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 58.6%
if -1.60000000000000013e-4 < y < 2.7e-41Initial program 99.9%
Taylor expanded in z around inf 83.2%
+-commutative83.2%
Simplified83.2%
if 2.7e-41 < y < 9.0000000000000001e34Initial program 99.8%
Taylor expanded in x around inf 87.1%
if 9.0000000000000001e34 < y < 6.0000000000000002e138Initial program 95.9%
Taylor expanded in x around 0 61.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ z (/ (- z y) y))))
(if (<= y -1e+146)
t_0
(if (<= y -0.001)
(/ z (/ (- z y) x))
(if (<= y 2.7e-41)
(+ y x)
(if (<= y 7.6e+31) (/ x (- 1.0 (/ y z))) t_0))))))
double code(double x, double y, double z) {
double t_0 = z / ((z - y) / y);
double tmp;
if (y <= -1e+146) {
tmp = t_0;
} else if (y <= -0.001) {
tmp = z / ((z - y) / x);
} else if (y <= 2.7e-41) {
tmp = y + x;
} else if (y <= 7.6e+31) {
tmp = x / (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 = z / ((z - y) / y)
if (y <= (-1d+146)) then
tmp = t_0
else if (y <= (-0.001d0)) then
tmp = z / ((z - y) / x)
else if (y <= 2.7d-41) then
tmp = y + x
else if (y <= 7.6d+31) then
tmp = x / (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 = z / ((z - y) / y);
double tmp;
if (y <= -1e+146) {
tmp = t_0;
} else if (y <= -0.001) {
tmp = z / ((z - y) / x);
} else if (y <= 2.7e-41) {
tmp = y + x;
} else if (y <= 7.6e+31) {
tmp = x / (1.0 - (y / z));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z / ((z - y) / y) tmp = 0 if y <= -1e+146: tmp = t_0 elif y <= -0.001: tmp = z / ((z - y) / x) elif y <= 2.7e-41: tmp = y + x elif y <= 7.6e+31: tmp = x / (1.0 - (y / z)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z / Float64(Float64(z - y) / y)) tmp = 0.0 if (y <= -1e+146) tmp = t_0; elseif (y <= -0.001) tmp = Float64(z / Float64(Float64(z - y) / x)); elseif (y <= 2.7e-41) tmp = Float64(y + x); elseif (y <= 7.6e+31) tmp = Float64(x / Float64(1.0 - Float64(y / z))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z / ((z - y) / y); tmp = 0.0; if (y <= -1e+146) tmp = t_0; elseif (y <= -0.001) tmp = z / ((z - y) / x); elseif (y <= 2.7e-41) tmp = y + x; elseif (y <= 7.6e+31) tmp = x / (1.0 - (y / z)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z / N[(N[(z - y), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1e+146], t$95$0, If[LessEqual[y, -0.001], N[(z / N[(N[(z - y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.7e-41], N[(y + x), $MachinePrecision], If[LessEqual[y, 7.6e+31], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{z}{\frac{z - y}{y}}\\
\mathbf{if}\;y \leq -1 \cdot 10^{+146}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -0.001:\\
\;\;\;\;\frac{z}{\frac{z - y}{x}}\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{-41}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;y \leq 7.6 \cdot 10^{+31}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -9.99999999999999934e145 or 7.6000000000000003e31 < y Initial program 73.2%
Taylor expanded in z around 0 73.2%
associate-/r/99.9%
add-cube-cbrt97.7%
associate-*r*97.6%
pow297.6%
Applied egg-rr97.6%
associate-*l*97.7%
clear-num97.7%
unpow297.7%
add-cube-cbrt99.8%
associate-*l/99.9%
*-un-lft-identity99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 80.7%
if -9.99999999999999934e145 < y < -1e-3Initial program 86.8%
Taylor expanded in z around 0 87.1%
associate-/r/99.7%
add-cube-cbrt97.7%
associate-*r*97.7%
pow297.7%
Applied egg-rr97.7%
associate-*l*97.7%
clear-num97.7%
unpow297.7%
add-cube-cbrt99.7%
associate-*l/99.9%
*-un-lft-identity99.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 58.6%
if -1e-3 < y < 2.7e-41Initial program 99.9%
Taylor expanded in z around inf 83.2%
+-commutative83.2%
Simplified83.2%
if 2.7e-41 < y < 7.6000000000000003e31Initial program 99.8%
Taylor expanded in x around inf 87.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.5e-119) (not (<= y 2.5e-185))) (/ z (/ (- z y) (+ y x))) (/ x (- 1.0 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.5e-119) || !(y <= 2.5e-185)) {
tmp = z / ((z - y) / (y + x));
} else {
tmp = x / (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 ((y <= (-4.5d-119)) .or. (.not. (y <= 2.5d-185))) then
tmp = z / ((z - y) / (y + x))
else
tmp = x / (1.0d0 - (y / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -4.5e-119) || !(y <= 2.5e-185)) {
tmp = z / ((z - y) / (y + x));
} else {
tmp = x / (1.0 - (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4.5e-119) or not (y <= 2.5e-185): tmp = z / ((z - y) / (y + x)) else: tmp = x / (1.0 - (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4.5e-119) || !(y <= 2.5e-185)) tmp = Float64(z / Float64(Float64(z - y) / Float64(y + x))); else tmp = Float64(x / Float64(1.0 - Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -4.5e-119) || ~((y <= 2.5e-185))) tmp = z / ((z - y) / (y + x)); else tmp = x / (1.0 - (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4.5e-119], N[Not[LessEqual[y, 2.5e-185]], $MachinePrecision]], N[(z / N[(N[(z - y), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.5 \cdot 10^{-119} \lor \neg \left(y \leq 2.5 \cdot 10^{-185}\right):\\
\;\;\;\;\frac{z}{\frac{z - y}{y + x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\end{array}
\end{array}
if y < -4.5000000000000003e-119 or 2.5000000000000001e-185 < y Initial program 84.6%
Taylor expanded in z around 0 84.7%
associate-/r/98.4%
add-cube-cbrt96.2%
associate-*r*96.2%
pow296.2%
Applied egg-rr96.2%
associate-*l*96.2%
clear-num96.2%
unpow296.2%
add-cube-cbrt98.2%
associate-*l/98.4%
*-un-lft-identity98.4%
Applied egg-rr98.4%
if -4.5000000000000003e-119 < y < 2.5000000000000001e-185Initial program 100.0%
Taylor expanded in x around inf 92.5%
Final simplification96.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -0.02) (not (<= y 9.2e+35))) (* z (/ (+ y x) (- y))) (+ y x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -0.02) || !(y <= 9.2e+35)) {
tmp = z * ((y + x) / -y);
} else {
tmp = y + 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 <= (-0.02d0)) .or. (.not. (y <= 9.2d+35))) then
tmp = z * ((y + x) / -y)
else
tmp = y + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -0.02) || !(y <= 9.2e+35)) {
tmp = z * ((y + x) / -y);
} else {
tmp = y + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -0.02) or not (y <= 9.2e+35): tmp = z * ((y + x) / -y) else: tmp = y + x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -0.02) || !(y <= 9.2e+35)) tmp = Float64(z * Float64(Float64(y + x) / Float64(-y))); else tmp = Float64(y + x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -0.02) || ~((y <= 9.2e+35))) tmp = z * ((y + x) / -y); else tmp = y + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -0.02], N[Not[LessEqual[y, 9.2e+35]], $MachinePrecision]], N[(z * N[(N[(y + x), $MachinePrecision] / (-y)), $MachinePrecision]), $MachinePrecision], N[(y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.02 \lor \neg \left(y \leq 9.2 \cdot 10^{+35}\right):\\
\;\;\;\;z \cdot \frac{y + x}{-y}\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if y < -0.0200000000000000004 or 9.1999999999999993e35 < y Initial program 77.0%
Taylor expanded in z around 0 64.5%
mul-1-neg64.5%
associate-/l*78.9%
distribute-rgt-neg-in78.9%
distribute-neg-frac278.9%
+-commutative78.9%
Simplified78.9%
if -0.0200000000000000004 < y < 9.1999999999999993e35Initial program 99.9%
Taylor expanded in z around inf 80.0%
+-commutative80.0%
Simplified80.0%
Final simplification79.4%
(FPCore (x y z) :precision binary64 (if (<= y -0.7) (/ (- z) (/ y (+ y x))) (if (<= y 1.9e+35) (+ y x) (* z (/ (+ y x) (- y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -0.7) {
tmp = -z / (y / (y + x));
} else if (y <= 1.9e+35) {
tmp = y + x;
} 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 (y <= (-0.7d0)) then
tmp = -z / (y / (y + x))
else if (y <= 1.9d+35) then
tmp = y + x
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 (y <= -0.7) {
tmp = -z / (y / (y + x));
} else if (y <= 1.9e+35) {
tmp = y + x;
} else {
tmp = z * ((y + x) / -y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -0.7: tmp = -z / (y / (y + x)) elif y <= 1.9e+35: tmp = y + x else: tmp = z * ((y + x) / -y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -0.7) tmp = Float64(Float64(-z) / Float64(y / Float64(y + x))); elseif (y <= 1.9e+35) tmp = Float64(y + x); else tmp = Float64(z * Float64(Float64(y + x) / Float64(-y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -0.7) tmp = -z / (y / (y + x)); elseif (y <= 1.9e+35) tmp = y + x; else tmp = z * ((y + x) / -y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -0.7], N[((-z) / N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.9e+35], N[(y + x), $MachinePrecision], N[(z * N[(N[(y + x), $MachinePrecision] / (-y)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.7:\\
\;\;\;\;\frac{-z}{\frac{y}{y + x}}\\
\mathbf{elif}\;y \leq 1.9 \cdot 10^{+35}:\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y + x}{-y}\\
\end{array}
\end{array}
if y < -0.69999999999999996Initial program 78.1%
Taylor expanded in z around 0 78.2%
associate-/r/99.8%
add-cube-cbrt97.6%
associate-*r*97.6%
pow297.6%
Applied egg-rr97.6%
associate-*l*97.6%
clear-num97.6%
unpow297.6%
add-cube-cbrt99.8%
associate-*l/99.9%
*-un-lft-identity99.9%
Applied egg-rr99.9%
Taylor expanded in z around 0 81.7%
neg-mul-181.7%
Simplified81.7%
if -0.69999999999999996 < y < 1.9e35Initial program 99.9%
Taylor expanded in z around inf 80.0%
+-commutative80.0%
Simplified80.0%
if 1.9e35 < y Initial program 75.6%
Taylor expanded in z around 0 65.3%
mul-1-neg65.3%
associate-/l*75.5%
distribute-rgt-neg-in75.5%
distribute-neg-frac275.5%
+-commutative75.5%
Simplified75.5%
Final simplification79.4%
(FPCore (x y z) :precision binary64 (if (or (<= x -9.5e+42) (not (<= x 380000000000.0))) (/ x (- 1.0 (/ y z))) (/ y (/ (- z y) z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -9.5e+42) || !(x <= 380000000000.0)) {
tmp = x / (1.0 - (y / z));
} else {
tmp = y / ((z - 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 ((x <= (-9.5d+42)) .or. (.not. (x <= 380000000000.0d0))) then
tmp = x / (1.0d0 - (y / z))
else
tmp = y / ((z - y) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -9.5e+42) || !(x <= 380000000000.0)) {
tmp = x / (1.0 - (y / z));
} else {
tmp = y / ((z - y) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -9.5e+42) or not (x <= 380000000000.0): tmp = x / (1.0 - (y / z)) else: tmp = y / ((z - y) / z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -9.5e+42) || !(x <= 380000000000.0)) tmp = Float64(x / Float64(1.0 - Float64(y / z))); else tmp = Float64(y / Float64(Float64(z - y) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -9.5e+42) || ~((x <= 380000000000.0))) tmp = x / (1.0 - (y / z)); else tmp = y / ((z - y) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -9.5e+42], N[Not[LessEqual[x, 380000000000.0]], $MachinePrecision]], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y / N[(N[(z - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.5 \cdot 10^{+42} \lor \neg \left(x \leq 380000000000\right):\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z - y}{z}}\\
\end{array}
\end{array}
if x < -9.50000000000000019e42 or 3.8e11 < x Initial program 89.1%
Taylor expanded in x around inf 75.6%
if -9.50000000000000019e42 < x < 3.8e11Initial program 87.8%
Taylor expanded in z around 0 87.9%
Taylor expanded in x around 0 64.0%
Final simplification70.3%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- 1.0 (/ y z)))) (if (or (<= x -1.8e+40) (not (<= x 520000000000.0))) (/ x t_0) (/ y t_0))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double tmp;
if ((x <= -1.8e+40) || !(x <= 520000000000.0)) {
tmp = x / t_0;
} else {
tmp = y / 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 = 1.0d0 - (y / z)
if ((x <= (-1.8d+40)) .or. (.not. (x <= 520000000000.0d0))) then
tmp = x / t_0
else
tmp = y / t_0
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 ((x <= -1.8e+40) || !(x <= 520000000000.0)) {
tmp = x / t_0;
} else {
tmp = y / t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) tmp = 0 if (x <= -1.8e+40) or not (x <= 520000000000.0): tmp = x / t_0 else: tmp = y / t_0 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y / z)) tmp = 0.0 if ((x <= -1.8e+40) || !(x <= 520000000000.0)) tmp = Float64(x / t_0); else tmp = Float64(y / t_0); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y / z); tmp = 0.0; if ((x <= -1.8e+40) || ~((x <= 520000000000.0))) tmp = x / t_0; else tmp = y / t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[x, -1.8e+40], N[Not[LessEqual[x, 520000000000.0]], $MachinePrecision]], N[(x / t$95$0), $MachinePrecision], N[(y / t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
\mathbf{if}\;x \leq -1.8 \cdot 10^{+40} \lor \neg \left(x \leq 520000000000\right):\\
\;\;\;\;\frac{x}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{t\_0}\\
\end{array}
\end{array}
if x < -1.79999999999999998e40 or 5.2e11 < x Initial program 89.1%
Taylor expanded in x around inf 75.6%
if -1.79999999999999998e40 < x < 5.2e11Initial program 87.8%
Taylor expanded in x around 0 64.0%
Final simplification70.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -5.9e+84) (not (<= y 9e+36))) (- z) (/ x (- 1.0 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5.9e+84) || !(y <= 9e+36)) {
tmp = -z;
} else {
tmp = x / (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 ((y <= (-5.9d+84)) .or. (.not. (y <= 9d+36))) then
tmp = -z
else
tmp = x / (1.0d0 - (y / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -5.9e+84) || !(y <= 9e+36)) {
tmp = -z;
} else {
tmp = x / (1.0 - (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5.9e+84) or not (y <= 9e+36): tmp = -z else: tmp = x / (1.0 - (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5.9e+84) || !(y <= 9e+36)) tmp = Float64(-z); else tmp = Float64(x / Float64(1.0 - Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -5.9e+84) || ~((y <= 9e+36))) tmp = -z; else tmp = x / (1.0 - (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5.9e+84], N[Not[LessEqual[y, 9e+36]], $MachinePrecision]], (-z), N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.9 \cdot 10^{+84} \lor \neg \left(y \leq 9 \cdot 10^{+36}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\end{array}
\end{array}
if y < -5.89999999999999984e84 or 8.99999999999999994e36 < y Initial program 72.4%
Taylor expanded in y around inf 64.2%
neg-mul-164.2%
Simplified64.2%
if -5.89999999999999984e84 < y < 8.99999999999999994e36Initial program 99.2%
Taylor expanded in x around inf 73.5%
Final simplification69.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -5.8e+51) (not (<= y 9.6e+36))) (- z) (+ y x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5.8e+51) || !(y <= 9.6e+36)) {
tmp = -z;
} else {
tmp = y + 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 <= (-5.8d+51)) .or. (.not. (y <= 9.6d+36))) then
tmp = -z
else
tmp = y + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -5.8e+51) || !(y <= 9.6e+36)) {
tmp = -z;
} else {
tmp = y + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5.8e+51) or not (y <= 9.6e+36): tmp = -z else: tmp = y + x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5.8e+51) || !(y <= 9.6e+36)) tmp = Float64(-z); else tmp = Float64(y + x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -5.8e+51) || ~((y <= 9.6e+36))) tmp = -z; else tmp = y + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5.8e+51], N[Not[LessEqual[y, 9.6e+36]], $MachinePrecision]], (-z), N[(y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.8 \cdot 10^{+51} \lor \neg \left(y \leq 9.6 \cdot 10^{+36}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if y < -5.7999999999999997e51 or 9.5999999999999997e36 < y Initial program 75.2%
Taylor expanded in y around inf 61.3%
neg-mul-161.3%
Simplified61.3%
if -5.7999999999999997e51 < y < 9.5999999999999997e36Initial program 99.2%
Taylor expanded in z around inf 76.3%
+-commutative76.3%
Simplified76.3%
Final simplification69.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.65e+47) (not (<= y 3.1e+35))) (- z) x))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.65e+47) || !(y <= 3.1e+35)) {
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.65d+47)) .or. (.not. (y <= 3.1d+35))) 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.65e+47) || !(y <= 3.1e+35)) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.65e+47) or not (y <= 3.1e+35): tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.65e+47) || !(y <= 3.1e+35)) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.65e+47) || ~((y <= 3.1e+35))) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.65e+47], N[Not[LessEqual[y, 3.1e+35]], $MachinePrecision]], (-z), x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.65 \cdot 10^{+47} \lor \neg \left(y \leq 3.1 \cdot 10^{+35}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1.65e47 or 3.09999999999999987e35 < y Initial program 75.2%
Taylor expanded in y around inf 61.3%
neg-mul-161.3%
Simplified61.3%
if -1.65e47 < y < 3.09999999999999987e35Initial program 99.2%
Taylor expanded in y around 0 61.2%
Final simplification61.2%
(FPCore (x y z) :precision binary64 (if (<= x -4.7e-29) x (if (<= x 1e-179) y x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -4.7e-29) {
tmp = x;
} else if (x <= 1e-179) {
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 <= (-4.7d-29)) then
tmp = x
else if (x <= 1d-179) 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 <= -4.7e-29) {
tmp = x;
} else if (x <= 1e-179) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -4.7e-29: tmp = x elif x <= 1e-179: tmp = y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -4.7e-29) tmp = x; elseif (x <= 1e-179) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -4.7e-29) tmp = x; elseif (x <= 1e-179) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -4.7e-29], x, If[LessEqual[x, 1e-179], y, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.7 \cdot 10^{-29}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 10^{-179}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -4.6999999999999998e-29 or 1e-179 < x Initial program 88.3%
Taylor expanded in y around 0 46.7%
if -4.6999999999999998e-29 < x < 1e-179Initial program 89.2%
Taylor expanded in z around inf 48.0%
+-commutative48.0%
Simplified48.0%
Taylor expanded in y around inf 35.0%
(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.5%
Taylor expanded in y around 0 37.6%
(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 2024191
(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))))