
(FPCore (x y z t) :precision binary64 (- x (/ (* (* y 2.0) z) (- (* (* z 2.0) z) (* y t)))))
double code(double x, double y, double z, double t) {
return x - (((y * 2.0) * z) / (((z * 2.0) * z) - (y * t)));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x - (((y * 2.0d0) * z) / (((z * 2.0d0) * z) - (y * t)))
end function
public static double code(double x, double y, double z, double t) {
return x - (((y * 2.0) * z) / (((z * 2.0) * z) - (y * t)));
}
def code(x, y, z, t): return x - (((y * 2.0) * z) / (((z * 2.0) * z) - (y * t)))
function code(x, y, z, t) return Float64(x - Float64(Float64(Float64(y * 2.0) * z) / Float64(Float64(Float64(z * 2.0) * z) - Float64(y * t)))) end
function tmp = code(x, y, z, t) tmp = x - (((y * 2.0) * z) / (((z * 2.0) * z) - (y * t))); end
code[x_, y_, z_, t_] := N[(x - N[(N[(N[(y * 2.0), $MachinePrecision] * z), $MachinePrecision] / N[(N[(N[(z * 2.0), $MachinePrecision] * z), $MachinePrecision] - N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (- x (/ (* (* y 2.0) z) (- (* (* z 2.0) z) (* y t)))))
double code(double x, double y, double z, double t) {
return x - (((y * 2.0) * z) / (((z * 2.0) * z) - (y * t)));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x - (((y * 2.0d0) * z) / (((z * 2.0d0) * z) - (y * t)))
end function
public static double code(double x, double y, double z, double t) {
return x - (((y * 2.0) * z) / (((z * 2.0) * z) - (y * t)));
}
def code(x, y, z, t): return x - (((y * 2.0) * z) / (((z * 2.0) * z) - (y * t)))
function code(x, y, z, t) return Float64(x - Float64(Float64(Float64(y * 2.0) * z) / Float64(Float64(Float64(z * 2.0) * z) - Float64(y * t)))) end
function tmp = code(x, y, z, t) tmp = x - (((y * 2.0) * z) / (((z * 2.0) * z) - (y * t))); end
code[x_, y_, z_, t_] := N[(x - N[(N[(N[(y * 2.0), $MachinePrecision] * z), $MachinePrecision] / N[(N[(N[(z * 2.0), $MachinePrecision] * z), $MachinePrecision] - N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t}
\end{array}
(FPCore (x y z t) :precision binary64 (fma (* y (/ 1.0 (fma -2.0 z (/ y (/ z t))))) 2.0 x))
double code(double x, double y, double z, double t) {
return fma((y * (1.0 / fma(-2.0, z, (y / (z / t))))), 2.0, x);
}
function code(x, y, z, t) return fma(Float64(y * Float64(1.0 / fma(-2.0, z, Float64(y / Float64(z / t))))), 2.0, x) end
code[x_, y_, z_, t_] := N[(N[(y * N[(1.0 / N[(-2.0 * z + N[(y / N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2.0 + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y \cdot \frac{1}{\mathsf{fma}\left(-2, z, \frac{y}{\frac{z}{t}}\right)}, 2, x\right)
\end{array}
Initial program 80.4%
Simplified93.7%
div-inv93.6%
*-commutative93.6%
fma-def93.6%
associate-/l*97.3%
Applied egg-rr97.3%
Final simplification97.3%
(FPCore (x y z t) :precision binary64 (fma (/ y (+ (* -2.0 z) (/ (* y t) z))) 2.0 x))
double code(double x, double y, double z, double t) {
return fma((y / ((-2.0 * z) + ((y * t) / z))), 2.0, x);
}
function code(x, y, z, t) return fma(Float64(y / Float64(Float64(-2.0 * z) + Float64(Float64(y * t) / z))), 2.0, x) end
code[x_, y_, z_, t_] := N[(N[(y / N[(N[(-2.0 * z), $MachinePrecision] + N[(N[(y * t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2.0 + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{y}{-2 \cdot z + \frac{y \cdot t}{z}}, 2, x\right)
\end{array}
Initial program 80.4%
Simplified93.7%
Final simplification93.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- x (/ y z)))
(t_2 (- x (/ (* y 2.0) (/ (- (* z (* z 2.0)) (* y t)) z)))))
(if (<= z -5.5e+154)
t_1
(if (<= z -2.6e-143)
t_2
(if (<= z 1.35e-118)
(- x (* -2.0 (/ z t)))
(if (<= z 2.1e+144) t_2 t_1))))))
double code(double x, double y, double z, double t) {
double t_1 = x - (y / z);
double t_2 = x - ((y * 2.0) / (((z * (z * 2.0)) - (y * t)) / z));
double tmp;
if (z <= -5.5e+154) {
tmp = t_1;
} else if (z <= -2.6e-143) {
tmp = t_2;
} else if (z <= 1.35e-118) {
tmp = x - (-2.0 * (z / t));
} else if (z <= 2.1e+144) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = x - (y / z)
t_2 = x - ((y * 2.0d0) / (((z * (z * 2.0d0)) - (y * t)) / z))
if (z <= (-5.5d+154)) then
tmp = t_1
else if (z <= (-2.6d-143)) then
tmp = t_2
else if (z <= 1.35d-118) then
tmp = x - ((-2.0d0) * (z / t))
else if (z <= 2.1d+144) then
tmp = t_2
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x - (y / z);
double t_2 = x - ((y * 2.0) / (((z * (z * 2.0)) - (y * t)) / z));
double tmp;
if (z <= -5.5e+154) {
tmp = t_1;
} else if (z <= -2.6e-143) {
tmp = t_2;
} else if (z <= 1.35e-118) {
tmp = x - (-2.0 * (z / t));
} else if (z <= 2.1e+144) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x - (y / z) t_2 = x - ((y * 2.0) / (((z * (z * 2.0)) - (y * t)) / z)) tmp = 0 if z <= -5.5e+154: tmp = t_1 elif z <= -2.6e-143: tmp = t_2 elif z <= 1.35e-118: tmp = x - (-2.0 * (z / t)) elif z <= 2.1e+144: tmp = t_2 else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x - Float64(y / z)) t_2 = Float64(x - Float64(Float64(y * 2.0) / Float64(Float64(Float64(z * Float64(z * 2.0)) - Float64(y * t)) / z))) tmp = 0.0 if (z <= -5.5e+154) tmp = t_1; elseif (z <= -2.6e-143) tmp = t_2; elseif (z <= 1.35e-118) tmp = Float64(x - Float64(-2.0 * Float64(z / t))); elseif (z <= 2.1e+144) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x - (y / z); t_2 = x - ((y * 2.0) / (((z * (z * 2.0)) - (y * t)) / z)); tmp = 0.0; if (z <= -5.5e+154) tmp = t_1; elseif (z <= -2.6e-143) tmp = t_2; elseif (z <= 1.35e-118) tmp = x - (-2.0 * (z / t)); elseif (z <= 2.1e+144) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x - N[(y / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x - N[(N[(y * 2.0), $MachinePrecision] / N[(N[(N[(z * N[(z * 2.0), $MachinePrecision]), $MachinePrecision] - N[(y * t), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -5.5e+154], t$95$1, If[LessEqual[z, -2.6e-143], t$95$2, If[LessEqual[z, 1.35e-118], N[(x - N[(-2.0 * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.1e+144], t$95$2, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x - \frac{y}{z}\\
t_2 := x - \frac{y \cdot 2}{\frac{z \cdot \left(z \cdot 2\right) - y \cdot t}{z}}\\
\mathbf{if}\;z \leq -5.5 \cdot 10^{+154}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -2.6 \cdot 10^{-143}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;z \leq 1.35 \cdot 10^{-118}:\\
\;\;\;\;x - -2 \cdot \frac{z}{t}\\
\mathbf{elif}\;z \leq 2.1 \cdot 10^{+144}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if z < -5.5000000000000006e154 or 2.09999999999999996e144 < z Initial program 50.7%
sub-neg50.7%
associate-/l*69.6%
distribute-neg-frac69.6%
distribute-lft-neg-out69.6%
associate-/r/69.6%
distribute-lft-neg-out69.6%
distribute-rgt-neg-in69.6%
metadata-eval69.6%
*-commutative69.6%
associate-*l*69.6%
fma-neg69.6%
Simplified69.6%
Taylor expanded in y around 0 98.7%
mul-1-neg98.7%
sub-neg98.7%
Simplified98.7%
if -5.5000000000000006e154 < z < -2.59999999999999987e-143 or 1.34999999999999997e-118 < z < 2.09999999999999996e144Initial program 90.6%
remove-double-neg90.6%
neg-mul-190.6%
*-commutative90.6%
*-commutative90.6%
neg-mul-190.6%
remove-double-neg90.6%
associate-/l*94.9%
associate-*l*94.9%
Simplified94.9%
if -2.59999999999999987e-143 < z < 1.34999999999999997e-118Initial program 94.3%
remove-double-neg94.3%
neg-mul-194.3%
*-commutative94.3%
*-commutative94.3%
neg-mul-194.3%
remove-double-neg94.3%
associate-/l*90.4%
associate-*l*90.4%
Simplified90.4%
Taylor expanded in y around inf 98.6%
*-commutative98.6%
Simplified98.6%
Final simplification97.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* z (* z 2.0)) (* y t))) (t_2 (- x (/ y z))))
(if (<= z -5.5e+154)
t_2
(if (<= z -2e-145)
(- x (/ (* y 2.0) (/ t_1 z)))
(if (<= z 1.16e-107)
(- x (* -2.0 (/ z t)))
(if (<= z 4.8e+101) (- x (/ (* z (* y 2.0)) t_1)) t_2))))))
double code(double x, double y, double z, double t) {
double t_1 = (z * (z * 2.0)) - (y * t);
double t_2 = x - (y / z);
double tmp;
if (z <= -5.5e+154) {
tmp = t_2;
} else if (z <= -2e-145) {
tmp = x - ((y * 2.0) / (t_1 / z));
} else if (z <= 1.16e-107) {
tmp = x - (-2.0 * (z / t));
} else if (z <= 4.8e+101) {
tmp = x - ((z * (y * 2.0)) / t_1);
} else {
tmp = t_2;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (z * (z * 2.0d0)) - (y * t)
t_2 = x - (y / z)
if (z <= (-5.5d+154)) then
tmp = t_2
else if (z <= (-2d-145)) then
tmp = x - ((y * 2.0d0) / (t_1 / z))
else if (z <= 1.16d-107) then
tmp = x - ((-2.0d0) * (z / t))
else if (z <= 4.8d+101) then
tmp = x - ((z * (y * 2.0d0)) / t_1)
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (z * (z * 2.0)) - (y * t);
double t_2 = x - (y / z);
double tmp;
if (z <= -5.5e+154) {
tmp = t_2;
} else if (z <= -2e-145) {
tmp = x - ((y * 2.0) / (t_1 / z));
} else if (z <= 1.16e-107) {
tmp = x - (-2.0 * (z / t));
} else if (z <= 4.8e+101) {
tmp = x - ((z * (y * 2.0)) / t_1);
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t): t_1 = (z * (z * 2.0)) - (y * t) t_2 = x - (y / z) tmp = 0 if z <= -5.5e+154: tmp = t_2 elif z <= -2e-145: tmp = x - ((y * 2.0) / (t_1 / z)) elif z <= 1.16e-107: tmp = x - (-2.0 * (z / t)) elif z <= 4.8e+101: tmp = x - ((z * (y * 2.0)) / t_1) else: tmp = t_2 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(z * Float64(z * 2.0)) - Float64(y * t)) t_2 = Float64(x - Float64(y / z)) tmp = 0.0 if (z <= -5.5e+154) tmp = t_2; elseif (z <= -2e-145) tmp = Float64(x - Float64(Float64(y * 2.0) / Float64(t_1 / z))); elseif (z <= 1.16e-107) tmp = Float64(x - Float64(-2.0 * Float64(z / t))); elseif (z <= 4.8e+101) tmp = Float64(x - Float64(Float64(z * Float64(y * 2.0)) / t_1)); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (z * (z * 2.0)) - (y * t); t_2 = x - (y / z); tmp = 0.0; if (z <= -5.5e+154) tmp = t_2; elseif (z <= -2e-145) tmp = x - ((y * 2.0) / (t_1 / z)); elseif (z <= 1.16e-107) tmp = x - (-2.0 * (z / t)); elseif (z <= 4.8e+101) tmp = x - ((z * (y * 2.0)) / t_1); else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z * N[(z * 2.0), $MachinePrecision]), $MachinePrecision] - N[(y * t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x - N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -5.5e+154], t$95$2, If[LessEqual[z, -2e-145], N[(x - N[(N[(y * 2.0), $MachinePrecision] / N[(t$95$1 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.16e-107], N[(x - N[(-2.0 * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4.8e+101], N[(x - N[(N[(z * N[(y * 2.0), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \left(z \cdot 2\right) - y \cdot t\\
t_2 := x - \frac{y}{z}\\
\mathbf{if}\;z \leq -5.5 \cdot 10^{+154}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;z \leq -2 \cdot 10^{-145}:\\
\;\;\;\;x - \frac{y \cdot 2}{\frac{t_1}{z}}\\
\mathbf{elif}\;z \leq 1.16 \cdot 10^{-107}:\\
\;\;\;\;x - -2 \cdot \frac{z}{t}\\
\mathbf{elif}\;z \leq 4.8 \cdot 10^{+101}:\\
\;\;\;\;x - \frac{z \cdot \left(y \cdot 2\right)}{t_1}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if z < -5.5000000000000006e154 or 4.79999999999999977e101 < z Initial program 54.2%
sub-neg54.2%
associate-/l*72.7%
distribute-neg-frac72.7%
distribute-lft-neg-out72.7%
associate-/r/72.7%
distribute-lft-neg-out72.7%
distribute-rgt-neg-in72.7%
metadata-eval72.7%
*-commutative72.7%
associate-*l*72.7%
fma-neg72.7%
Simplified72.7%
Taylor expanded in y around 0 96.7%
mul-1-neg96.7%
sub-neg96.7%
Simplified96.7%
if -5.5000000000000006e154 < z < -1.99999999999999983e-145Initial program 87.7%
remove-double-neg87.7%
neg-mul-187.7%
*-commutative87.7%
*-commutative87.7%
neg-mul-187.7%
remove-double-neg87.7%
associate-/l*94.8%
associate-*l*94.8%
Simplified94.8%
if -1.99999999999999983e-145 < z < 1.16e-107Initial program 94.4%
remove-double-neg94.4%
neg-mul-194.4%
*-commutative94.4%
*-commutative94.4%
neg-mul-194.4%
remove-double-neg94.4%
associate-/l*90.5%
associate-*l*90.5%
Simplified90.5%
Taylor expanded in y around inf 98.6%
*-commutative98.6%
Simplified98.6%
if 1.16e-107 < z < 4.79999999999999977e101Initial program 98.0%
Final simplification97.0%
(FPCore (x y z t) :precision binary64 (if (or (<= z -9.5e-41) (not (<= z 9.5e+20))) (- x (/ y z)) (- x (* -2.0 (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -9.5e-41) || !(z <= 9.5e+20)) {
tmp = x - (y / z);
} else {
tmp = x - (-2.0 * (z / t));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((z <= (-9.5d-41)) .or. (.not. (z <= 9.5d+20))) then
tmp = x - (y / z)
else
tmp = x - ((-2.0d0) * (z / t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -9.5e-41) || !(z <= 9.5e+20)) {
tmp = x - (y / z);
} else {
tmp = x - (-2.0 * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -9.5e-41) or not (z <= 9.5e+20): tmp = x - (y / z) else: tmp = x - (-2.0 * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -9.5e-41) || !(z <= 9.5e+20)) tmp = Float64(x - Float64(y / z)); else tmp = Float64(x - Float64(-2.0 * Float64(z / t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -9.5e-41) || ~((z <= 9.5e+20))) tmp = x - (y / z); else tmp = x - (-2.0 * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -9.5e-41], N[Not[LessEqual[z, 9.5e+20]], $MachinePrecision]], N[(x - N[(y / z), $MachinePrecision]), $MachinePrecision], N[(x - N[(-2.0 * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.5 \cdot 10^{-41} \lor \neg \left(z \leq 9.5 \cdot 10^{+20}\right):\\
\;\;\;\;x - \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x - -2 \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -9.4999999999999997e-41 or 9.5e20 < z Initial program 68.1%
sub-neg68.1%
associate-/l*81.7%
distribute-neg-frac81.7%
distribute-lft-neg-out81.7%
associate-/r/81.1%
distribute-lft-neg-out81.1%
distribute-rgt-neg-in81.1%
metadata-eval81.1%
*-commutative81.1%
associate-*l*81.1%
fma-neg81.1%
Simplified81.1%
Taylor expanded in y around 0 92.5%
mul-1-neg92.5%
sub-neg92.5%
Simplified92.5%
if -9.4999999999999997e-41 < z < 9.5e20Initial program 94.3%
remove-double-neg94.3%
neg-mul-194.3%
*-commutative94.3%
*-commutative94.3%
neg-mul-194.3%
remove-double-neg94.3%
associate-/l*92.0%
associate-*l*92.0%
Simplified92.0%
Taylor expanded in y around inf 92.0%
*-commutative92.0%
Simplified92.0%
Final simplification92.2%
(FPCore (x y z t) :precision binary64 (if (or (<= z -3.6e-40) (not (<= z 1e+21))) (- x (/ y z)) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -3.6e-40) || !(z <= 1e+21)) {
tmp = x - (y / z);
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((z <= (-3.6d-40)) .or. (.not. (z <= 1d+21))) then
tmp = x - (y / z)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -3.6e-40) || !(z <= 1e+21)) {
tmp = x - (y / z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -3.6e-40) or not (z <= 1e+21): tmp = x - (y / z) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -3.6e-40) || !(z <= 1e+21)) tmp = Float64(x - Float64(y / z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -3.6e-40) || ~((z <= 1e+21))) tmp = x - (y / z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -3.6e-40], N[Not[LessEqual[z, 1e+21]], $MachinePrecision]], N[(x - N[(y / z), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.6 \cdot 10^{-40} \lor \neg \left(z \leq 10^{+21}\right):\\
\;\;\;\;x - \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -3.6e-40 or 1e21 < z Initial program 68.1%
sub-neg68.1%
associate-/l*81.7%
distribute-neg-frac81.7%
distribute-lft-neg-out81.7%
associate-/r/81.1%
distribute-lft-neg-out81.1%
distribute-rgt-neg-in81.1%
metadata-eval81.1%
*-commutative81.1%
associate-*l*81.1%
fma-neg81.1%
Simplified81.1%
Taylor expanded in y around 0 92.5%
mul-1-neg92.5%
sub-neg92.5%
Simplified92.5%
if -3.6e-40 < z < 1e21Initial program 94.3%
sub-neg94.3%
associate-/l*92.0%
distribute-neg-frac92.0%
distribute-lft-neg-out92.0%
associate-/r/95.1%
distribute-lft-neg-out95.1%
distribute-rgt-neg-in95.1%
metadata-eval95.1%
*-commutative95.1%
associate-*l*95.1%
fma-neg95.1%
Simplified95.1%
Taylor expanded in x around inf 77.6%
Final simplification85.5%
(FPCore (x y z t) :precision binary64 (if (<= t -1.08e-147) x (if (<= t -3.1e-292) (/ (- y) z) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.08e-147) {
tmp = x;
} else if (t <= -3.1e-292) {
tmp = -y / z;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (t <= (-1.08d-147)) then
tmp = x
else if (t <= (-3.1d-292)) then
tmp = -y / z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.08e-147) {
tmp = x;
} else if (t <= -3.1e-292) {
tmp = -y / z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -1.08e-147: tmp = x elif t <= -3.1e-292: tmp = -y / z else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -1.08e-147) tmp = x; elseif (t <= -3.1e-292) tmp = Float64(Float64(-y) / z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -1.08e-147) tmp = x; elseif (t <= -3.1e-292) tmp = -y / z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -1.08e-147], x, If[LessEqual[t, -3.1e-292], N[((-y) / z), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.08 \cdot 10^{-147}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq -3.1 \cdot 10^{-292}:\\
\;\;\;\;\frac{-y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -1.07999999999999995e-147 or -3.0999999999999999e-292 < t Initial program 83.5%
sub-neg83.5%
associate-/l*89.9%
distribute-neg-frac89.9%
distribute-lft-neg-out89.9%
associate-/r/91.1%
distribute-lft-neg-out91.1%
distribute-rgt-neg-in91.1%
metadata-eval91.1%
*-commutative91.1%
associate-*l*91.1%
fma-neg91.1%
Simplified91.1%
Taylor expanded in x around inf 79.9%
if -1.07999999999999995e-147 < t < -3.0999999999999999e-292Initial program 56.1%
Simplified93.3%
Taylor expanded in x around 0 66.4%
Taylor expanded in y around 0 59.6%
mul-1-neg59.6%
distribute-frac-neg59.6%
Simplified59.6%
Final simplification77.6%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 80.4%
sub-neg80.4%
associate-/l*86.5%
distribute-neg-frac86.5%
distribute-lft-neg-out86.5%
associate-/r/87.6%
distribute-lft-neg-out87.6%
distribute-rgt-neg-in87.6%
metadata-eval87.6%
*-commutative87.6%
associate-*l*87.6%
fma-neg87.6%
Simplified87.6%
Taylor expanded in x around inf 74.3%
Final simplification74.3%
(FPCore (x y z t) :precision binary64 (- x (/ 1.0 (- (/ z y) (/ (/ t 2.0) z)))))
double code(double x, double y, double z, double t) {
return x - (1.0 / ((z / y) - ((t / 2.0) / z)));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x - (1.0d0 / ((z / y) - ((t / 2.0d0) / z)))
end function
public static double code(double x, double y, double z, double t) {
return x - (1.0 / ((z / y) - ((t / 2.0) / z)));
}
def code(x, y, z, t): return x - (1.0 / ((z / y) - ((t / 2.0) / z)))
function code(x, y, z, t) return Float64(x - Float64(1.0 / Float64(Float64(z / y) - Float64(Float64(t / 2.0) / z)))) end
function tmp = code(x, y, z, t) tmp = x - (1.0 / ((z / y) - ((t / 2.0) / z))); end
code[x_, y_, z_, t_] := N[(x - N[(1.0 / N[(N[(z / y), $MachinePrecision] - N[(N[(t / 2.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{1}{\frac{z}{y} - \frac{\frac{t}{2}}{z}}
\end{array}
herbie shell --seed 2023333
(FPCore (x y z t)
:name "Numeric.AD.Rank1.Halley:findZero from ad-4.2.4"
:precision binary64
:herbie-target
(- x (/ 1.0 (- (/ z y) (/ (/ t 2.0) z))))
(- x (/ (* (* y 2.0) z) (- (* (* z 2.0) z) (* y t)))))