
(FPCore (x y z t) :precision binary64 (/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0)))
double code(double x, double y, double z, double t) {
return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
}
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 * z) - x) / ((t * z) - x))) / (x + 1.0d0)
end function
public static double code(double x, double y, double z, double t) {
return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
}
def code(x, y, z, t): return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0)
function code(x, y, z, t) return Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / Float64(Float64(t * z) - x))) / Float64(x + 1.0)) end
function tmp = code(x, y, z, t) tmp = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0); end
code[x_, y_, z_, t_] := N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / N[(N[(t * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0)))
double code(double x, double y, double z, double t) {
return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
}
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 * z) - x) / ((t * z) - x))) / (x + 1.0d0)
end function
public static double code(double x, double y, double z, double t) {
return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
}
def code(x, y, z, t): return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0)
function code(x, y, z, t) return Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / Float64(Float64(t * z) - x))) / Float64(x + 1.0)) end
function tmp = code(x, y, z, t) tmp = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0); end
code[x_, y_, z_, t_] := N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / N[(N[(t * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\end{array}
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* z t) x)) (t_2 (/ (+ x (/ (- (* y z) x) t_1)) (+ x 1.0))))
(if (<= t_2 -1e+16)
(* (/ z t_1) (/ y (+ x 1.0)))
(if (<= t_2 0.05)
(/ (- x (/ (- (/ x z) y) t)) (+ x 1.0))
(/ (+ x (* y (- (/ 1.0 y) (* z (/ -1.0 t_1))))) (+ x 1.0))))))
double code(double x, double y, double z, double t) {
double t_1 = (z * t) - x;
double t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0);
double tmp;
if (t_2 <= -1e+16) {
tmp = (z / t_1) * (y / (x + 1.0));
} else if (t_2 <= 0.05) {
tmp = (x - (((x / z) - y) / t)) / (x + 1.0);
} else {
tmp = (x + (y * ((1.0 / y) - (z * (-1.0 / t_1))))) / (x + 1.0);
}
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 * t) - x
t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0d0)
if (t_2 <= (-1d+16)) then
tmp = (z / t_1) * (y / (x + 1.0d0))
else if (t_2 <= 0.05d0) then
tmp = (x - (((x / z) - y) / t)) / (x + 1.0d0)
else
tmp = (x + (y * ((1.0d0 / y) - (z * ((-1.0d0) / t_1))))) / (x + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (z * t) - x;
double t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0);
double tmp;
if (t_2 <= -1e+16) {
tmp = (z / t_1) * (y / (x + 1.0));
} else if (t_2 <= 0.05) {
tmp = (x - (((x / z) - y) / t)) / (x + 1.0);
} else {
tmp = (x + (y * ((1.0 / y) - (z * (-1.0 / t_1))))) / (x + 1.0);
}
return tmp;
}
def code(x, y, z, t): t_1 = (z * t) - x t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0) tmp = 0 if t_2 <= -1e+16: tmp = (z / t_1) * (y / (x + 1.0)) elif t_2 <= 0.05: tmp = (x - (((x / z) - y) / t)) / (x + 1.0) else: tmp = (x + (y * ((1.0 / y) - (z * (-1.0 / t_1))))) / (x + 1.0) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(z * t) - x) t_2 = Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / t_1)) / Float64(x + 1.0)) tmp = 0.0 if (t_2 <= -1e+16) tmp = Float64(Float64(z / t_1) * Float64(y / Float64(x + 1.0))); elseif (t_2 <= 0.05) tmp = Float64(Float64(x - Float64(Float64(Float64(x / z) - y) / t)) / Float64(x + 1.0)); else tmp = Float64(Float64(x + Float64(y * Float64(Float64(1.0 / y) - Float64(z * Float64(-1.0 / t_1))))) / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (z * t) - x; t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0); tmp = 0.0; if (t_2 <= -1e+16) tmp = (z / t_1) * (y / (x + 1.0)); elseif (t_2 <= 0.05) tmp = (x - (((x / z) - y) / t)) / (x + 1.0); else tmp = (x + (y * ((1.0 / y) - (z * (-1.0 / t_1))))) / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z * t), $MachinePrecision] - x), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -1e+16], N[(N[(z / t$95$1), $MachinePrecision] * N[(y / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.05], N[(N[(x - N[(N[(N[(x / z), $MachinePrecision] - y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(y * N[(N[(1.0 / y), $MachinePrecision] - N[(z * N[(-1.0 / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot t - x\\
t_2 := \frac{x + \frac{y \cdot z - x}{t\_1}}{x + 1}\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{+16}:\\
\;\;\;\;\frac{z}{t\_1} \cdot \frac{y}{x + 1}\\
\mathbf{elif}\;t\_2 \leq 0.05:\\
\;\;\;\;\frac{x - \frac{\frac{x}{z} - y}{t}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x + y \cdot \left(\frac{1}{y} - z \cdot \frac{-1}{t\_1}\right)}{x + 1}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < -1e16Initial program 78.4%
*-commutative78.4%
Simplified78.4%
Taylor expanded in y around inf 77.9%
times-frac99.7%
+-commutative99.7%
Applied egg-rr99.7%
if -1e16 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < 0.050000000000000003Initial program 93.5%
*-commutative93.5%
Simplified93.5%
Taylor expanded in t around -inf 97.8%
mul-1-neg97.8%
distribute-lft-out--97.8%
Simplified97.8%
if 0.050000000000000003 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) Initial program 91.8%
*-commutative91.8%
Simplified91.8%
Taylor expanded in y around inf 94.2%
div-inv94.2%
Applied egg-rr94.2%
Taylor expanded in x around inf 97.3%
Final simplification97.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* z t) x))
(t_2 (/ (+ x (/ (- (* y z) x) t_1)) (+ x 1.0)))
(t_3 (/ y (+ x 1.0))))
(if (<= t_2 -2e+120)
(* (/ z t_1) t_3)
(if (<= t_2 1e+241)
t_2
(+ (/ x (+ x 1.0)) (/ (+ t_3 (/ (/ x z) (- -1.0 x))) t))))))
double code(double x, double y, double z, double t) {
double t_1 = (z * t) - x;
double t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0);
double t_3 = y / (x + 1.0);
double tmp;
if (t_2 <= -2e+120) {
tmp = (z / t_1) * t_3;
} else if (t_2 <= 1e+241) {
tmp = t_2;
} else {
tmp = (x / (x + 1.0)) + ((t_3 + ((x / z) / (-1.0 - x))) / 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) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_1 = (z * t) - x
t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0d0)
t_3 = y / (x + 1.0d0)
if (t_2 <= (-2d+120)) then
tmp = (z / t_1) * t_3
else if (t_2 <= 1d+241) then
tmp = t_2
else
tmp = (x / (x + 1.0d0)) + ((t_3 + ((x / z) / ((-1.0d0) - x))) / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (z * t) - x;
double t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0);
double t_3 = y / (x + 1.0);
double tmp;
if (t_2 <= -2e+120) {
tmp = (z / t_1) * t_3;
} else if (t_2 <= 1e+241) {
tmp = t_2;
} else {
tmp = (x / (x + 1.0)) + ((t_3 + ((x / z) / (-1.0 - x))) / t);
}
return tmp;
}
def code(x, y, z, t): t_1 = (z * t) - x t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0) t_3 = y / (x + 1.0) tmp = 0 if t_2 <= -2e+120: tmp = (z / t_1) * t_3 elif t_2 <= 1e+241: tmp = t_2 else: tmp = (x / (x + 1.0)) + ((t_3 + ((x / z) / (-1.0 - x))) / t) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(z * t) - x) t_2 = Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / t_1)) / Float64(x + 1.0)) t_3 = Float64(y / Float64(x + 1.0)) tmp = 0.0 if (t_2 <= -2e+120) tmp = Float64(Float64(z / t_1) * t_3); elseif (t_2 <= 1e+241) tmp = t_2; else tmp = Float64(Float64(x / Float64(x + 1.0)) + Float64(Float64(t_3 + Float64(Float64(x / z) / Float64(-1.0 - x))) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (z * t) - x; t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0); t_3 = y / (x + 1.0); tmp = 0.0; if (t_2 <= -2e+120) tmp = (z / t_1) * t_3; elseif (t_2 <= 1e+241) tmp = t_2; else tmp = (x / (x + 1.0)) + ((t_3 + ((x / z) / (-1.0 - x))) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z * t), $MachinePrecision] - x), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(y / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+120], N[(N[(z / t$95$1), $MachinePrecision] * t$95$3), $MachinePrecision], If[LessEqual[t$95$2, 1e+241], t$95$2, N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$3 + N[(N[(x / z), $MachinePrecision] / N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot t - x\\
t_2 := \frac{x + \frac{y \cdot z - x}{t\_1}}{x + 1}\\
t_3 := \frac{y}{x + 1}\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+120}:\\
\;\;\;\;\frac{z}{t\_1} \cdot t\_3\\
\mathbf{elif}\;t\_2 \leq 10^{+241}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1} + \frac{t\_3 + \frac{\frac{x}{z}}{-1 - x}}{t}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < -2e120Initial program 67.9%
*-commutative67.9%
Simplified67.9%
Taylor expanded in y around inf 67.2%
times-frac99.8%
+-commutative99.8%
Applied egg-rr99.8%
if -2e120 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < 1.0000000000000001e241Initial program 98.0%
if 1.0000000000000001e241 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) Initial program 43.1%
*-commutative43.1%
Simplified43.1%
Taylor expanded in t around -inf 79.9%
+-commutative79.9%
mul-1-neg79.9%
unsub-neg79.9%
+-commutative79.9%
sub-neg79.9%
mul-1-neg79.9%
distribute-neg-frac279.9%
distribute-neg-in79.9%
metadata-eval79.9%
unsub-neg79.9%
mul-1-neg79.9%
remove-double-neg79.9%
associate-/r*79.9%
+-commutative79.9%
Simplified79.9%
Final simplification96.5%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* z t) x)) (t_2 (/ (+ x (/ (- (* y z) x) t_1)) (+ x 1.0))))
(if (<= t_2 -2e+120)
(* (/ z t_1) (/ y (+ x 1.0)))
(if (<= t_2 1e+241) t_2 (/ (+ x (/ y t)) (+ x 1.0))))))
double code(double x, double y, double z, double t) {
double t_1 = (z * t) - x;
double t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0);
double tmp;
if (t_2 <= -2e+120) {
tmp = (z / t_1) * (y / (x + 1.0));
} else if (t_2 <= 1e+241) {
tmp = t_2;
} else {
tmp = (x + (y / t)) / (x + 1.0);
}
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 * t) - x
t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0d0)
if (t_2 <= (-2d+120)) then
tmp = (z / t_1) * (y / (x + 1.0d0))
else if (t_2 <= 1d+241) then
tmp = t_2
else
tmp = (x + (y / t)) / (x + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (z * t) - x;
double t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0);
double tmp;
if (t_2 <= -2e+120) {
tmp = (z / t_1) * (y / (x + 1.0));
} else if (t_2 <= 1e+241) {
tmp = t_2;
} else {
tmp = (x + (y / t)) / (x + 1.0);
}
return tmp;
}
def code(x, y, z, t): t_1 = (z * t) - x t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0) tmp = 0 if t_2 <= -2e+120: tmp = (z / t_1) * (y / (x + 1.0)) elif t_2 <= 1e+241: tmp = t_2 else: tmp = (x + (y / t)) / (x + 1.0) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(z * t) - x) t_2 = Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / t_1)) / Float64(x + 1.0)) tmp = 0.0 if (t_2 <= -2e+120) tmp = Float64(Float64(z / t_1) * Float64(y / Float64(x + 1.0))); elseif (t_2 <= 1e+241) tmp = t_2; else tmp = Float64(Float64(x + Float64(y / t)) / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (z * t) - x; t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0); tmp = 0.0; if (t_2 <= -2e+120) tmp = (z / t_1) * (y / (x + 1.0)); elseif (t_2 <= 1e+241) tmp = t_2; else tmp = (x + (y / t)) / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z * t), $MachinePrecision] - x), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+120], N[(N[(z / t$95$1), $MachinePrecision] * N[(y / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e+241], t$95$2, N[(N[(x + N[(y / t), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot t - x\\
t_2 := \frac{x + \frac{y \cdot z - x}{t\_1}}{x + 1}\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+120}:\\
\;\;\;\;\frac{z}{t\_1} \cdot \frac{y}{x + 1}\\
\mathbf{elif}\;t\_2 \leq 10^{+241}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < -2e120Initial program 67.9%
*-commutative67.9%
Simplified67.9%
Taylor expanded in y around inf 67.2%
times-frac99.8%
+-commutative99.8%
Applied egg-rr99.8%
if -2e120 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) < 1.0000000000000001e241Initial program 98.0%
if 1.0000000000000001e241 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) Initial program 43.1%
*-commutative43.1%
Simplified43.1%
Taylor expanded in z around inf 75.9%
+-commutative75.9%
+-commutative75.9%
Simplified75.9%
Final simplification96.1%
(FPCore (x y z t)
:precision binary64
(if (<= x -4.1e+15)
1.0
(if (<= x 6.5e-103)
(/ (+ x (/ y t)) (+ x 1.0))
(if (<= x 2.75e-19) (/ (/ (- x (* y z)) x) (+ x 1.0)) (/ x (+ x 1.0))))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -4.1e+15) {
tmp = 1.0;
} else if (x <= 6.5e-103) {
tmp = (x + (y / t)) / (x + 1.0);
} else if (x <= 2.75e-19) {
tmp = ((x - (y * z)) / x) / (x + 1.0);
} else {
tmp = x / (x + 1.0);
}
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.1d+15)) then
tmp = 1.0d0
else if (x <= 6.5d-103) then
tmp = (x + (y / t)) / (x + 1.0d0)
else if (x <= 2.75d-19) then
tmp = ((x - (y * z)) / x) / (x + 1.0d0)
else
tmp = x / (x + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -4.1e+15) {
tmp = 1.0;
} else if (x <= 6.5e-103) {
tmp = (x + (y / t)) / (x + 1.0);
} else if (x <= 2.75e-19) {
tmp = ((x - (y * z)) / x) / (x + 1.0);
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -4.1e+15: tmp = 1.0 elif x <= 6.5e-103: tmp = (x + (y / t)) / (x + 1.0) elif x <= 2.75e-19: tmp = ((x - (y * z)) / x) / (x + 1.0) else: tmp = x / (x + 1.0) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -4.1e+15) tmp = 1.0; elseif (x <= 6.5e-103) tmp = Float64(Float64(x + Float64(y / t)) / Float64(x + 1.0)); elseif (x <= 2.75e-19) tmp = Float64(Float64(Float64(x - Float64(y * z)) / x) / Float64(x + 1.0)); else tmp = Float64(x / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -4.1e+15) tmp = 1.0; elseif (x <= 6.5e-103) tmp = (x + (y / t)) / (x + 1.0); elseif (x <= 2.75e-19) tmp = ((x - (y * z)) / x) / (x + 1.0); else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -4.1e+15], 1.0, If[LessEqual[x, 6.5e-103], N[(N[(x + N[(y / t), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.75e-19], N[(N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.1 \cdot 10^{+15}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 6.5 \cdot 10^{-103}:\\
\;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\
\mathbf{elif}\;x \leq 2.75 \cdot 10^{-19}:\\
\;\;\;\;\frac{\frac{x - y \cdot z}{x}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -4.1e15Initial program 86.7%
*-commutative86.7%
Simplified86.7%
Taylor expanded in x around inf 88.9%
if -4.1e15 < x < 6.49999999999999966e-103Initial program 91.0%
*-commutative91.0%
Simplified91.0%
Taylor expanded in z around inf 70.1%
+-commutative70.1%
+-commutative70.1%
Simplified70.1%
if 6.49999999999999966e-103 < x < 2.7499999999999998e-19Initial program 99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in t around 0 76.0%
mul-1-neg76.0%
unsub-neg76.0%
associate-/l*76.0%
+-commutative76.0%
Simplified76.0%
Taylor expanded in x around 0 76.0%
*-commutative76.0%
Simplified76.0%
if 2.7499999999999998e-19 < x Initial program 91.6%
*-commutative91.6%
Simplified91.6%
Taylor expanded in t around inf 92.1%
+-commutative92.1%
Simplified92.1%
Final simplification79.8%
(FPCore (x y z t) :precision binary64 (if (or (<= t -1.45e-39) (not (<= t 3.2e-87))) (/ (+ x (/ y t)) (+ x 1.0)) (/ (+ (- x (* y (/ z x))) 1.0) (+ x 1.0))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.45e-39) || !(t <= 3.2e-87)) {
tmp = (x + (y / t)) / (x + 1.0);
} else {
tmp = ((x - (y * (z / x))) + 1.0) / (x + 1.0);
}
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.45d-39)) .or. (.not. (t <= 3.2d-87))) then
tmp = (x + (y / t)) / (x + 1.0d0)
else
tmp = ((x - (y * (z / x))) + 1.0d0) / (x + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.45e-39) || !(t <= 3.2e-87)) {
tmp = (x + (y / t)) / (x + 1.0);
} else {
tmp = ((x - (y * (z / x))) + 1.0) / (x + 1.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -1.45e-39) or not (t <= 3.2e-87): tmp = (x + (y / t)) / (x + 1.0) else: tmp = ((x - (y * (z / x))) + 1.0) / (x + 1.0) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -1.45e-39) || !(t <= 3.2e-87)) tmp = Float64(Float64(x + Float64(y / t)) / Float64(x + 1.0)); else tmp = Float64(Float64(Float64(x - Float64(y * Float64(z / x))) + 1.0) / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -1.45e-39) || ~((t <= 3.2e-87))) tmp = (x + (y / t)) / (x + 1.0); else tmp = ((x - (y * (z / x))) + 1.0) / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -1.45e-39], N[Not[LessEqual[t, 3.2e-87]], $MachinePrecision]], N[(N[(x + N[(y / t), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x - N[(y * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.45 \cdot 10^{-39} \lor \neg \left(t \leq 3.2 \cdot 10^{-87}\right):\\
\;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x - y \cdot \frac{z}{x}\right) + 1}{x + 1}\\
\end{array}
\end{array}
if t < -1.44999999999999994e-39 or 3.19999999999999979e-87 < t Initial program 90.1%
*-commutative90.1%
Simplified90.1%
Taylor expanded in z around inf 84.1%
+-commutative84.1%
+-commutative84.1%
Simplified84.1%
if -1.44999999999999994e-39 < t < 3.19999999999999979e-87Initial program 91.7%
*-commutative91.7%
Simplified91.7%
Taylor expanded in t around 0 76.2%
mul-1-neg76.2%
unsub-neg76.2%
associate-/l*82.6%
+-commutative82.6%
Simplified82.6%
Final simplification83.5%
(FPCore (x y z t)
:precision binary64
(if (<= x -1.9e-54)
(/ (+ (- x (* y (/ z x))) 1.0) (+ x 1.0))
(if (<= x 1.14e-144)
(/ (- x (/ (- (/ x z) y) t)) (+ x 1.0))
(/ (+ x (/ x (- x (* z t)))) (+ x 1.0)))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.9e-54) {
tmp = ((x - (y * (z / x))) + 1.0) / (x + 1.0);
} else if (x <= 1.14e-144) {
tmp = (x - (((x / z) - y) / t)) / (x + 1.0);
} else {
tmp = (x + (x / (x - (z * t)))) / (x + 1.0);
}
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.9d-54)) then
tmp = ((x - (y * (z / x))) + 1.0d0) / (x + 1.0d0)
else if (x <= 1.14d-144) then
tmp = (x - (((x / z) - y) / t)) / (x + 1.0d0)
else
tmp = (x + (x / (x - (z * t)))) / (x + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.9e-54) {
tmp = ((x - (y * (z / x))) + 1.0) / (x + 1.0);
} else if (x <= 1.14e-144) {
tmp = (x - (((x / z) - y) / t)) / (x + 1.0);
} else {
tmp = (x + (x / (x - (z * t)))) / (x + 1.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -1.9e-54: tmp = ((x - (y * (z / x))) + 1.0) / (x + 1.0) elif x <= 1.14e-144: tmp = (x - (((x / z) - y) / t)) / (x + 1.0) else: tmp = (x + (x / (x - (z * t)))) / (x + 1.0) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -1.9e-54) tmp = Float64(Float64(Float64(x - Float64(y * Float64(z / x))) + 1.0) / Float64(x + 1.0)); elseif (x <= 1.14e-144) tmp = Float64(Float64(x - Float64(Float64(Float64(x / z) - y) / t)) / Float64(x + 1.0)); else tmp = Float64(Float64(x + Float64(x / Float64(x - Float64(z * t)))) / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -1.9e-54) tmp = ((x - (y * (z / x))) + 1.0) / (x + 1.0); elseif (x <= 1.14e-144) tmp = (x - (((x / z) - y) / t)) / (x + 1.0); else tmp = (x + (x / (x - (z * t)))) / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -1.9e-54], N[(N[(N[(x - N[(y * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.14e-144], N[(N[(x - N[(N[(N[(x / z), $MachinePrecision] - y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(x / N[(x - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9 \cdot 10^{-54}:\\
\;\;\;\;\frac{\left(x - y \cdot \frac{z}{x}\right) + 1}{x + 1}\\
\mathbf{elif}\;x \leq 1.14 \cdot 10^{-144}:\\
\;\;\;\;\frac{x - \frac{\frac{x}{z} - y}{t}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x + \frac{x}{x - z \cdot t}}{x + 1}\\
\end{array}
\end{array}
if x < -1.9000000000000001e-54Initial program 87.6%
*-commutative87.6%
Simplified87.6%
Taylor expanded in t around 0 81.8%
mul-1-neg81.8%
unsub-neg81.8%
associate-/l*90.2%
+-commutative90.2%
Simplified90.2%
if -1.9000000000000001e-54 < x < 1.14000000000000006e-144Initial program 90.4%
*-commutative90.4%
Simplified90.4%
Taylor expanded in t around -inf 81.6%
mul-1-neg81.6%
distribute-lft-out--81.6%
Simplified81.6%
if 1.14000000000000006e-144 < x Initial program 93.9%
*-commutative93.9%
Simplified93.9%
Taylor expanded in y around 0 85.8%
Final simplification85.3%
(FPCore (x y z t) :precision binary64 (if (<= x -4.6e+21) 1.0 (if (<= x 6.4e-99) (/ (+ x (/ y t)) (+ x 1.0)) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -4.6e+21) {
tmp = 1.0;
} else if (x <= 6.4e-99) {
tmp = (x + (y / t)) / (x + 1.0);
} else {
tmp = 1.0;
}
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+21)) then
tmp = 1.0d0
else if (x <= 6.4d-99) then
tmp = (x + (y / t)) / (x + 1.0d0)
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -4.6e+21) {
tmp = 1.0;
} else if (x <= 6.4e-99) {
tmp = (x + (y / t)) / (x + 1.0);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -4.6e+21: tmp = 1.0 elif x <= 6.4e-99: tmp = (x + (y / t)) / (x + 1.0) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -4.6e+21) tmp = 1.0; elseif (x <= 6.4e-99) tmp = Float64(Float64(x + Float64(y / t)) / Float64(x + 1.0)); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -4.6e+21) tmp = 1.0; elseif (x <= 6.4e-99) tmp = (x + (y / t)) / (x + 1.0); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -4.6e+21], 1.0, If[LessEqual[x, 6.4e-99], N[(N[(x + N[(y / t), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.6 \cdot 10^{+21}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 6.4 \cdot 10^{-99}:\\
\;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -4.6e21 or 6.4000000000000001e-99 < x Initial program 90.6%
*-commutative90.6%
Simplified90.6%
Taylor expanded in x around inf 84.6%
if -4.6e21 < x < 6.4000000000000001e-99Initial program 91.0%
*-commutative91.0%
Simplified91.0%
Taylor expanded in z around inf 70.1%
+-commutative70.1%
+-commutative70.1%
Simplified70.1%
Final simplification77.7%
(FPCore (x y z t) :precision binary64 (if (<= x -1.04e-78) 1.0 (if (<= x 1.96e-143) (/ y t) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.04e-78) {
tmp = 1.0;
} else if (x <= 1.96e-143) {
tmp = y / t;
} else {
tmp = 1.0;
}
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.04d-78)) then
tmp = 1.0d0
else if (x <= 1.96d-143) then
tmp = y / t
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.04e-78) {
tmp = 1.0;
} else if (x <= 1.96e-143) {
tmp = y / t;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -1.04e-78: tmp = 1.0 elif x <= 1.96e-143: tmp = y / t else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -1.04e-78) tmp = 1.0; elseif (x <= 1.96e-143) tmp = Float64(y / t); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -1.04e-78) tmp = 1.0; elseif (x <= 1.96e-143) tmp = y / t; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -1.04e-78], 1.0, If[LessEqual[x, 1.96e-143], N[(y / t), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.04 \cdot 10^{-78}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.96 \cdot 10^{-143}:\\
\;\;\;\;\frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1.03999999999999997e-78 or 1.96000000000000004e-143 < x Initial program 91.5%
*-commutative91.5%
Simplified91.5%
Taylor expanded in x around inf 76.9%
if -1.03999999999999997e-78 < x < 1.96000000000000004e-143Initial program 89.6%
*-commutative89.6%
Simplified89.6%
Taylor expanded in x around 0 55.4%
(FPCore (x y z t) :precision binary64 1.0)
double code(double x, double y, double z, double t) {
return 1.0;
}
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 = 1.0d0
end function
public static double code(double x, double y, double z, double t) {
return 1.0;
}
def code(x, y, z, t): return 1.0
function code(x, y, z, t) return 1.0 end
function tmp = code(x, y, z, t) tmp = 1.0; end
code[x_, y_, z_, t_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 90.8%
*-commutative90.8%
Simplified90.8%
Taylor expanded in x around inf 51.7%
(FPCore (x y z t) :precision binary64 (/ (+ x (- (/ y (- t (/ x z))) (/ x (- (* t z) x)))) (+ x 1.0)))
double code(double x, double y, double z, double t) {
return (x + ((y / (t - (x / z))) - (x / ((t * z) - x)))) / (x + 1.0);
}
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 / (t - (x / z))) - (x / ((t * z) - x)))) / (x + 1.0d0)
end function
public static double code(double x, double y, double z, double t) {
return (x + ((y / (t - (x / z))) - (x / ((t * z) - x)))) / (x + 1.0);
}
def code(x, y, z, t): return (x + ((y / (t - (x / z))) - (x / ((t * z) - x)))) / (x + 1.0)
function code(x, y, z, t) return Float64(Float64(x + Float64(Float64(y / Float64(t - Float64(x / z))) - Float64(x / Float64(Float64(t * z) - x)))) / Float64(x + 1.0)) end
function tmp = code(x, y, z, t) tmp = (x + ((y / (t - (x / z))) - (x / ((t * z) - x)))) / (x + 1.0); end
code[x_, y_, z_, t_] := N[(N[(x + N[(N[(y / N[(t - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x / N[(N[(t * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + \left(\frac{y}{t - \frac{x}{z}} - \frac{x}{t \cdot z - x}\right)}{x + 1}
\end{array}
herbie shell --seed 2024143
(FPCore (x y z t)
:name "Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, A"
:precision binary64
:alt
(! :herbie-platform default (/ (+ x (- (/ y (- t (/ x z))) (/ x (- (* t z) x)))) (+ x 1)))
(/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0)))