
(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 (or (<= z -3.3e-143) (not (<= z 1.35e-154))) (+ x (/ (* y 2.0) (- (* t (/ y z)) (* 2.0 z)))) (- x (/ (* z -2.0) t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -3.3e-143) || !(z <= 1.35e-154)) {
tmp = x + ((y * 2.0) / ((t * (y / z)) - (2.0 * 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 <= (-3.3d-143)) .or. (.not. (z <= 1.35d-154))) then
tmp = x + ((y * 2.0d0) / ((t * (y / z)) - (2.0d0 * 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 <= -3.3e-143) || !(z <= 1.35e-154)) {
tmp = x + ((y * 2.0) / ((t * (y / z)) - (2.0 * z)));
} else {
tmp = x - ((z * -2.0) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -3.3e-143) or not (z <= 1.35e-154): tmp = x + ((y * 2.0) / ((t * (y / z)) - (2.0 * z))) else: tmp = x - ((z * -2.0) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -3.3e-143) || !(z <= 1.35e-154)) tmp = Float64(x + Float64(Float64(y * 2.0) / Float64(Float64(t * Float64(y / z)) - Float64(2.0 * 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 <= -3.3e-143) || ~((z <= 1.35e-154))) tmp = x + ((y * 2.0) / ((t * (y / z)) - (2.0 * z))); else tmp = x - ((z * -2.0) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -3.3e-143], N[Not[LessEqual[z, 1.35e-154]], $MachinePrecision]], N[(x + N[(N[(y * 2.0), $MachinePrecision] / N[(N[(t * N[(y / z), $MachinePrecision]), $MachinePrecision] - N[(2.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(z * -2.0), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.3 \cdot 10^{-143} \lor \neg \left(z \leq 1.35 \cdot 10^{-154}\right):\\
\;\;\;\;x + \frac{y \cdot 2}{t \cdot \frac{y}{z} - 2 \cdot z}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{z \cdot -2}{t}\\
\end{array}
\end{array}
if z < -3.3000000000000001e-143 or 1.34999999999999995e-154 < z Initial program 84.3%
Simplified92.6%
clear-num92.6%
un-div-inv92.6%
*-commutative92.6%
*-commutative92.6%
associate-*l*92.6%
pow292.6%
Applied egg-rr92.6%
Taylor expanded in y around 0 95.2%
mul-1-neg95.2%
+-commutative95.2%
unsub-neg95.2%
*-commutative95.2%
associate-/l*96.7%
Simplified96.7%
if -3.3000000000000001e-143 < z < 1.34999999999999995e-154Initial program 87.7%
Simplified85.0%
Taylor expanded in y around inf 100.0%
associate-*r/100.0%
*-commutative100.0%
Simplified100.0%
Final simplification97.5%
(FPCore (x y z t) :precision binary64 (if (<= (+ x (/ (* (* y 2.0) z) (- (* y t) (* z (* 2.0 z))))) 1e+214) (- x (* (* y 2.0) (/ z (fma (* 2.0 z) z (* y (- t)))))) (+ x (/ (* y 2.0) (- (* t (/ y z)) (* 2.0 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))))) <= 1e+214) {
tmp = x - ((y * 2.0) * (z / fma((2.0 * z), z, (y * -t))));
} else {
tmp = x + ((y * 2.0) / ((t * (y / z)) - (2.0 * 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))))) <= 1e+214) tmp = Float64(x - Float64(Float64(y * 2.0) * Float64(z / fma(Float64(2.0 * z), z, Float64(y * Float64(-t)))))); else tmp = Float64(x + Float64(Float64(y * 2.0) / Float64(Float64(t * Float64(y / z)) - Float64(2.0 * 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], 1e+214], N[(x - N[(N[(y * 2.0), $MachinePrecision] * N[(z / N[(N[(2.0 * z), $MachinePrecision] * z + N[(y * (-t)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y * 2.0), $MachinePrecision] / N[(N[(t * N[(y / z), $MachinePrecision]), $MachinePrecision] - N[(2.0 * z), $MachinePrecision]), $MachinePrecision]), $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 10^{+214}:\\
\;\;\;\;x - \left(y \cdot 2\right) \cdot \frac{z}{\mathsf{fma}\left(2 \cdot z, z, y \cdot \left(-t\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y \cdot 2}{t \cdot \frac{y}{z} - 2 \cdot 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)))) < 9.9999999999999995e213Initial program 96.1%
Simplified96.2%
associate-*r*96.2%
fma-neg96.2%
*-commutative96.2%
distribute-rgt-neg-in96.2%
Applied egg-rr96.2%
if 9.9999999999999995e213 < (-.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 28.9%
Simplified62.6%
clear-num62.6%
un-div-inv62.6%
*-commutative62.6%
*-commutative62.6%
associate-*l*62.6%
pow262.6%
Applied egg-rr62.6%
Taylor expanded in y around 0 79.3%
mul-1-neg79.3%
+-commutative79.3%
unsub-neg79.3%
*-commutative79.3%
associate-/l*97.5%
Simplified97.5%
Final simplification96.4%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* y t) (* z (* 2.0 z)))))
(if (<= (+ x (/ (* (* y 2.0) z) t_1)) 1e+214)
(+ x (* (* y 2.0) (/ z t_1)))
(+ x (/ (* y 2.0) (- (* t (/ y z)) (* 2.0 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)) <= 1e+214) {
tmp = x + ((y * 2.0) * (z / t_1));
} else {
tmp = x + ((y * 2.0) / ((t * (y / z)) - (2.0 * 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)) <= 1d+214) then
tmp = x + ((y * 2.0d0) * (z / t_1))
else
tmp = x + ((y * 2.0d0) / ((t * (y / z)) - (2.0d0 * 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)) <= 1e+214) {
tmp = x + ((y * 2.0) * (z / t_1));
} else {
tmp = x + ((y * 2.0) / ((t * (y / z)) - (2.0 * 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)) <= 1e+214: tmp = x + ((y * 2.0) * (z / t_1)) else: tmp = x + ((y * 2.0) / ((t * (y / z)) - (2.0 * 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)) <= 1e+214) tmp = Float64(x + Float64(Float64(y * 2.0) * Float64(z / t_1))); else tmp = Float64(x + Float64(Float64(y * 2.0) / Float64(Float64(t * Float64(y / z)) - Float64(2.0 * 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)) <= 1e+214) tmp = x + ((y * 2.0) * (z / t_1)); else tmp = x + ((y * 2.0) / ((t * (y / z)) - (2.0 * 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], 1e+214], N[(x + N[(N[(y * 2.0), $MachinePrecision] * N[(z / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y * 2.0), $MachinePrecision] / N[(N[(t * N[(y / z), $MachinePrecision]), $MachinePrecision] - N[(2.0 * z), $MachinePrecision]), $MachinePrecision]), $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 10^{+214}:\\
\;\;\;\;x + \left(y \cdot 2\right) \cdot \frac{z}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y \cdot 2}{t \cdot \frac{y}{z} - 2 \cdot 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)))) < 9.9999999999999995e213Initial program 96.1%
Simplified96.2%
if 9.9999999999999995e213 < (-.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 28.9%
Simplified62.6%
clear-num62.6%
un-div-inv62.6%
*-commutative62.6%
*-commutative62.6%
associate-*l*62.6%
pow262.6%
Applied egg-rr62.6%
Taylor expanded in y around 0 79.3%
mul-1-neg79.3%
+-commutative79.3%
unsub-neg79.3%
*-commutative79.3%
associate-/l*97.5%
Simplified97.5%
Final simplification96.4%
(FPCore (x y z t) :precision binary64 (if (or (<= z -1.85e-31) (not (<= z 1.9e-15))) (- x (/ y z)) (- x (/ (* z -2.0) t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1.85e-31) || !(z <= 1.9e-15)) {
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 <= (-1.85d-31)) .or. (.not. (z <= 1.9d-15))) 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 <= -1.85e-31) || !(z <= 1.9e-15)) {
tmp = x - (y / z);
} else {
tmp = x - ((z * -2.0) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -1.85e-31) or not (z <= 1.9e-15): tmp = x - (y / z) else: tmp = x - ((z * -2.0) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -1.85e-31) || !(z <= 1.9e-15)) 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 <= -1.85e-31) || ~((z <= 1.9e-15))) 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, -1.85e-31], N[Not[LessEqual[z, 1.9e-15]], $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 -1.85 \cdot 10^{-31} \lor \neg \left(z \leq 1.9 \cdot 10^{-15}\right):\\
\;\;\;\;x - \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{z \cdot -2}{t}\\
\end{array}
\end{array}
if z < -1.8499999999999999e-31 or 1.9000000000000001e-15 < z Initial program 79.2%
Simplified90.4%
Taylor expanded in y around 0 89.3%
if -1.8499999999999999e-31 < z < 1.9000000000000001e-15Initial program 92.5%
Simplified91.0%
Taylor expanded in y around inf 94.2%
associate-*r/94.2%
*-commutative94.2%
Simplified94.2%
Final simplification91.4%
(FPCore (x y z t) :precision binary64 (if (or (<= z -3.6e-50) (not (<= z 5.6e-36))) (- x (/ y z)) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -3.6e-50) || !(z <= 5.6e-36)) {
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-50)) .or. (.not. (z <= 5.6d-36))) 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-50) || !(z <= 5.6e-36)) {
tmp = x - (y / z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -3.6e-50) or not (z <= 5.6e-36): tmp = x - (y / z) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -3.6e-50) || !(z <= 5.6e-36)) 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-50) || ~((z <= 5.6e-36))) tmp = x - (y / z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -3.6e-50], N[Not[LessEqual[z, 5.6e-36]], $MachinePrecision]], N[(x - N[(y / z), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.6 \cdot 10^{-50} \lor \neg \left(z \leq 5.6 \cdot 10^{-36}\right):\\
\;\;\;\;x - \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -3.59999999999999979e-50 or 5.6000000000000002e-36 < z Initial program 80.3%
Simplified90.7%
Taylor expanded in y around 0 85.6%
if -3.59999999999999979e-50 < z < 5.6000000000000002e-36Initial program 92.3%
Simplified90.6%
Taylor expanded in x around inf 71.1%
Final simplification79.8%
(FPCore (x y z t) :precision binary64 (if (<= x 6.6e-300) x (if (<= x 1e-124) (* 2.0 (/ z t)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= 6.6e-300) {
tmp = x;
} else if (x <= 1e-124) {
tmp = 2.0 * (z / t);
} 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-300) then
tmp = x
else if (x <= 1d-124) then
tmp = 2.0d0 * (z / t)
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-300) {
tmp = x;
} else if (x <= 1e-124) {
tmp = 2.0 * (z / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= 6.6e-300: tmp = x elif x <= 1e-124: tmp = 2.0 * (z / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= 6.6e-300) tmp = x; elseif (x <= 1e-124) tmp = Float64(2.0 * Float64(z / t)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= 6.6e-300) tmp = x; elseif (x <= 1e-124) tmp = 2.0 * (z / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, 6.6e-300], x, If[LessEqual[x, 1e-124], N[(2.0 * N[(z / t), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.6 \cdot 10^{-300}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 10^{-124}:\\
\;\;\;\;2 \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < 6.6000000000000004e-300 or 9.99999999999999933e-125 < x Initial program 87.0%
Simplified94.0%
Taylor expanded in x around inf 79.4%
if 6.6000000000000004e-300 < x < 9.99999999999999933e-125Initial program 74.1%
Simplified71.8%
Taylor expanded in y around inf 61.6%
associate-*r/61.6%
*-commutative61.6%
Simplified61.6%
Taylor expanded in x around 0 55.5%
(FPCore (x y z t) :precision binary64 (if (<= x 1.26e-297) x (if (<= x 1.7e-100) (/ y (- z)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= 1.26e-297) {
tmp = x;
} else if (x <= 1.7e-100) {
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 <= 1.26d-297) then
tmp = x
else if (x <= 1.7d-100) 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 <= 1.26e-297) {
tmp = x;
} else if (x <= 1.7e-100) {
tmp = y / -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= 1.26e-297: tmp = x elif x <= 1.7e-100: tmp = y / -z else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= 1.26e-297) tmp = x; elseif (x <= 1.7e-100) 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 <= 1.26e-297) tmp = x; elseif (x <= 1.7e-100) tmp = y / -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, 1.26e-297], x, If[LessEqual[x, 1.7e-100], N[(y / (-z)), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.26 \cdot 10^{-297}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{-100}:\\
\;\;\;\;\frac{y}{-z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < 1.2599999999999999e-297 or 1.69999999999999988e-100 < x Initial program 86.7%
Simplified93.8%
Taylor expanded in x around inf 80.2%
if 1.2599999999999999e-297 < x < 1.69999999999999988e-100Initial program 77.4%
Simplified75.5%
Taylor expanded in y around 0 46.4%
Taylor expanded in x around 0 40.0%
mul-1-neg40.0%
distribute-frac-neg240.0%
Simplified40.0%
(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 85.1%
Simplified90.7%
Taylor expanded in x around inf 69.7%
(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 2024098
(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)))))