
(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 11 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-258) (not (<= t_0 4e-278)))
t_0
(- (/ (* z (+ 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-258) || !(t_0 <= 4e-278)) {
tmp = t_0;
} else {
tmp = ((z * (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-258)) .or. (.not. (t_0 <= 4d-278))) then
tmp = t_0
else
tmp = ((z * (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-258) || !(t_0 <= 4e-278)) {
tmp = t_0;
} else {
tmp = ((z * (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-258) or not (t_0 <= 4e-278): tmp = t_0 else: tmp = ((z * (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-258) || !(t_0 <= 4e-278)) tmp = t_0; else tmp = Float64(Float64(Float64(z * Float64(x + 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-258) || ~((t_0 <= 4e-278))) tmp = t_0; else tmp = ((z * (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-258], N[Not[LessEqual[t$95$0, 4e-278]], $MachinePrecision]], t$95$0, N[(N[(N[(z * N[(x + z), $MachinePrecision]), $MachinePrecision] / (-y)), $MachinePrecision] - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{-258} \lor \neg \left(t\_0 \leq 4 \cdot 10^{-278}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{z \cdot \left(x + z\right)}{-y} - z\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -3.99999999999999982e-258 or 3.99999999999999975e-278 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) Initial program 99.8%
if -3.99999999999999982e-258 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < 3.99999999999999975e-278Initial program 28.7%
Taylor expanded in y around inf 100.0%
associate--l+100.0%
associate-*r/100.0%
div-sub100.0%
remove-double-neg100.0%
mul-1-neg100.0%
neg-mul-1100.0%
distribute-lft-out--100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
unsub-neg100.0%
mul-1-neg100.0%
sub-neg100.0%
mul-1-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
unpow2100.0%
distribute-rgt-out100.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-258) (not (<= t_0 4e-278)))
t_0
(* z (/ (+ x y) (- y))))))
double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -4e-258) || !(t_0 <= 4e-278)) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = (x + y) / (1.0d0 - (y / z))
if ((t_0 <= (-4d-258)) .or. (.not. (t_0 <= 4d-278))) then
tmp = t_0
else
tmp = z * ((x + y) / -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-258) || !(t_0 <= 4e-278)) {
tmp = t_0;
} else {
tmp = z * ((x + y) / -y);
}
return tmp;
}
def code(x, y, z): t_0 = (x + y) / (1.0 - (y / z)) tmp = 0 if (t_0 <= -4e-258) or not (t_0 <= 4e-278): tmp = t_0 else: tmp = z * ((x + y) / -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-258) || !(t_0 <= 4e-278)) tmp = t_0; else tmp = Float64(z * Float64(Float64(x + y) / Float64(-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-258) || ~((t_0 <= 4e-278))) tmp = t_0; else tmp = z * ((x + y) / -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-258], N[Not[LessEqual[t$95$0, 4e-278]], $MachinePrecision]], t$95$0, N[(z * N[(N[(x + y), $MachinePrecision] / (-y)), $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^{-258} \lor \neg \left(t\_0 \leq 4 \cdot 10^{-278}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{x + y}{-y}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -3.99999999999999982e-258 or 3.99999999999999975e-278 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) Initial program 99.8%
if -3.99999999999999982e-258 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < 3.99999999999999975e-278Initial program 28.7%
Taylor expanded in z around 0 85.2%
*-commutative85.2%
associate-/l*100.0%
associate-*r*100.0%
associate-*l/100.0%
*-commutative100.0%
neg-mul-1100.0%
distribute-neg-in100.0%
unsub-neg100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(if (<= y -3.55e+220)
(- z)
(if (<= y -0.082)
(* y (/ z (- z y)))
(if (<= y -1.45e-194)
(+ x y)
(if (<= y 3.3e+81) (/ x (- 1.0 (/ y z))) (- z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.55e+220) {
tmp = -z;
} else if (y <= -0.082) {
tmp = y * (z / (z - y));
} else if (y <= -1.45e-194) {
tmp = x + y;
} else if (y <= 3.3e+81) {
tmp = x / (1.0 - (y / z));
} 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 <= (-3.55d+220)) then
tmp = -z
else if (y <= (-0.082d0)) then
tmp = y * (z / (z - y))
else if (y <= (-1.45d-194)) then
tmp = x + y
else if (y <= 3.3d+81) then
tmp = x / (1.0d0 - (y / z))
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -3.55e+220) {
tmp = -z;
} else if (y <= -0.082) {
tmp = y * (z / (z - y));
} else if (y <= -1.45e-194) {
tmp = x + y;
} else if (y <= 3.3e+81) {
tmp = x / (1.0 - (y / z));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.55e+220: tmp = -z elif y <= -0.082: tmp = y * (z / (z - y)) elif y <= -1.45e-194: tmp = x + y elif y <= 3.3e+81: tmp = x / (1.0 - (y / z)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.55e+220) tmp = Float64(-z); elseif (y <= -0.082) tmp = Float64(y * Float64(z / Float64(z - y))); elseif (y <= -1.45e-194) tmp = Float64(x + y); elseif (y <= 3.3e+81) tmp = Float64(x / Float64(1.0 - Float64(y / z))); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.55e+220) tmp = -z; elseif (y <= -0.082) tmp = y * (z / (z - y)); elseif (y <= -1.45e-194) tmp = x + y; elseif (y <= 3.3e+81) tmp = x / (1.0 - (y / z)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.55e+220], (-z), If[LessEqual[y, -0.082], N[(y * N[(z / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -1.45e-194], N[(x + y), $MachinePrecision], If[LessEqual[y, 3.3e+81], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-z)]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.55 \cdot 10^{+220}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -0.082:\\
\;\;\;\;y \cdot \frac{z}{z - y}\\
\mathbf{elif}\;y \leq -1.45 \cdot 10^{-194}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq 3.3 \cdot 10^{+81}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -3.55000000000000002e220 or 3.3e81 < y Initial program 68.4%
Taylor expanded in y around inf 68.6%
mul-1-neg68.6%
Simplified68.6%
if -3.55000000000000002e220 < y < -0.0820000000000000034Initial program 84.5%
Taylor expanded in z around 0 84.5%
Taylor expanded in x around 0 59.4%
associate-/l*71.4%
Simplified71.4%
if -0.0820000000000000034 < y < -1.44999999999999985e-194Initial program 99.8%
Taylor expanded in z around inf 65.5%
+-commutative65.5%
Simplified65.5%
if -1.44999999999999985e-194 < y < 3.3e81Initial program 99.9%
Taylor expanded in x around inf 80.9%
Final simplification73.9%
(FPCore (x y z)
:precision binary64
(if (<= z -1.3e-6)
(+ x y)
(if (<= z 3.2e-72)
(- (* x (/ z (- y))) z)
(if (<= z 8.5e+81) (/ x (- 1.0 (/ y z))) (* (+ x y) (+ 1.0 (/ y z)))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.3e-6) {
tmp = x + y;
} else if (z <= 3.2e-72) {
tmp = (x * (z / -y)) - z;
} else if (z <= 8.5e+81) {
tmp = x / (1.0 - (y / z));
} 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 <= (-1.3d-6)) then
tmp = x + y
else if (z <= 3.2d-72) then
tmp = (x * (z / -y)) - z
else if (z <= 8.5d+81) then
tmp = x / (1.0d0 - (y / z))
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 <= -1.3e-6) {
tmp = x + y;
} else if (z <= 3.2e-72) {
tmp = (x * (z / -y)) - z;
} else if (z <= 8.5e+81) {
tmp = x / (1.0 - (y / z));
} else {
tmp = (x + y) * (1.0 + (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.3e-6: tmp = x + y elif z <= 3.2e-72: tmp = (x * (z / -y)) - z elif z <= 8.5e+81: tmp = x / (1.0 - (y / z)) else: tmp = (x + y) * (1.0 + (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.3e-6) tmp = Float64(x + y); elseif (z <= 3.2e-72) tmp = Float64(Float64(x * Float64(z / Float64(-y))) - z); elseif (z <= 8.5e+81) tmp = Float64(x / Float64(1.0 - Float64(y / z))); 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 <= -1.3e-6) tmp = x + y; elseif (z <= 3.2e-72) tmp = (x * (z / -y)) - z; elseif (z <= 8.5e+81) tmp = x / (1.0 - (y / z)); else tmp = (x + y) * (1.0 + (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.3e-6], N[(x + y), $MachinePrecision], If[LessEqual[z, 3.2e-72], N[(N[(x * N[(z / (-y)), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[z, 8.5e+81], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $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 -1.3 \cdot 10^{-6}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 3.2 \cdot 10^{-72}:\\
\;\;\;\;x \cdot \frac{z}{-y} - z\\
\mathbf{elif}\;z \leq 8.5 \cdot 10^{+81}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;\left(x + y\right) \cdot \left(1 + \frac{y}{z}\right)\\
\end{array}
\end{array}
if z < -1.30000000000000005e-6Initial program 100.0%
Taylor expanded in z around inf 75.7%
+-commutative75.7%
Simplified75.7%
if -1.30000000000000005e-6 < z < 3.19999999999999999e-72Initial program 77.5%
Taylor expanded in y around inf 78.5%
associate--l+78.5%
associate-*r/78.5%
div-sub78.5%
remove-double-neg78.5%
mul-1-neg78.5%
neg-mul-178.5%
distribute-lft-out--78.5%
mul-1-neg78.5%
distribute-neg-frac78.5%
unsub-neg78.5%
mul-1-neg78.5%
sub-neg78.5%
mul-1-neg78.5%
remove-double-neg78.5%
+-commutative78.5%
unpow278.5%
distribute-rgt-out78.5%
Simplified78.5%
Taylor expanded in z around 0 78.6%
associate-/l*76.8%
Simplified76.8%
if 3.19999999999999999e-72 < z < 8.49999999999999986e81Initial program 95.9%
Taylor expanded in x around inf 80.1%
if 8.49999999999999986e81 < z Initial program 99.9%
Taylor expanded in z around inf 71.6%
associate-+r+71.6%
*-rgt-identity71.6%
*-commutative71.6%
associate-/l*86.9%
distribute-lft-in86.8%
+-commutative86.8%
Simplified86.8%
Final simplification78.8%
(FPCore (x y z)
:precision binary64
(if (<= y -3.5e+209)
(- z)
(if (<= y -1.4e+186)
y
(if (or (<= y -9e+27) (not (<= y 5.5e+82))) (- z) (+ x y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.5e+209) {
tmp = -z;
} else if (y <= -1.4e+186) {
tmp = y;
} else if ((y <= -9e+27) || !(y <= 5.5e+82)) {
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 <= (-3.5d+209)) then
tmp = -z
else if (y <= (-1.4d+186)) then
tmp = y
else if ((y <= (-9d+27)) .or. (.not. (y <= 5.5d+82))) 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 <= -3.5e+209) {
tmp = -z;
} else if (y <= -1.4e+186) {
tmp = y;
} else if ((y <= -9e+27) || !(y <= 5.5e+82)) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.5e+209: tmp = -z elif y <= -1.4e+186: tmp = y elif (y <= -9e+27) or not (y <= 5.5e+82): tmp = -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.5e+209) tmp = Float64(-z); elseif (y <= -1.4e+186) tmp = y; elseif ((y <= -9e+27) || !(y <= 5.5e+82)) tmp = Float64(-z); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.5e+209) tmp = -z; elseif (y <= -1.4e+186) tmp = y; elseif ((y <= -9e+27) || ~((y <= 5.5e+82))) tmp = -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.5e+209], (-z), If[LessEqual[y, -1.4e+186], y, If[Or[LessEqual[y, -9e+27], N[Not[LessEqual[y, 5.5e+82]], $MachinePrecision]], (-z), N[(x + y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.5 \cdot 10^{+209}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -1.4 \cdot 10^{+186}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq -9 \cdot 10^{+27} \lor \neg \left(y \leq 5.5 \cdot 10^{+82}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -3.5000000000000003e209 or -1.40000000000000009e186 < y < -8.9999999999999998e27 or 5.49999999999999997e82 < y Initial program 72.9%
Taylor expanded in y around inf 63.6%
mul-1-neg63.6%
Simplified63.6%
if -3.5000000000000003e209 < y < -1.40000000000000009e186Initial program 100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in y around 0 86.0%
if -8.9999999999999998e27 < y < 5.49999999999999997e82Initial program 99.9%
Taylor expanded in z around inf 72.0%
+-commutative72.0%
Simplified72.0%
Final simplification69.1%
(FPCore (x y z)
:precision binary64
(if (<= y -3.5e+209)
(- z)
(if (<= y -1.4e+186)
y
(if (or (<= y -0.215) (not (<= y 6.5e-8))) (- z) x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.5e+209) {
tmp = -z;
} else if (y <= -1.4e+186) {
tmp = y;
} else if ((y <= -0.215) || !(y <= 6.5e-8)) {
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 <= (-3.5d+209)) then
tmp = -z
else if (y <= (-1.4d+186)) then
tmp = y
else if ((y <= (-0.215d0)) .or. (.not. (y <= 6.5d-8))) 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 <= -3.5e+209) {
tmp = -z;
} else if (y <= -1.4e+186) {
tmp = y;
} else if ((y <= -0.215) || !(y <= 6.5e-8)) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.5e+209: tmp = -z elif y <= -1.4e+186: tmp = y elif (y <= -0.215) or not (y <= 6.5e-8): tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.5e+209) tmp = Float64(-z); elseif (y <= -1.4e+186) tmp = y; elseif ((y <= -0.215) || !(y <= 6.5e-8)) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.5e+209) tmp = -z; elseif (y <= -1.4e+186) tmp = y; elseif ((y <= -0.215) || ~((y <= 6.5e-8))) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.5e+209], (-z), If[LessEqual[y, -1.4e+186], y, If[Or[LessEqual[y, -0.215], N[Not[LessEqual[y, 6.5e-8]], $MachinePrecision]], (-z), x]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.5 \cdot 10^{+209}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -1.4 \cdot 10^{+186}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq -0.215 \lor \neg \left(y \leq 6.5 \cdot 10^{-8}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -3.5000000000000003e209 or -1.40000000000000009e186 < y < -0.214999999999999997 or 6.49999999999999997e-8 < y Initial program 76.7%
Taylor expanded in y around inf 58.7%
mul-1-neg58.7%
Simplified58.7%
if -3.5000000000000003e209 < y < -1.40000000000000009e186Initial program 100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in y around 0 86.0%
if -0.214999999999999997 < y < 6.49999999999999997e-8Initial program 99.9%
Taylor expanded in y around 0 60.5%
Final simplification60.4%
(FPCore (x y z)
:precision binary64
(if (<= z -2.1e-7)
(+ x y)
(if (<= z 5e-72)
(* z (/ (+ x y) (- y)))
(if (<= z 6.2e+81) (/ x (- 1.0 (/ y z))) (+ x y)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.1e-7) {
tmp = x + y;
} else if (z <= 5e-72) {
tmp = z * ((x + y) / -y);
} else if (z <= 6.2e+81) {
tmp = x / (1.0 - (y / 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 (z <= (-2.1d-7)) then
tmp = x + y
else if (z <= 5d-72) then
tmp = z * ((x + y) / -y)
else if (z <= 6.2d+81) then
tmp = x / (1.0d0 - (y / z))
else
tmp = x + y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -2.1e-7) {
tmp = x + y;
} else if (z <= 5e-72) {
tmp = z * ((x + y) / -y);
} else if (z <= 6.2e+81) {
tmp = x / (1.0 - (y / z));
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.1e-7: tmp = x + y elif z <= 5e-72: tmp = z * ((x + y) / -y) elif z <= 6.2e+81: tmp = x / (1.0 - (y / z)) else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.1e-7) tmp = Float64(x + y); elseif (z <= 5e-72) tmp = Float64(z * Float64(Float64(x + y) / Float64(-y))); elseif (z <= 6.2e+81) tmp = Float64(x / Float64(1.0 - Float64(y / z))); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2.1e-7) tmp = x + y; elseif (z <= 5e-72) tmp = z * ((x + y) / -y); elseif (z <= 6.2e+81) tmp = x / (1.0 - (y / z)); else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.1e-7], N[(x + y), $MachinePrecision], If[LessEqual[z, 5e-72], N[(z * N[(N[(x + y), $MachinePrecision] / (-y)), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.2e+81], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.1 \cdot 10^{-7}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 5 \cdot 10^{-72}:\\
\;\;\;\;z \cdot \frac{x + y}{-y}\\
\mathbf{elif}\;z \leq 6.2 \cdot 10^{+81}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if z < -2.1e-7 or 6.2e81 < z Initial program 99.9%
Taylor expanded in z around inf 80.5%
+-commutative80.5%
Simplified80.5%
if -2.1e-7 < z < 4.9999999999999996e-72Initial program 77.5%
Taylor expanded in z around 0 71.1%
*-commutative71.1%
associate-/l*76.1%
associate-*r*76.1%
associate-*l/76.1%
*-commutative76.1%
neg-mul-176.1%
distribute-neg-in76.1%
unsub-neg76.1%
Simplified76.1%
if 4.9999999999999996e-72 < z < 6.2e81Initial program 95.9%
Taylor expanded in x around inf 80.1%
Final simplification78.5%
(FPCore (x y z)
:precision binary64
(if (<= z -5.6e-10)
(+ x y)
(if (<= z 4.3e-73)
(- (* x (/ z (- y))) z)
(if (<= z 6.2e+81) (/ x (- 1.0 (/ y z))) (+ x y)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -5.6e-10) {
tmp = x + y;
} else if (z <= 4.3e-73) {
tmp = (x * (z / -y)) - z;
} else if (z <= 6.2e+81) {
tmp = x / (1.0 - (y / 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 (z <= (-5.6d-10)) then
tmp = x + y
else if (z <= 4.3d-73) then
tmp = (x * (z / -y)) - z
else if (z <= 6.2d+81) then
tmp = x / (1.0d0 - (y / z))
else
tmp = x + y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -5.6e-10) {
tmp = x + y;
} else if (z <= 4.3e-73) {
tmp = (x * (z / -y)) - z;
} else if (z <= 6.2e+81) {
tmp = x / (1.0 - (y / z));
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -5.6e-10: tmp = x + y elif z <= 4.3e-73: tmp = (x * (z / -y)) - z elif z <= 6.2e+81: tmp = x / (1.0 - (y / z)) else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if (z <= -5.6e-10) tmp = Float64(x + y); elseif (z <= 4.3e-73) tmp = Float64(Float64(x * Float64(z / Float64(-y))) - z); elseif (z <= 6.2e+81) tmp = Float64(x / Float64(1.0 - Float64(y / z))); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -5.6e-10) tmp = x + y; elseif (z <= 4.3e-73) tmp = (x * (z / -y)) - z; elseif (z <= 6.2e+81) tmp = x / (1.0 - (y / z)); else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -5.6e-10], N[(x + y), $MachinePrecision], If[LessEqual[z, 4.3e-73], N[(N[(x * N[(z / (-y)), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[z, 6.2e+81], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.6 \cdot 10^{-10}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 4.3 \cdot 10^{-73}:\\
\;\;\;\;x \cdot \frac{z}{-y} - z\\
\mathbf{elif}\;z \leq 6.2 \cdot 10^{+81}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if z < -5.60000000000000031e-10 or 6.2e81 < z Initial program 99.9%
Taylor expanded in z around inf 80.5%
+-commutative80.5%
Simplified80.5%
if -5.60000000000000031e-10 < z < 4.2999999999999999e-73Initial program 77.5%
Taylor expanded in y around inf 78.5%
associate--l+78.5%
associate-*r/78.5%
div-sub78.5%
remove-double-neg78.5%
mul-1-neg78.5%
neg-mul-178.5%
distribute-lft-out--78.5%
mul-1-neg78.5%
distribute-neg-frac78.5%
unsub-neg78.5%
mul-1-neg78.5%
sub-neg78.5%
mul-1-neg78.5%
remove-double-neg78.5%
+-commutative78.5%
unpow278.5%
distribute-rgt-out78.5%
Simplified78.5%
Taylor expanded in z around 0 78.6%
associate-/l*76.8%
Simplified76.8%
if 4.2999999999999999e-73 < z < 6.2e81Initial program 95.9%
Taylor expanded in x around inf 80.1%
Final simplification78.8%
(FPCore (x y z) :precision binary64 (if (<= y -3.55e+220) (- z) (if (<= y -4.5e-11) (* y (/ z (- z y))) (if (<= y 3.7e+80) (+ x y) (- z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.55e+220) {
tmp = -z;
} else if (y <= -4.5e-11) {
tmp = y * (z / (z - y));
} else if (y <= 3.7e+80) {
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 <= (-3.55d+220)) then
tmp = -z
else if (y <= (-4.5d-11)) then
tmp = y * (z / (z - y))
else if (y <= 3.7d+80) 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 <= -3.55e+220) {
tmp = -z;
} else if (y <= -4.5e-11) {
tmp = y * (z / (z - y));
} else if (y <= 3.7e+80) {
tmp = x + y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.55e+220: tmp = -z elif y <= -4.5e-11: tmp = y * (z / (z - y)) elif y <= 3.7e+80: tmp = x + y else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.55e+220) tmp = Float64(-z); elseif (y <= -4.5e-11) tmp = Float64(y * Float64(z / Float64(z - y))); elseif (y <= 3.7e+80) tmp = Float64(x + y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.55e+220) tmp = -z; elseif (y <= -4.5e-11) tmp = y * (z / (z - y)); elseif (y <= 3.7e+80) tmp = x + y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.55e+220], (-z), If[LessEqual[y, -4.5e-11], N[(y * N[(z / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.7e+80], N[(x + y), $MachinePrecision], (-z)]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.55 \cdot 10^{+220}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -4.5 \cdot 10^{-11}:\\
\;\;\;\;y \cdot \frac{z}{z - y}\\
\mathbf{elif}\;y \leq 3.7 \cdot 10^{+80}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -3.55000000000000002e220 or 3.69999999999999996e80 < y Initial program 68.4%
Taylor expanded in y around inf 68.6%
mul-1-neg68.6%
Simplified68.6%
if -3.55000000000000002e220 < y < -4.5e-11Initial program 84.5%
Taylor expanded in z around 0 84.5%
Taylor expanded in x around 0 59.4%
associate-/l*71.4%
Simplified71.4%
if -4.5e-11 < y < 3.69999999999999996e80Initial program 99.9%
Taylor expanded in z around inf 72.6%
+-commutative72.6%
Simplified72.6%
Final simplification71.5%
(FPCore (x y z) :precision binary64 (if (<= x -1.08e-162) x (if (<= x 4.5e-134) y x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.08e-162) {
tmp = x;
} else if (x <= 4.5e-134) {
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 <= (-1.08d-162)) then
tmp = x
else if (x <= 4.5d-134) 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 <= -1.08e-162) {
tmp = x;
} else if (x <= 4.5e-134) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.08e-162: tmp = x elif x <= 4.5e-134: tmp = y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.08e-162) tmp = x; elseif (x <= 4.5e-134) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.08e-162) tmp = x; elseif (x <= 4.5e-134) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.08e-162], x, If[LessEqual[x, 4.5e-134], y, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.08 \cdot 10^{-162}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 4.5 \cdot 10^{-134}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.08000000000000006e-162 or 4.5000000000000005e-134 < x Initial program 88.3%
Taylor expanded in y around 0 44.1%
if -1.08000000000000006e-162 < x < 4.5000000000000005e-134Initial program 93.6%
Taylor expanded in x around 0 84.9%
Taylor expanded in y around 0 50.0%
Final simplification45.5%
(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 89.6%
Taylor expanded in y around 0 35.8%
Final simplification35.8%
(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 2024095
(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))))