
(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 -4e-257) (not (<= t_0 5e-298)))
t_0
(- (- (- z) (/ z (/ y x))) (/ z (/ y z))))))
double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -4e-257) || !(t_0 <= 5e-298)) {
tmp = t_0;
} else {
tmp = (-z - (z / (y / x))) - (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) :: t_0
real(8) :: tmp
t_0 = (x + y) / (1.0d0 - (y / z))
if ((t_0 <= (-4d-257)) .or. (.not. (t_0 <= 5d-298))) then
tmp = t_0
else
tmp = (-z - (z / (y / x))) - (z / (y / z))
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 <= -4e-257) || !(t_0 <= 5e-298)) {
tmp = t_0;
} else {
tmp = (-z - (z / (y / x))) - (z / (y / z));
}
return tmp;
}
def code(x, y, z): t_0 = (x + y) / (1.0 - (y / z)) tmp = 0 if (t_0 <= -4e-257) or not (t_0 <= 5e-298): tmp = t_0 else: tmp = (-z - (z / (y / x))) - (z / (y / z)) 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 <= -4e-257) || !(t_0 <= 5e-298)) tmp = t_0; else tmp = Float64(Float64(Float64(-z) - Float64(z / Float64(y / x))) - Float64(z / Float64(y / z))); 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 <= -4e-257) || ~((t_0 <= 5e-298))) tmp = t_0; else tmp = (-z - (z / (y / x))) - (z / (y / z)); 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, -4e-257], N[Not[LessEqual[t$95$0, 5e-298]], $MachinePrecision]], t$95$0, N[(N[((-z) - N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{if}\;t_0 \leq -4 \cdot 10^{-257} \lor \neg \left(t_0 \leq 5 \cdot 10^{-298}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-z\right) - \frac{z}{\frac{y}{x}}\right) - \frac{z}{\frac{y}{z}}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -3.9999999999999999e-257 or 5.0000000000000002e-298 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) Initial program 99.9%
if -3.9999999999999999e-257 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < 5.0000000000000002e-298Initial program 9.5%
Taylor expanded in y around inf 99.9%
mul-1-neg99.9%
unsub-neg99.9%
mul-1-neg99.9%
associate-/l*100.0%
unpow2100.0%
associate-/l*100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (+ x y) (- 1.0 (/ y z)))))
(if (or (<= t_0 -4e-257) (not (<= t_0 5e-298)))
t_0
(- (- z) (* z (/ x y))))))
double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -4e-257) || !(t_0 <= 5e-298)) {
tmp = t_0;
} else {
tmp = -z - (z * (x / y));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (x + y) / (1.0d0 - (y / z))
if ((t_0 <= (-4d-257)) .or. (.not. (t_0 <= 5d-298))) then
tmp = t_0
else
tmp = -z - (z * (x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -4e-257) || !(t_0 <= 5e-298)) {
tmp = t_0;
} else {
tmp = -z - (z * (x / y));
}
return tmp;
}
def code(x, y, z): t_0 = (x + y) / (1.0 - (y / z)) tmp = 0 if (t_0 <= -4e-257) or not (t_0 <= 5e-298): tmp = t_0 else: tmp = -z - (z * (x / y)) return tmp
function code(x, y, z) t_0 = Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))) tmp = 0.0 if ((t_0 <= -4e-257) || !(t_0 <= 5e-298)) tmp = t_0; else tmp = Float64(Float64(-z) - Float64(z * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x + y) / (1.0 - (y / z)); tmp = 0.0; if ((t_0 <= -4e-257) || ~((t_0 <= 5e-298))) tmp = t_0; else tmp = -z - (z * (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -4e-257], N[Not[LessEqual[t$95$0, 5e-298]], $MachinePrecision]], t$95$0, N[((-z) - N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{if}\;t_0 \leq -4 \cdot 10^{-257} \lor \neg \left(t_0 \leq 5 \cdot 10^{-298}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - z \cdot \frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -3.9999999999999999e-257 or 5.0000000000000002e-298 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) Initial program 99.9%
if -3.9999999999999999e-257 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < 5.0000000000000002e-298Initial program 9.5%
Taylor expanded in z around 0 96.5%
mul-1-neg96.5%
associate-/l*9.5%
+-commutative9.5%
distribute-neg-frac9.5%
distribute-neg-in9.5%
+-commutative9.5%
sub-neg9.5%
Simplified9.5%
Taylor expanded in y around 0 99.9%
distribute-lft-out99.9%
associate-*r/99.9%
neg-mul-199.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(if (<= y -2.7e+116)
(- z)
(if (<= y -7e+69)
(+ x y)
(if (<= y -2e+64)
(- z)
(if (<= y -2.8e-184)
(/ x (- 1.0 (/ y z)))
(if (<= y 1.08e+89) (+ x y) (- z)))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.7e+116) {
tmp = -z;
} else if (y <= -7e+69) {
tmp = x + y;
} else if (y <= -2e+64) {
tmp = -z;
} else if (y <= -2.8e-184) {
tmp = x / (1.0 - (y / z));
} else if (y <= 1.08e+89) {
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.7d+116)) then
tmp = -z
else if (y <= (-7d+69)) then
tmp = x + y
else if (y <= (-2d+64)) then
tmp = -z
else if (y <= (-2.8d-184)) then
tmp = x / (1.0d0 - (y / z))
else if (y <= 1.08d+89) 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.7e+116) {
tmp = -z;
} else if (y <= -7e+69) {
tmp = x + y;
} else if (y <= -2e+64) {
tmp = -z;
} else if (y <= -2.8e-184) {
tmp = x / (1.0 - (y / z));
} else if (y <= 1.08e+89) {
tmp = x + y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.7e+116: tmp = -z elif y <= -7e+69: tmp = x + y elif y <= -2e+64: tmp = -z elif y <= -2.8e-184: tmp = x / (1.0 - (y / z)) elif y <= 1.08e+89: tmp = x + y else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.7e+116) tmp = Float64(-z); elseif (y <= -7e+69) tmp = Float64(x + y); elseif (y <= -2e+64) tmp = Float64(-z); elseif (y <= -2.8e-184) tmp = Float64(x / Float64(1.0 - Float64(y / z))); elseif (y <= 1.08e+89) 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.7e+116) tmp = -z; elseif (y <= -7e+69) tmp = x + y; elseif (y <= -2e+64) tmp = -z; elseif (y <= -2.8e-184) tmp = x / (1.0 - (y / z)); elseif (y <= 1.08e+89) tmp = x + y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.7e+116], (-z), If[LessEqual[y, -7e+69], N[(x + y), $MachinePrecision], If[LessEqual[y, -2e+64], (-z), If[LessEqual[y, -2.8e-184], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.08e+89], N[(x + y), $MachinePrecision], (-z)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{+116}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -7 \cdot 10^{+69}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq -2 \cdot 10^{+64}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -2.8 \cdot 10^{-184}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\mathbf{elif}\;y \leq 1.08 \cdot 10^{+89}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -2.7e116 or -6.99999999999999974e69 < y < -2.00000000000000004e64 or 1.08000000000000006e89 < y Initial program 72.9%
Taylor expanded in y around inf 74.2%
mul-1-neg74.2%
Simplified74.2%
if -2.7e116 < y < -6.99999999999999974e69 or -2.7999999999999998e-184 < y < 1.08000000000000006e89Initial program 96.4%
Taylor expanded in z around inf 74.2%
if -2.00000000000000004e64 < y < -2.7999999999999998e-184Initial program 99.8%
Taylor expanded in x around inf 66.7%
Final simplification72.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ y z))) (t_1 (/ x t_0)))
(if (<= x -2.15e-13)
t_1
(if (<= x 7.2e-102)
(/ y t_0)
(if (<= x 7e+25)
(- (- z) (* z (/ x y)))
(if (<= x 1.3e+47) (+ x y) t_1))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = x / t_0;
double tmp;
if (x <= -2.15e-13) {
tmp = t_1;
} else if (x <= 7.2e-102) {
tmp = y / t_0;
} else if (x <= 7e+25) {
tmp = -z - (z * (x / y));
} else if (x <= 1.3e+47) {
tmp = x + y;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (y / z)
t_1 = x / t_0
if (x <= (-2.15d-13)) then
tmp = t_1
else if (x <= 7.2d-102) then
tmp = y / t_0
else if (x <= 7d+25) then
tmp = -z - (z * (x / y))
else if (x <= 1.3d+47) then
tmp = x + y
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = x / t_0;
double tmp;
if (x <= -2.15e-13) {
tmp = t_1;
} else if (x <= 7.2e-102) {
tmp = y / t_0;
} else if (x <= 7e+25) {
tmp = -z - (z * (x / y));
} else if (x <= 1.3e+47) {
tmp = x + y;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) t_1 = x / t_0 tmp = 0 if x <= -2.15e-13: tmp = t_1 elif x <= 7.2e-102: tmp = y / t_0 elif x <= 7e+25: tmp = -z - (z * (x / y)) elif x <= 1.3e+47: tmp = x + y else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y / z)) t_1 = Float64(x / t_0) tmp = 0.0 if (x <= -2.15e-13) tmp = t_1; elseif (x <= 7.2e-102) tmp = Float64(y / t_0); elseif (x <= 7e+25) tmp = Float64(Float64(-z) - Float64(z * Float64(x / y))); elseif (x <= 1.3e+47) tmp = Float64(x + y); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y / z); t_1 = x / t_0; tmp = 0.0; if (x <= -2.15e-13) tmp = t_1; elseif (x <= 7.2e-102) tmp = y / t_0; elseif (x <= 7e+25) tmp = -z - (z * (x / y)); elseif (x <= 1.3e+47) tmp = x + y; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / t$95$0), $MachinePrecision]}, If[LessEqual[x, -2.15e-13], t$95$1, If[LessEqual[x, 7.2e-102], N[(y / t$95$0), $MachinePrecision], If[LessEqual[x, 7e+25], N[((-z) - N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.3e+47], N[(x + y), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
t_1 := \frac{x}{t_0}\\
\mathbf{if}\;x \leq -2.15 \cdot 10^{-13}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{-102}:\\
\;\;\;\;\frac{y}{t_0}\\
\mathbf{elif}\;x \leq 7 \cdot 10^{+25}:\\
\;\;\;\;\left(-z\right) - z \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{+47}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -2.1499999999999999e-13 or 1.30000000000000002e47 < x Initial program 88.8%
Taylor expanded in x around inf 75.2%
if -2.1499999999999999e-13 < x < 7.2e-102Initial program 92.8%
Taylor expanded in x around 0 74.8%
if 7.2e-102 < x < 6.99999999999999999e25Initial program 86.8%
Taylor expanded in z around 0 61.2%
mul-1-neg61.2%
associate-/l*58.1%
+-commutative58.1%
distribute-neg-frac58.1%
distribute-neg-in58.1%
+-commutative58.1%
sub-neg58.1%
Simplified58.1%
Taylor expanded in y around 0 67.9%
distribute-lft-out67.9%
associate-*r/71.2%
neg-mul-171.2%
Simplified71.2%
if 6.99999999999999999e25 < x < 1.30000000000000002e47Initial program 100.0%
Taylor expanded in z around inf 85.9%
Final simplification74.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- 1.0 (/ y z)))) (if (or (<= x -9e-14) (not (<= x 9.5e-42))) (/ 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 <= -9e-14) || !(x <= 9.5e-42)) {
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 <= (-9d-14)) .or. (.not. (x <= 9.5d-42))) 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 <= -9e-14) || !(x <= 9.5e-42)) {
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 <= -9e-14) or not (x <= 9.5e-42): 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 <= -9e-14) || !(x <= 9.5e-42)) 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 <= -9e-14) || ~((x <= 9.5e-42))) 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, -9e-14], N[Not[LessEqual[x, 9.5e-42]], $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 -9 \cdot 10^{-14} \lor \neg \left(x \leq 9.5 \cdot 10^{-42}\right):\\
\;\;\;\;\frac{x}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{t_0}\\
\end{array}
\end{array}
if x < -8.9999999999999995e-14 or 9.49999999999999948e-42 < x Initial program 88.9%
Taylor expanded in x around inf 71.8%
if -8.9999999999999995e-14 < x < 9.49999999999999948e-42Initial program 92.5%
Taylor expanded in x around 0 75.1%
Final simplification73.1%
(FPCore (x y z)
:precision binary64
(if (<= y -6.2e+115)
(- z)
(if (<= y -5.2e+70)
y
(if (<= y -2e+54) (- z) (if (<= y 1.05e-40) x (- z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6.2e+115) {
tmp = -z;
} else if (y <= -5.2e+70) {
tmp = y;
} else if (y <= -2e+54) {
tmp = -z;
} else if (y <= 1.05e-40) {
tmp = x;
} 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 <= (-6.2d+115)) then
tmp = -z
else if (y <= (-5.2d+70)) then
tmp = y
else if (y <= (-2d+54)) then
tmp = -z
else if (y <= 1.05d-40) then
tmp = x
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -6.2e+115) {
tmp = -z;
} else if (y <= -5.2e+70) {
tmp = y;
} else if (y <= -2e+54) {
tmp = -z;
} else if (y <= 1.05e-40) {
tmp = x;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6.2e+115: tmp = -z elif y <= -5.2e+70: tmp = y elif y <= -2e+54: tmp = -z elif y <= 1.05e-40: tmp = x else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6.2e+115) tmp = Float64(-z); elseif (y <= -5.2e+70) tmp = y; elseif (y <= -2e+54) tmp = Float64(-z); elseif (y <= 1.05e-40) tmp = x; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -6.2e+115) tmp = -z; elseif (y <= -5.2e+70) tmp = y; elseif (y <= -2e+54) tmp = -z; elseif (y <= 1.05e-40) tmp = x; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6.2e+115], (-z), If[LessEqual[y, -5.2e+70], y, If[LessEqual[y, -2e+54], (-z), If[LessEqual[y, 1.05e-40], x, (-z)]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{+115}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -5.2 \cdot 10^{+70}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq -2 \cdot 10^{+54}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{-40}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -6.2000000000000001e115 or -5.2000000000000001e70 < y < -2.0000000000000002e54 or 1.05000000000000009e-40 < y Initial program 80.0%
Taylor expanded in y around inf 60.5%
mul-1-neg60.5%
Simplified60.5%
if -6.2000000000000001e115 < y < -5.2000000000000001e70Initial program 68.4%
Taylor expanded in x around 0 54.2%
Taylor expanded in y around 0 48.0%
if -2.0000000000000002e54 < y < 1.05000000000000009e-40Initial program 99.9%
Taylor expanded in y around 0 58.1%
Final simplification58.6%
(FPCore (x y z) :precision binary64 (if (<= y -9e+115) (- z) (if (<= y 9.2e+88) (+ x y) (- z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -9e+115) {
tmp = -z;
} else if (y <= 9.2e+88) {
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 <= (-9d+115)) then
tmp = -z
else if (y <= 9.2d+88) 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 <= -9e+115) {
tmp = -z;
} else if (y <= 9.2e+88) {
tmp = x + y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -9e+115: tmp = -z elif y <= 9.2e+88: tmp = x + y else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -9e+115) tmp = Float64(-z); elseif (y <= 9.2e+88) tmp = Float64(x + y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -9e+115) tmp = -z; elseif (y <= 9.2e+88) tmp = x + y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -9e+115], (-z), If[LessEqual[y, 9.2e+88], N[(x + y), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9 \cdot 10^{+115}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 9.2 \cdot 10^{+88}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -8.99999999999999927e115 or 9.2000000000000007e88 < y Initial program 73.4%
Taylor expanded in y around inf 74.2%
mul-1-neg74.2%
Simplified74.2%
if -8.99999999999999927e115 < y < 9.2000000000000007e88Initial program 96.8%
Taylor expanded in z around inf 67.9%
Final simplification69.7%
(FPCore (x y z) :precision binary64 (if (<= x -5.4e-13) x (if (<= x 2.65e-45) y x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -5.4e-13) {
tmp = x;
} else if (x <= 2.65e-45) {
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 <= (-5.4d-13)) then
tmp = x
else if (x <= 2.65d-45) 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 <= -5.4e-13) {
tmp = x;
} else if (x <= 2.65e-45) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -5.4e-13: tmp = x elif x <= 2.65e-45: tmp = y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -5.4e-13) tmp = x; elseif (x <= 2.65e-45) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -5.4e-13) tmp = x; elseif (x <= 2.65e-45) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -5.4e-13], x, If[LessEqual[x, 2.65e-45], y, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.4 \cdot 10^{-13}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 2.65 \cdot 10^{-45}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -5.40000000000000021e-13 or 2.6499999999999999e-45 < x Initial program 88.9%
Taylor expanded in y around 0 52.2%
if -5.40000000000000021e-13 < x < 2.6499999999999999e-45Initial program 92.5%
Taylor expanded in x around 0 74.2%
Taylor expanded in y around 0 40.2%
Final simplification47.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 90.3%
Taylor expanded in y around 0 37.0%
Final simplification37.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ (+ y x) (- y)) z)))
(if (< y -3.7429310762689856e+171)
t_0
(if (< y 3.5534662456086734e+168) (/ (+ x y) (- 1.0 (/ y z))) t_0))))
double code(double x, double y, double z) {
double t_0 = ((y + x) / -y) * z;
double tmp;
if (y < -3.7429310762689856e+171) {
tmp = t_0;
} else if (y < 3.5534662456086734e+168) {
tmp = (x + y) / (1.0 - (y / z));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = ((y + x) / -y) * z
if (y < (-3.7429310762689856d+171)) then
tmp = t_0
else if (y < 3.5534662456086734d+168) then
tmp = (x + y) / (1.0d0 - (y / z))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((y + x) / -y) * z;
double tmp;
if (y < -3.7429310762689856e+171) {
tmp = t_0;
} else if (y < 3.5534662456086734e+168) {
tmp = (x + y) / (1.0 - (y / z));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = ((y + x) / -y) * z tmp = 0 if y < -3.7429310762689856e+171: tmp = t_0 elif y < 3.5534662456086734e+168: tmp = (x + y) / (1.0 - (y / z)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(y + x) / Float64(-y)) * z) tmp = 0.0 if (y < -3.7429310762689856e+171) tmp = t_0; elseif (y < 3.5534662456086734e+168) tmp = Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((y + x) / -y) * z; tmp = 0.0; if (y < -3.7429310762689856e+171) tmp = t_0; elseif (y < 3.5534662456086734e+168) tmp = (x + y) / (1.0 - (y / z)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(y + x), $MachinePrecision] / (-y)), $MachinePrecision] * z), $MachinePrecision]}, If[Less[y, -3.7429310762689856e+171], t$95$0, If[Less[y, 3.5534662456086734e+168], N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y + x}{-y} \cdot z\\
\mathbf{if}\;y < -3.7429310762689856 \cdot 10^{+171}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y < 3.5534662456086734 \cdot 10^{+168}:\\
\;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
herbie shell --seed 2023240
(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))))