
(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 (if (<= (+ x (/ (* (* y 2.0) z) (- (* y t) (* z (* 2.0 z))))) 1.5e+263) (fma y (* z (/ 2.0 (fma z (* z -2.0) (* y t)))) x) (- x (/ y z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x + (((y * 2.0) * z) / ((y * t) - (z * (2.0 * z))))) <= 1.5e+263) {
tmp = fma(y, (z * (2.0 / fma(z, (z * -2.0), (y * t)))), x);
} else {
tmp = x - (y / z);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(x + Float64(Float64(Float64(y * 2.0) * z) / Float64(Float64(y * t) - Float64(z * Float64(2.0 * z))))) <= 1.5e+263) tmp = fma(y, Float64(z * Float64(2.0 / fma(z, Float64(z * -2.0), Float64(y * t)))), x); else tmp = Float64(x - Float64(y / z)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(x + N[(N[(N[(y * 2.0), $MachinePrecision] * z), $MachinePrecision] / N[(N[(y * t), $MachinePrecision] - N[(z * N[(2.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.5e+263], N[(y * N[(z * N[(2.0 / N[(z * N[(z * -2.0), $MachinePrecision] + N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(x - N[(y / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + \frac{\left(y \cdot 2\right) \cdot z}{y \cdot t - z \cdot \left(2 \cdot z\right)} \leq 1.5 \cdot 10^{+263}:\\
\;\;\;\;\mathsf{fma}\left(y, z \cdot \frac{2}{\mathsf{fma}\left(z, z \cdot -2, y \cdot t\right)}, x\right)\\
\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)))) < 1.49999999999999995e263Initial program 95.2%
Simplified97.3%
if 1.49999999999999995e263 < (-.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 16.5%
Simplified41.9%
Taylor expanded in y around 0 82.0%
Final simplification94.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* y t) (* z (* 2.0 z)))))
(if (<= (+ x (/ (* (* y 2.0) z) t_1)) 1.5e+263)
(+ x (* (* y 2.0) (/ z t_1)))
(- x (/ y z)))))
double code(double x, double y, double z, double t) {
double t_1 = (y * t) - (z * (2.0 * z));
double tmp;
if ((x + (((y * 2.0) * z) / t_1)) <= 1.5e+263) {
tmp = x + ((y * 2.0) * (z / t_1));
} 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) :: t_1
real(8) :: tmp
t_1 = (y * t) - (z * (2.0d0 * z))
if ((x + (((y * 2.0d0) * z) / t_1)) <= 1.5d+263) then
tmp = x + ((y * 2.0d0) * (z / t_1))
else
tmp = x - (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (y * t) - (z * (2.0 * z));
double tmp;
if ((x + (((y * 2.0) * z) / t_1)) <= 1.5e+263) {
tmp = x + ((y * 2.0) * (z / t_1));
} else {
tmp = x - (y / z);
}
return tmp;
}
def code(x, y, z, t): t_1 = (y * t) - (z * (2.0 * z)) tmp = 0 if (x + (((y * 2.0) * z) / t_1)) <= 1.5e+263: tmp = x + ((y * 2.0) * (z / t_1)) else: tmp = x - (y / z) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(y * t) - Float64(z * Float64(2.0 * z))) tmp = 0.0 if (Float64(x + Float64(Float64(Float64(y * 2.0) * z) / t_1)) <= 1.5e+263) tmp = Float64(x + Float64(Float64(y * 2.0) * Float64(z / t_1))); else tmp = Float64(x - Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (y * t) - (z * (2.0 * z)); tmp = 0.0; if ((x + (((y * 2.0) * z) / t_1)) <= 1.5e+263) tmp = x + ((y * 2.0) * (z / t_1)); else tmp = x - (y / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y * t), $MachinePrecision] - N[(z * N[(2.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x + N[(N[(N[(y * 2.0), $MachinePrecision] * z), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], 1.5e+263], N[(x + N[(N[(y * 2.0), $MachinePrecision] * N[(z / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(y / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot t - z \cdot \left(2 \cdot z\right)\\
\mathbf{if}\;x + \frac{\left(y \cdot 2\right) \cdot z}{t\_1} \leq 1.5 \cdot 10^{+263}:\\
\;\;\;\;x + \left(y \cdot 2\right) \cdot \frac{z}{t\_1}\\
\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)))) < 1.49999999999999995e263Initial program 95.2%
Simplified97.3%
if 1.49999999999999995e263 < (-.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 16.5%
Simplified41.9%
Taylor expanded in y around 0 82.0%
Final simplification94.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- x (/ y z))))
(if (<= z -1.25)
t_1
(if (<= z 9.5e-199)
x
(if (<= z 1.2e-139) (* 2.0 (/ z t)) (if (<= z 25.0) x t_1))))))
double code(double x, double y, double z, double t) {
double t_1 = x - (y / z);
double tmp;
if (z <= -1.25) {
tmp = t_1;
} else if (z <= 9.5e-199) {
tmp = x;
} else if (z <= 1.2e-139) {
tmp = 2.0 * (z / t);
} else if (z <= 25.0) {
tmp = x;
} 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) :: tmp
t_1 = x - (y / z)
if (z <= (-1.25d0)) then
tmp = t_1
else if (z <= 9.5d-199) then
tmp = x
else if (z <= 1.2d-139) then
tmp = 2.0d0 * (z / t)
else if (z <= 25.0d0) then
tmp = x
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 tmp;
if (z <= -1.25) {
tmp = t_1;
} else if (z <= 9.5e-199) {
tmp = x;
} else if (z <= 1.2e-139) {
tmp = 2.0 * (z / t);
} else if (z <= 25.0) {
tmp = x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x - (y / z) tmp = 0 if z <= -1.25: tmp = t_1 elif z <= 9.5e-199: tmp = x elif z <= 1.2e-139: tmp = 2.0 * (z / t) elif z <= 25.0: tmp = x else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x - Float64(y / z)) tmp = 0.0 if (z <= -1.25) tmp = t_1; elseif (z <= 9.5e-199) tmp = x; elseif (z <= 1.2e-139) tmp = Float64(2.0 * Float64(z / t)); elseif (z <= 25.0) tmp = x; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x - (y / z); tmp = 0.0; if (z <= -1.25) tmp = t_1; elseif (z <= 9.5e-199) tmp = x; elseif (z <= 1.2e-139) tmp = 2.0 * (z / t); elseif (z <= 25.0) tmp = x; 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]}, If[LessEqual[z, -1.25], t$95$1, If[LessEqual[z, 9.5e-199], x, If[LessEqual[z, 1.2e-139], N[(2.0 * N[(z / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 25.0], x, t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x - \frac{y}{z}\\
\mathbf{if}\;z \leq -1.25:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 9.5 \cdot 10^{-199}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.2 \cdot 10^{-139}:\\
\;\;\;\;2 \cdot \frac{z}{t}\\
\mathbf{elif}\;z \leq 25:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.25 or 25 < z Initial program 77.5%
Simplified87.2%
Taylor expanded in y around 0 91.4%
if -1.25 < z < 9.5000000000000005e-199 or 1.20000000000000007e-139 < z < 25Initial program 90.3%
Simplified90.4%
Taylor expanded in x around inf 80.8%
if 9.5000000000000005e-199 < z < 1.20000000000000007e-139Initial program 64.0%
Simplified98.9%
Taylor expanded in y around inf 88.0%
associate-*r/88.0%
*-commutative88.0%
Simplified88.0%
Taylor expanded in x around 0 75.8%
Final simplification85.3%
(FPCore (x y z t)
:precision binary64
(if (<= z -0.07)
(+ x (/ -1.0 (/ z y)))
(if (<= z 1e-198)
x
(if (<= z 1.2e-139) (* 2.0 (/ z t)) (if (<= z 3800.0) x (- x (/ y z)))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -0.07) {
tmp = x + (-1.0 / (z / y));
} else if (z <= 1e-198) {
tmp = x;
} else if (z <= 1.2e-139) {
tmp = 2.0 * (z / t);
} else if (z <= 3800.0) {
tmp = x;
} 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 (z <= (-0.07d0)) then
tmp = x + ((-1.0d0) / (z / y))
else if (z <= 1d-198) then
tmp = x
else if (z <= 1.2d-139) then
tmp = 2.0d0 * (z / t)
else if (z <= 3800.0d0) then
tmp = x
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 (z <= -0.07) {
tmp = x + (-1.0 / (z / y));
} else if (z <= 1e-198) {
tmp = x;
} else if (z <= 1.2e-139) {
tmp = 2.0 * (z / t);
} else if (z <= 3800.0) {
tmp = x;
} else {
tmp = x - (y / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -0.07: tmp = x + (-1.0 / (z / y)) elif z <= 1e-198: tmp = x elif z <= 1.2e-139: tmp = 2.0 * (z / t) elif z <= 3800.0: tmp = x else: tmp = x - (y / z) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -0.07) tmp = Float64(x + Float64(-1.0 / Float64(z / y))); elseif (z <= 1e-198) tmp = x; elseif (z <= 1.2e-139) tmp = Float64(2.0 * Float64(z / t)); elseif (z <= 3800.0) tmp = x; else tmp = Float64(x - Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -0.07) tmp = x + (-1.0 / (z / y)); elseif (z <= 1e-198) tmp = x; elseif (z <= 1.2e-139) tmp = 2.0 * (z / t); elseif (z <= 3800.0) tmp = x; else tmp = x - (y / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -0.07], N[(x + N[(-1.0 / N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1e-198], x, If[LessEqual[z, 1.2e-139], N[(2.0 * N[(z / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3800.0], x, N[(x - N[(y / z), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.07:\\
\;\;\;\;x + \frac{-1}{\frac{z}{y}}\\
\mathbf{elif}\;z \leq 10^{-198}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.2 \cdot 10^{-139}:\\
\;\;\;\;2 \cdot \frac{z}{t}\\
\mathbf{elif}\;z \leq 3800:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{z}\\
\end{array}
\end{array}
if z < -0.070000000000000007Initial program 76.4%
Simplified88.6%
Taylor expanded in z around inf 90.1%
associate-*l*90.1%
div-inv90.1%
associate-*r*90.1%
metadata-eval90.1%
*-un-lft-identity90.1%
div-inv90.2%
clear-num90.3%
Applied egg-rr90.3%
if -0.070000000000000007 < z < 9.9999999999999991e-199 or 1.20000000000000007e-139 < z < 3800Initial program 90.3%
Simplified90.4%
Taylor expanded in x around inf 80.8%
if 9.9999999999999991e-199 < z < 1.20000000000000007e-139Initial program 64.0%
Simplified98.9%
Taylor expanded in y around inf 88.0%
associate-*r/88.0%
*-commutative88.0%
Simplified88.0%
Taylor expanded in x around 0 75.8%
if 3800 < z Initial program 78.3%
Simplified86.2%
Taylor expanded in y around 0 92.3%
Final simplification85.3%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ y (- z))))
(if (<= x -7.8e-173)
x
(if (<= x 4e-291)
t_1
(if (<= x 7e-202) (* 2.0 (/ z t)) (if (<= x 2.3e-176) t_1 x))))))
double code(double x, double y, double z, double t) {
double t_1 = y / -z;
double tmp;
if (x <= -7.8e-173) {
tmp = x;
} else if (x <= 4e-291) {
tmp = t_1;
} else if (x <= 7e-202) {
tmp = 2.0 * (z / t);
} else if (x <= 2.3e-176) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_1 = y / -z
if (x <= (-7.8d-173)) then
tmp = x
else if (x <= 4d-291) then
tmp = t_1
else if (x <= 7d-202) then
tmp = 2.0d0 * (z / t)
else if (x <= 2.3d-176) then
tmp = t_1
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = y / -z;
double tmp;
if (x <= -7.8e-173) {
tmp = x;
} else if (x <= 4e-291) {
tmp = t_1;
} else if (x <= 7e-202) {
tmp = 2.0 * (z / t);
} else if (x <= 2.3e-176) {
tmp = t_1;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): t_1 = y / -z tmp = 0 if x <= -7.8e-173: tmp = x elif x <= 4e-291: tmp = t_1 elif x <= 7e-202: tmp = 2.0 * (z / t) elif x <= 2.3e-176: tmp = t_1 else: tmp = x return tmp
function code(x, y, z, t) t_1 = Float64(y / Float64(-z)) tmp = 0.0 if (x <= -7.8e-173) tmp = x; elseif (x <= 4e-291) tmp = t_1; elseif (x <= 7e-202) tmp = Float64(2.0 * Float64(z / t)); elseif (x <= 2.3e-176) tmp = t_1; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = y / -z; tmp = 0.0; if (x <= -7.8e-173) tmp = x; elseif (x <= 4e-291) tmp = t_1; elseif (x <= 7e-202) tmp = 2.0 * (z / t); elseif (x <= 2.3e-176) tmp = t_1; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y / (-z)), $MachinePrecision]}, If[LessEqual[x, -7.8e-173], x, If[LessEqual[x, 4e-291], t$95$1, If[LessEqual[x, 7e-202], N[(2.0 * N[(z / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.3e-176], t$95$1, x]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y}{-z}\\
\mathbf{if}\;x \leq -7.8 \cdot 10^{-173}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 4 \cdot 10^{-291}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 7 \cdot 10^{-202}:\\
\;\;\;\;2 \cdot \frac{z}{t}\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{-176}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -7.79999999999999974e-173 or 2.3000000000000001e-176 < x Initial program 88.4%
Simplified93.5%
Taylor expanded in x around inf 88.6%
if -7.79999999999999974e-173 < x < 3.99999999999999985e-291 or 6.9999999999999998e-202 < x < 2.3000000000000001e-176Initial program 71.2%
Simplified74.3%
Taylor expanded in y around 0 61.4%
Taylor expanded in x around 0 53.5%
associate-*r/53.5%
neg-mul-153.5%
Simplified53.5%
if 3.99999999999999985e-291 < x < 6.9999999999999998e-202Initial program 64.9%
Simplified76.7%
Taylor expanded in y around inf 53.3%
associate-*r/53.3%
*-commutative53.3%
Simplified53.3%
Taylor expanded in x around 0 49.5%
Final simplification80.2%
(FPCore (x y z t) :precision binary64 (if (<= z -45.0) (+ x (/ -1.0 (/ z y))) (if (<= z 420.0) (- x (/ (* z -2.0) t)) (- x (/ y z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -45.0) {
tmp = x + (-1.0 / (z / y));
} else if (z <= 420.0) {
tmp = x - ((z * -2.0) / t);
} 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 (z <= (-45.0d0)) then
tmp = x + ((-1.0d0) / (z / y))
else if (z <= 420.0d0) then
tmp = x - ((z * (-2.0d0)) / t)
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 (z <= -45.0) {
tmp = x + (-1.0 / (z / y));
} else if (z <= 420.0) {
tmp = x - ((z * -2.0) / t);
} else {
tmp = x - (y / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -45.0: tmp = x + (-1.0 / (z / y)) elif z <= 420.0: tmp = x - ((z * -2.0) / t) else: tmp = x - (y / z) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -45.0) tmp = Float64(x + Float64(-1.0 / Float64(z / y))); elseif (z <= 420.0) tmp = Float64(x - Float64(Float64(z * -2.0) / t)); else tmp = Float64(x - Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -45.0) tmp = x + (-1.0 / (z / y)); elseif (z <= 420.0) tmp = x - ((z * -2.0) / t); else tmp = x - (y / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -45.0], N[(x + N[(-1.0 / N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 420.0], N[(x - N[(N[(z * -2.0), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(y / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -45:\\
\;\;\;\;x + \frac{-1}{\frac{z}{y}}\\
\mathbf{elif}\;z \leq 420:\\
\;\;\;\;x - \frac{z \cdot -2}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{z}\\
\end{array}
\end{array}
if z < -45Initial program 75.9%
Simplified88.4%
Taylor expanded in z around inf 91.9%
associate-*l*91.9%
div-inv91.9%
associate-*r*91.9%
metadata-eval91.9%
*-un-lft-identity91.9%
div-inv92.0%
clear-num92.0%
Applied egg-rr92.0%
if -45 < z < 420Initial program 88.9%
Simplified90.9%
Taylor expanded in y around inf 88.5%
associate-*r/88.5%
*-commutative88.5%
Simplified88.5%
if 420 < z Initial program 78.3%
Simplified86.2%
Taylor expanded in y around 0 92.3%
Final simplification90.1%
(FPCore (x y z t) :precision binary64 (if (<= x -2.8e-171) x (if (<= x 5.2e-177) (/ y (- z)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -2.8e-171) {
tmp = x;
} else if (x <= 5.2e-177) {
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 <= (-2.8d-171)) then
tmp = x
else if (x <= 5.2d-177) 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 <= -2.8e-171) {
tmp = x;
} else if (x <= 5.2e-177) {
tmp = y / -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -2.8e-171: tmp = x elif x <= 5.2e-177: tmp = y / -z else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -2.8e-171) tmp = x; elseif (x <= 5.2e-177) tmp = Float64(y / Float64(-z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -2.8e-171) tmp = x; elseif (x <= 5.2e-177) tmp = y / -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -2.8e-171], x, If[LessEqual[x, 5.2e-177], N[(y / (-z)), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.8 \cdot 10^{-171}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{-177}:\\
\;\;\;\;\frac{y}{-z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -2.80000000000000023e-171 or 5.2000000000000002e-177 < x Initial program 88.4%
Simplified93.5%
Taylor expanded in x around inf 88.6%
if -2.80000000000000023e-171 < x < 5.2000000000000002e-177Initial program 68.6%
Simplified75.3%
Taylor expanded in y around 0 55.7%
Taylor expanded in x around 0 43.4%
associate-*r/43.4%
neg-mul-143.4%
Simplified43.4%
Final simplification78.2%
(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 83.8%
Simplified89.3%
Taylor expanded in x around inf 73.6%
Final simplification73.6%
(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 2024067
(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)))))