
(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
(let* ((t_1 (+ x (* (* y 2.0) (/ z (- (* y t) (* z (* z 2.0))))))))
(if (<= z -1e+154)
(- x (/ y z))
(if (<= z -6e-166)
t_1
(if (<= z 1.1e-162)
(- x (/ (* z -2.0) t))
(if (<= z 7.2e+141)
t_1
(- x (/ (- y (* (* t -0.5) (/ (/ y z) (/ z y)))) z))))))))
double code(double x, double y, double z, double t) {
double t_1 = x + ((y * 2.0) * (z / ((y * t) - (z * (z * 2.0)))));
double tmp;
if (z <= -1e+154) {
tmp = x - (y / z);
} else if (z <= -6e-166) {
tmp = t_1;
} else if (z <= 1.1e-162) {
tmp = x - ((z * -2.0) / t);
} else if (z <= 7.2e+141) {
tmp = t_1;
} else {
tmp = x - ((y - ((t * -0.5) * ((y / z) / (z / y)))) / z);
}
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) :: tmp
t_1 = x + ((y * 2.0d0) * (z / ((y * t) - (z * (z * 2.0d0)))))
if (z <= (-1d+154)) then
tmp = x - (y / z)
else if (z <= (-6d-166)) then
tmp = t_1
else if (z <= 1.1d-162) then
tmp = x - ((z * (-2.0d0)) / t)
else if (z <= 7.2d+141) then
tmp = t_1
else
tmp = x - ((y - ((t * (-0.5d0)) * ((y / z) / (z / y)))) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x + ((y * 2.0) * (z / ((y * t) - (z * (z * 2.0)))));
double tmp;
if (z <= -1e+154) {
tmp = x - (y / z);
} else if (z <= -6e-166) {
tmp = t_1;
} else if (z <= 1.1e-162) {
tmp = x - ((z * -2.0) / t);
} else if (z <= 7.2e+141) {
tmp = t_1;
} else {
tmp = x - ((y - ((t * -0.5) * ((y / z) / (z / y)))) / z);
}
return tmp;
}
def code(x, y, z, t): t_1 = x + ((y * 2.0) * (z / ((y * t) - (z * (z * 2.0))))) tmp = 0 if z <= -1e+154: tmp = x - (y / z) elif z <= -6e-166: tmp = t_1 elif z <= 1.1e-162: tmp = x - ((z * -2.0) / t) elif z <= 7.2e+141: tmp = t_1 else: tmp = x - ((y - ((t * -0.5) * ((y / z) / (z / y)))) / z) return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(Float64(y * 2.0) * Float64(z / Float64(Float64(y * t) - Float64(z * Float64(z * 2.0)))))) tmp = 0.0 if (z <= -1e+154) tmp = Float64(x - Float64(y / z)); elseif (z <= -6e-166) tmp = t_1; elseif (z <= 1.1e-162) tmp = Float64(x - Float64(Float64(z * -2.0) / t)); elseif (z <= 7.2e+141) tmp = t_1; else tmp = Float64(x - Float64(Float64(y - Float64(Float64(t * -0.5) * Float64(Float64(y / z) / Float64(z / y)))) / z)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + ((y * 2.0) * (z / ((y * t) - (z * (z * 2.0))))); tmp = 0.0; if (z <= -1e+154) tmp = x - (y / z); elseif (z <= -6e-166) tmp = t_1; elseif (z <= 1.1e-162) tmp = x - ((z * -2.0) / t); elseif (z <= 7.2e+141) tmp = t_1; else tmp = x - ((y - ((t * -0.5) * ((y / z) / (z / y)))) / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(N[(y * 2.0), $MachinePrecision] * N[(z / N[(N[(y * t), $MachinePrecision] - N[(z * N[(z * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1e+154], N[(x - N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -6e-166], t$95$1, If[LessEqual[z, 1.1e-162], N[(x - N[(N[(z * -2.0), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 7.2e+141], t$95$1, N[(x - N[(N[(y - N[(N[(t * -0.5), $MachinePrecision] * N[(N[(y / z), $MachinePrecision] / N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \left(y \cdot 2\right) \cdot \frac{z}{y \cdot t - z \cdot \left(z \cdot 2\right)}\\
\mathbf{if}\;z \leq -1 \cdot 10^{+154}:\\
\;\;\;\;x - \frac{y}{z}\\
\mathbf{elif}\;z \leq -6 \cdot 10^{-166}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.1 \cdot 10^{-162}:\\
\;\;\;\;x - \frac{z \cdot -2}{t}\\
\mathbf{elif}\;z \leq 7.2 \cdot 10^{+141}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y - \left(t \cdot -0.5\right) \cdot \frac{\frac{y}{z}}{\frac{z}{y}}}{z}\\
\end{array}
\end{array}
if z < -1.00000000000000004e154Initial program 60.0%
Simplified82.9%
Taylor expanded in y around 0 100.0%
if -1.00000000000000004e154 < z < -6.0000000000000005e-166 or 1.1e-162 < z < 7.2000000000000003e141Initial program 87.4%
Simplified94.0%
if -6.0000000000000005e-166 < z < 1.1e-162Initial program 76.5%
Simplified69.9%
Taylor expanded in y around inf 98.2%
associate-*r/98.2%
*-commutative98.2%
Simplified98.2%
if 7.2000000000000003e141 < z Initial program 61.6%
Simplified75.1%
clear-num75.1%
un-div-inv75.1%
*-commutative75.1%
*-commutative75.1%
associate-*l*75.1%
pow275.1%
Applied egg-rr75.1%
associate-/r/75.1%
*-commutative75.1%
*-commutative75.1%
*-commutative75.1%
Simplified75.1%
Taylor expanded in z around -inf 77.4%
mul-1-neg77.4%
neg-mul-177.4%
distribute-neg-frac277.4%
Simplified96.9%
clear-num96.9%
pow296.9%
un-div-inv96.9%
clear-num96.9%
Applied egg-rr96.9%
Final simplification96.0%
(FPCore (x y z t)
:precision binary64
(if (<= z -6e-166)
(fma y (* z (/ 2.0 (fma z (* z -2.0) (* y t)))) x)
(if (<= z 2.1e-138)
(- x (/ (* z -2.0) t))
(if (<= z 5.8e+141)
(+ x (* z (/ (* y 2.0) (- (* y t) (* 2.0 (pow z 2.0))))))
(- x (/ (- y (* (* t -0.5) (/ (/ y z) (/ z y)))) z))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -6e-166) {
tmp = fma(y, (z * (2.0 / fma(z, (z * -2.0), (y * t)))), x);
} else if (z <= 2.1e-138) {
tmp = x - ((z * -2.0) / t);
} else if (z <= 5.8e+141) {
tmp = x + (z * ((y * 2.0) / ((y * t) - (2.0 * pow(z, 2.0)))));
} else {
tmp = x - ((y - ((t * -0.5) * ((y / z) / (z / y)))) / z);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= -6e-166) tmp = fma(y, Float64(z * Float64(2.0 / fma(z, Float64(z * -2.0), Float64(y * t)))), x); elseif (z <= 2.1e-138) tmp = Float64(x - Float64(Float64(z * -2.0) / t)); elseif (z <= 5.8e+141) tmp = Float64(x + Float64(z * Float64(Float64(y * 2.0) / Float64(Float64(y * t) - Float64(2.0 * (z ^ 2.0)))))); else tmp = Float64(x - Float64(Float64(y - Float64(Float64(t * -0.5) * Float64(Float64(y / z) / Float64(z / y)))) / z)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -6e-166], N[(y * N[(z * N[(2.0 / N[(z * N[(z * -2.0), $MachinePrecision] + N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 2.1e-138], N[(x - N[(N[(z * -2.0), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.8e+141], N[(x + N[(z * N[(N[(y * 2.0), $MachinePrecision] / N[(N[(y * t), $MachinePrecision] - N[(2.0 * N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(y - N[(N[(t * -0.5), $MachinePrecision] * N[(N[(y / z), $MachinePrecision] / N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6 \cdot 10^{-166}:\\
\;\;\;\;\mathsf{fma}\left(y, z \cdot \frac{2}{\mathsf{fma}\left(z, z \cdot -2, y \cdot t\right)}, x\right)\\
\mathbf{elif}\;z \leq 2.1 \cdot 10^{-138}:\\
\;\;\;\;x - \frac{z \cdot -2}{t}\\
\mathbf{elif}\;z \leq 5.8 \cdot 10^{+141}:\\
\;\;\;\;x + z \cdot \frac{y \cdot 2}{y \cdot t - 2 \cdot {z}^{2}}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y - \left(t \cdot -0.5\right) \cdot \frac{\frac{y}{z}}{\frac{z}{y}}}{z}\\
\end{array}
\end{array}
if z < -6.0000000000000005e-166Initial program 75.2%
Simplified90.1%
if -6.0000000000000005e-166 < z < 2.09999999999999986e-138Initial program 78.5%
Simplified72.6%
Taylor expanded in y around inf 98.3%
associate-*r/98.3%
*-commutative98.3%
Simplified98.3%
if 2.09999999999999986e-138 < z < 5.80000000000000013e141Initial program 94.5%
Simplified99.8%
clear-num99.8%
un-div-inv99.8%
*-commutative99.8%
*-commutative99.8%
associate-*l*99.8%
pow299.8%
Applied egg-rr99.8%
associate-/r/99.8%
*-commutative99.8%
*-commutative99.8%
*-commutative99.8%
Simplified99.8%
if 5.80000000000000013e141 < z Initial program 61.6%
Simplified75.1%
clear-num75.1%
un-div-inv75.1%
*-commutative75.1%
*-commutative75.1%
associate-*l*75.1%
pow275.1%
Applied egg-rr75.1%
associate-/r/75.1%
*-commutative75.1%
*-commutative75.1%
*-commutative75.1%
Simplified75.1%
Taylor expanded in z around -inf 77.4%
mul-1-neg77.4%
neg-mul-177.4%
distribute-neg-frac277.4%
Simplified96.9%
clear-num96.9%
pow296.9%
un-div-inv96.9%
clear-num96.9%
Applied egg-rr96.9%
Final simplification94.8%
(FPCore (x y z t) :precision binary64 (if (<= (+ x (/ (* z (* y 2.0)) (- (* y t) (* z (* z 2.0))))) 2e+264) (+ x (* z (/ (* y 2.0) (- (* y t) (* 2.0 (pow z 2.0)))))) (- x (/ y z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x + ((z * (y * 2.0)) / ((y * t) - (z * (z * 2.0))))) <= 2e+264) {
tmp = x + (z * ((y * 2.0) / ((y * t) - (2.0 * pow(z, 2.0)))));
} else {
tmp = x - (y / z);
}
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 ((x + ((z * (y * 2.0d0)) / ((y * t) - (z * (z * 2.0d0))))) <= 2d+264) then
tmp = x + (z * ((y * 2.0d0) / ((y * t) - (2.0d0 * (z ** 2.0d0)))))
else
tmp = x - (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x + ((z * (y * 2.0)) / ((y * t) - (z * (z * 2.0))))) <= 2e+264) {
tmp = x + (z * ((y * 2.0) / ((y * t) - (2.0 * Math.pow(z, 2.0)))));
} else {
tmp = x - (y / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x + ((z * (y * 2.0)) / ((y * t) - (z * (z * 2.0))))) <= 2e+264: tmp = x + (z * ((y * 2.0) / ((y * t) - (2.0 * math.pow(z, 2.0))))) else: tmp = x - (y / z) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x + Float64(Float64(z * Float64(y * 2.0)) / Float64(Float64(y * t) - Float64(z * Float64(z * 2.0))))) <= 2e+264) tmp = Float64(x + Float64(z * Float64(Float64(y * 2.0) / Float64(Float64(y * t) - Float64(2.0 * (z ^ 2.0)))))); else tmp = Float64(x - Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x + ((z * (y * 2.0)) / ((y * t) - (z * (z * 2.0))))) <= 2e+264) tmp = x + (z * ((y * 2.0) / ((y * t) - (2.0 * (z ^ 2.0))))); else tmp = x - (y / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x + N[(N[(z * N[(y * 2.0), $MachinePrecision]), $MachinePrecision] / N[(N[(y * t), $MachinePrecision] - N[(z * N[(z * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+264], N[(x + N[(z * N[(N[(y * 2.0), $MachinePrecision] / N[(N[(y * t), $MachinePrecision] - N[(2.0 * N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(y / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + \frac{z \cdot \left(y \cdot 2\right)}{y \cdot t - z \cdot \left(z \cdot 2\right)} \leq 2 \cdot 10^{+264}:\\
\;\;\;\;x + z \cdot \frac{y \cdot 2}{y \cdot t - 2 \cdot {z}^{2}}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{z}\\
\end{array}
\end{array}
if (-.f64 x (/.f64 (*.f64 (*.f64 y #s(literal 2 binary64)) z) (-.f64 (*.f64 (*.f64 z #s(literal 2 binary64)) z) (*.f64 y t)))) < 2.00000000000000009e264Initial program 92.1%
Simplified92.4%
clear-num92.1%
un-div-inv92.1%
*-commutative92.1%
*-commutative92.1%
associate-*l*92.1%
pow292.1%
Applied egg-rr92.1%
associate-/r/94.8%
*-commutative94.8%
*-commutative94.8%
*-commutative94.8%
Simplified94.8%
if 2.00000000000000009e264 < (-.f64 x (/.f64 (*.f64 (*.f64 y #s(literal 2 binary64)) z) (-.f64 (*.f64 (*.f64 z #s(literal 2 binary64)) z) (*.f64 y t)))) Initial program 17.4%
Simplified54.2%
Taylor expanded in y around 0 77.4%
Final simplification91.6%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- x (/ y z)))
(t_2 (+ x (* (* y 2.0) (/ z (- (* y t) (* z (* z 2.0))))))))
(if (<= z -1e+154)
t_1
(if (<= z -6e-166)
t_2
(if (<= z 1e-162)
(- x (/ (* z -2.0) t))
(if (<= z 8.5e+138) 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 / ((y * t) - (z * (z * 2.0)))));
double tmp;
if (z <= -1e+154) {
tmp = t_1;
} else if (z <= -6e-166) {
tmp = t_2;
} else if (z <= 1e-162) {
tmp = x - ((z * -2.0) / t);
} else if (z <= 8.5e+138) {
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 / ((y * t) - (z * (z * 2.0d0)))))
if (z <= (-1d+154)) then
tmp = t_1
else if (z <= (-6d-166)) then
tmp = t_2
else if (z <= 1d-162) then
tmp = x - ((z * (-2.0d0)) / t)
else if (z <= 8.5d+138) 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 / ((y * t) - (z * (z * 2.0)))));
double tmp;
if (z <= -1e+154) {
tmp = t_1;
} else if (z <= -6e-166) {
tmp = t_2;
} else if (z <= 1e-162) {
tmp = x - ((z * -2.0) / t);
} else if (z <= 8.5e+138) {
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 / ((y * t) - (z * (z * 2.0))))) tmp = 0 if z <= -1e+154: tmp = t_1 elif z <= -6e-166: tmp = t_2 elif z <= 1e-162: tmp = x - ((z * -2.0) / t) elif z <= 8.5e+138: 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(z / Float64(Float64(y * t) - Float64(z * Float64(z * 2.0)))))) tmp = 0.0 if (z <= -1e+154) tmp = t_1; elseif (z <= -6e-166) tmp = t_2; elseif (z <= 1e-162) tmp = Float64(x - Float64(Float64(z * -2.0) / t)); elseif (z <= 8.5e+138) 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 / ((y * t) - (z * (z * 2.0))))); tmp = 0.0; if (z <= -1e+154) tmp = t_1; elseif (z <= -6e-166) tmp = t_2; elseif (z <= 1e-162) tmp = x - ((z * -2.0) / t); elseif (z <= 8.5e+138) 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[(z / N[(N[(y * t), $MachinePrecision] - N[(z * N[(z * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1e+154], t$95$1, If[LessEqual[z, -6e-166], t$95$2, If[LessEqual[z, 1e-162], N[(x - N[(N[(z * -2.0), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 8.5e+138], t$95$2, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x - \frac{y}{z}\\
t_2 := x + \left(y \cdot 2\right) \cdot \frac{z}{y \cdot t - z \cdot \left(z \cdot 2\right)}\\
\mathbf{if}\;z \leq -1 \cdot 10^{+154}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -6 \cdot 10^{-166}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;z \leq 10^{-162}:\\
\;\;\;\;x - \frac{z \cdot -2}{t}\\
\mathbf{elif}\;z \leq 8.5 \cdot 10^{+138}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.00000000000000004e154 or 8.5000000000000006e138 < z Initial program 60.8%
Simplified79.2%
Taylor expanded in y around 0 98.4%
if -1.00000000000000004e154 < z < -6.0000000000000005e-166 or 9.99999999999999954e-163 < z < 8.5000000000000006e138Initial program 87.4%
Simplified94.0%
if -6.0000000000000005e-166 < z < 9.99999999999999954e-163Initial program 76.5%
Simplified69.9%
Taylor expanded in y around inf 98.2%
associate-*r/98.2%
*-commutative98.2%
Simplified98.2%
Final simplification95.9%
(FPCore (x y z t) :precision binary64 (if (<= x -4.6e-215) x (if (<= x 1.36e-232) (* 2.0 (/ z t)) (if (<= x 2.2e-133) (- x (/ y z)) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -4.6e-215) {
tmp = x;
} else if (x <= 1.36e-232) {
tmp = 2.0 * (z / t);
} else if (x <= 2.2e-133) {
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 (x <= (-4.6d-215)) then
tmp = x
else if (x <= 1.36d-232) then
tmp = 2.0d0 * (z / t)
else if (x <= 2.2d-133) 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 (x <= -4.6e-215) {
tmp = x;
} else if (x <= 1.36e-232) {
tmp = 2.0 * (z / t);
} else if (x <= 2.2e-133) {
tmp = x - (y / z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -4.6e-215: tmp = x elif x <= 1.36e-232: tmp = 2.0 * (z / t) elif x <= 2.2e-133: tmp = x - (y / z) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -4.6e-215) tmp = x; elseif (x <= 1.36e-232) tmp = Float64(2.0 * Float64(z / t)); elseif (x <= 2.2e-133) 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 (x <= -4.6e-215) tmp = x; elseif (x <= 1.36e-232) tmp = 2.0 * (z / t); elseif (x <= 2.2e-133) tmp = x - (y / z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -4.6e-215], x, If[LessEqual[x, 1.36e-232], N[(2.0 * N[(z / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.2e-133], N[(x - N[(y / z), $MachinePrecision]), $MachinePrecision], x]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.6 \cdot 10^{-215}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.36 \cdot 10^{-232}:\\
\;\;\;\;2 \cdot \frac{z}{t}\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{-133}:\\
\;\;\;\;x - \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -4.5999999999999998e-215 or 2.2000000000000001e-133 < x Initial program 81.6%
Simplified91.6%
Taylor expanded in x around inf 85.8%
if -4.5999999999999998e-215 < x < 1.3600000000000001e-232Initial program 67.4%
Simplified66.7%
Taylor expanded in y around inf 74.0%
associate-*r/74.0%
*-commutative74.0%
Simplified74.0%
Taylor expanded in x around 0 59.8%
if 1.3600000000000001e-232 < x < 2.2000000000000001e-133Initial program 72.4%
Simplified69.6%
Taylor expanded in y around 0 67.7%
(FPCore (x y z t) :precision binary64 (if (<= x -6.6e-211) x (if (<= x 3e-232) (* 2.0 (/ z t)) (if (<= x 2.25e-207) (/ (- y) z) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -6.6e-211) {
tmp = x;
} else if (x <= 3e-232) {
tmp = 2.0 * (z / t);
} else if (x <= 2.25e-207) {
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 (x <= (-6.6d-211)) then
tmp = x
else if (x <= 3d-232) then
tmp = 2.0d0 * (z / t)
else if (x <= 2.25d-207) 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 (x <= -6.6e-211) {
tmp = x;
} else if (x <= 3e-232) {
tmp = 2.0 * (z / t);
} else if (x <= 2.25e-207) {
tmp = -y / z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -6.6e-211: tmp = x elif x <= 3e-232: tmp = 2.0 * (z / t) elif x <= 2.25e-207: tmp = -y / z else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -6.6e-211) tmp = x; elseif (x <= 3e-232) tmp = Float64(2.0 * Float64(z / t)); elseif (x <= 2.25e-207) tmp = Float64(Float64(-y) / z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -6.6e-211) tmp = x; elseif (x <= 3e-232) tmp = 2.0 * (z / t); elseif (x <= 2.25e-207) tmp = -y / z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -6.6e-211], x, If[LessEqual[x, 3e-232], N[(2.0 * N[(z / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.25e-207], N[((-y) / z), $MachinePrecision], x]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.6 \cdot 10^{-211}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 3 \cdot 10^{-232}:\\
\;\;\;\;2 \cdot \frac{z}{t}\\
\mathbf{elif}\;x \leq 2.25 \cdot 10^{-207}:\\
\;\;\;\;\frac{-y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -6.6000000000000004e-211 or 2.24999999999999996e-207 < x Initial program 81.2%
Simplified90.0%
Taylor expanded in x around inf 82.4%
if -6.6000000000000004e-211 < x < 2.9999999999999999e-232Initial program 67.4%
Simplified66.7%
Taylor expanded in y around inf 74.0%
associate-*r/74.0%
*-commutative74.0%
Simplified74.0%
Taylor expanded in x around 0 59.8%
if 2.9999999999999999e-232 < x < 2.24999999999999996e-207Initial program 63.1%
Simplified63.1%
Taylor expanded in y around 0 96.4%
Taylor expanded in x around 0 83.8%
mul-1-neg83.8%
distribute-frac-neg283.8%
Simplified83.8%
Final simplification78.8%
(FPCore (x y z t) :precision binary64 (if (or (<= z -5.8e+14) (not (<= z 5.2e+86))) (- x (/ y z)) (- x (/ (* z -2.0) t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -5.8e+14) || !(z <= 5.2e+86)) {
tmp = x - (y / z);
} else {
tmp = x - ((z * -2.0) / 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 <= (-5.8d+14)) .or. (.not. (z <= 5.2d+86))) then
tmp = x - (y / z)
else
tmp = x - ((z * (-2.0d0)) / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -5.8e+14) || !(z <= 5.2e+86)) {
tmp = x - (y / z);
} else {
tmp = x - ((z * -2.0) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -5.8e+14) or not (z <= 5.2e+86): tmp = x - (y / z) else: tmp = x - ((z * -2.0) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -5.8e+14) || !(z <= 5.2e+86)) tmp = Float64(x - Float64(y / z)); else tmp = Float64(x - Float64(Float64(z * -2.0) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -5.8e+14) || ~((z <= 5.2e+86))) tmp = x - (y / z); else tmp = x - ((z * -2.0) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -5.8e+14], N[Not[LessEqual[z, 5.2e+86]], $MachinePrecision]], N[(x - N[(y / z), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(z * -2.0), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.8 \cdot 10^{+14} \lor \neg \left(z \leq 5.2 \cdot 10^{+86}\right):\\
\;\;\;\;x - \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{z \cdot -2}{t}\\
\end{array}
\end{array}
if z < -5.8e14 or 5.1999999999999995e86 < z Initial program 66.1%
Simplified83.2%
Taylor expanded in y around 0 91.9%
if -5.8e14 < z < 5.1999999999999995e86Initial program 86.9%
Simplified86.9%
Taylor expanded in y around inf 88.9%
associate-*r/88.9%
*-commutative88.9%
Simplified88.9%
Final simplification90.1%
(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 78.3%
Simplified85.4%
Taylor expanded in x around inf 70.9%
(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 2024106
(FPCore (x y z t)
:name "Numeric.AD.Rank1.Halley:findZero from ad-4.2.4"
:precision binary64
:alt
(- x (/ 1.0 (- (/ z y) (/ (/ t 2.0) z))))
(- x (/ (* (* y 2.0) z) (- (* (* z 2.0) z) (* y t)))))