
(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 11 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 (/ (- (/ (- (* y z) x) (- x (* z t))) x) (- -1.0 x)))) (if (<= t_1 5e+301) t_1 (/ (+ x (/ y t)) (+ x 1.0)))))
double code(double x, double y, double z, double t) {
double t_1 = ((((y * z) - x) / (x - (z * t))) - x) / (-1.0 - x);
double tmp;
if (t_1 <= 5e+301) {
tmp = t_1;
} 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) :: tmp
t_1 = ((((y * z) - x) / (x - (z * t))) - x) / ((-1.0d0) - x)
if (t_1 <= 5d+301) then
tmp = t_1
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 = ((((y * z) - x) / (x - (z * t))) - x) / (-1.0 - x);
double tmp;
if (t_1 <= 5e+301) {
tmp = t_1;
} else {
tmp = (x + (y / t)) / (x + 1.0);
}
return tmp;
}
def code(x, y, z, t): t_1 = ((((y * z) - x) / (x - (z * t))) - x) / (-1.0 - x) tmp = 0 if t_1 <= 5e+301: tmp = t_1 else: tmp = (x + (y / t)) / (x + 1.0) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(Float64(Float64(Float64(y * z) - x) / Float64(x - Float64(z * t))) - x) / Float64(-1.0 - x)) tmp = 0.0 if (t_1 <= 5e+301) tmp = t_1; 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 = ((((y * z) - x) / (x - (z * t))) - x) / (-1.0 - x); tmp = 0.0; if (t_1 <= 5e+301) tmp = t_1; else tmp = (x + (y / t)) / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / N[(x - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 5e+301], t$95$1, N[(N[(x + N[(y / t), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\frac{y \cdot z - x}{x - z \cdot t} - x}{-1 - x}\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{+301}:\\
\;\;\;\;t\_1\\
\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))) < 5.0000000000000004e301Initial program 97.7%
if 5.0000000000000004e301 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x #s(literal 1 binary64))) Initial program 32.0%
*-commutative32.0%
Simplified32.0%
Taylor expanded in z around inf 82.0%
Final simplification95.7%
(FPCore (x y z t) :precision binary64 (if (or (<= z -5.5e+26) (not (<= z 5.5e-27))) (/ (+ x (/ y t)) (+ x 1.0)) (/ (+ x (/ (- x (* y z)) x)) (+ x 1.0))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -5.5e+26) || !(z <= 5.5e-27)) {
tmp = (x + (y / t)) / (x + 1.0);
} else {
tmp = (x + ((x - (y * z)) / 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 ((z <= (-5.5d+26)) .or. (.not. (z <= 5.5d-27))) then
tmp = (x + (y / t)) / (x + 1.0d0)
else
tmp = (x + ((x - (y * z)) / 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 ((z <= -5.5e+26) || !(z <= 5.5e-27)) {
tmp = (x + (y / t)) / (x + 1.0);
} else {
tmp = (x + ((x - (y * z)) / x)) / (x + 1.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -5.5e+26) or not (z <= 5.5e-27): tmp = (x + (y / t)) / (x + 1.0) else: tmp = (x + ((x - (y * z)) / x)) / (x + 1.0) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -5.5e+26) || !(z <= 5.5e-27)) tmp = Float64(Float64(x + Float64(y / t)) / Float64(x + 1.0)); else tmp = Float64(Float64(x + Float64(Float64(x - Float64(y * z)) / x)) / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -5.5e+26) || ~((z <= 5.5e-27))) tmp = (x + (y / t)) / (x + 1.0); else tmp = (x + ((x - (y * z)) / x)) / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -5.5e+26], N[Not[LessEqual[z, 5.5e-27]], $MachinePrecision]], N[(N[(x + N[(y / t), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \cdot 10^{+26} \lor \neg \left(z \leq 5.5 \cdot 10^{-27}\right):\\
\;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x + \frac{x - y \cdot z}{x}}{x + 1}\\
\end{array}
\end{array}
if z < -5.4999999999999997e26 or 5.5000000000000002e-27 < z Initial program 79.4%
*-commutative79.4%
Simplified79.4%
Taylor expanded in z around inf 89.7%
if -5.4999999999999997e26 < z < 5.5000000000000002e-27Initial program 99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in t around 0 85.0%
fma-neg85.0%
associate-*r/85.0%
neg-mul-185.0%
fma-neg85.0%
*-commutative85.0%
Simplified85.0%
Final simplification87.4%
(FPCore (x y z t) :precision binary64 (if (or (<= z -9.8e+26) (not (<= z 5.6e-28))) (/ (+ x (/ y t)) (+ x 1.0)) (/ (+ x (/ (- x (* y z)) x)) (+ x 1.0))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -9.8e+26) || !(z <= 5.6e-28)) {
tmp = (x + (y / t)) / (x + 1.0);
} else {
tmp = (x + ((x - (y * z)) / 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 ((z <= (-9.8d+26)) .or. (.not. (z <= 5.6d-28))) then
tmp = (x + (y / t)) / (x + 1.0d0)
else
tmp = (x + ((x - (y * z)) / 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 ((z <= -9.8e+26) || !(z <= 5.6e-28)) {
tmp = (x + (y / t)) / (x + 1.0);
} else {
tmp = (x + ((x - (y * z)) / x)) / (x + 1.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -9.8e+26) or not (z <= 5.6e-28): tmp = (x + (y / t)) / (x + 1.0) else: tmp = (x + ((x - (y * z)) / x)) / (x + 1.0) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -9.8e+26) || !(z <= 5.6e-28)) tmp = Float64(Float64(x + Float64(y / t)) / Float64(x + 1.0)); else tmp = Float64(Float64(x + Float64(Float64(x - Float64(y * z)) / x)) / Float64(x + 1.0)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -9.8e+26) || ~((z <= 5.6e-28))) tmp = (x + (y / t)) / (x + 1.0); else tmp = (x + ((x - (y * z)) / x)) / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -9.8e+26], N[Not[LessEqual[z, 5.6e-28]], $MachinePrecision]], N[(N[(x + N[(y / t), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.8 \cdot 10^{+26} \lor \neg \left(z \leq 5.6 \cdot 10^{-28}\right):\\
\;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x + \frac{x - y \cdot z}{x}}{x + 1}\\
\end{array}
\end{array}
if z < -9.79999999999999947e26 or 5.5999999999999996e-28 < z Initial program 79.4%
*-commutative79.4%
Simplified79.4%
Taylor expanded in z around inf 89.7%
if -9.79999999999999947e26 < z < 5.5999999999999996e-28Initial program 99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in t around 0 85.0%
fma-neg85.0%
associate-*r/85.0%
neg-mul-185.0%
fma-neg85.0%
*-commutative85.0%
Simplified85.0%
Taylor expanded in x around 0 85.0%
neg-mul-185.0%
unsub-neg85.0%
Simplified85.0%
Final simplification87.4%
(FPCore (x y z t) :precision binary64 (if (or (<= z -5.9e+26) (not (<= z 9.6e-27))) (/ (+ x (/ y t)) (+ x 1.0)) (+ 1.0 (* y (/ (/ z x) (- -1.0 x))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -5.9e+26) || !(z <= 9.6e-27)) {
tmp = (x + (y / t)) / (x + 1.0);
} else {
tmp = 1.0 + (y * ((z / x) / (-1.0 - 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 <= (-5.9d+26)) .or. (.not. (z <= 9.6d-27))) then
tmp = (x + (y / t)) / (x + 1.0d0)
else
tmp = 1.0d0 + (y * ((z / x) / ((-1.0d0) - x)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -5.9e+26) || !(z <= 9.6e-27)) {
tmp = (x + (y / t)) / (x + 1.0);
} else {
tmp = 1.0 + (y * ((z / x) / (-1.0 - x)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -5.9e+26) or not (z <= 9.6e-27): tmp = (x + (y / t)) / (x + 1.0) else: tmp = 1.0 + (y * ((z / x) / (-1.0 - x))) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -5.9e+26) || !(z <= 9.6e-27)) tmp = Float64(Float64(x + Float64(y / t)) / Float64(x + 1.0)); else tmp = Float64(1.0 + Float64(y * Float64(Float64(z / x) / Float64(-1.0 - x)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -5.9e+26) || ~((z <= 9.6e-27))) tmp = (x + (y / t)) / (x + 1.0); else tmp = 1.0 + (y * ((z / x) / (-1.0 - x))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -5.9e+26], N[Not[LessEqual[z, 9.6e-27]], $MachinePrecision]], N[(N[(x + N[(y / t), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(y * N[(N[(z / x), $MachinePrecision] / N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.9 \cdot 10^{+26} \lor \neg \left(z \leq 9.6 \cdot 10^{-27}\right):\\
\;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;1 + y \cdot \frac{\frac{z}{x}}{-1 - x}\\
\end{array}
\end{array}
if z < -5.9000000000000003e26 or 9.60000000000000008e-27 < z Initial program 79.4%
*-commutative79.4%
Simplified79.4%
Taylor expanded in z around inf 89.7%
if -5.9000000000000003e26 < z < 9.60000000000000008e-27Initial program 99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in t around 0 85.0%
fma-neg85.0%
associate-*r/85.0%
neg-mul-185.0%
fma-neg85.0%
*-commutative85.0%
Simplified85.0%
Taylor expanded in x around 0 85.0%
neg-mul-185.0%
unsub-neg85.0%
Simplified85.0%
Taylor expanded in y around 0 85.0%
rgt-mult-inverse84.8%
mul-1-neg84.8%
associate-/l*84.8%
distribute-rgt-neg-in84.8%
mul-1-neg84.8%
distribute-lft-in84.8%
distribute-rgt-in84.8%
lft-mult-inverse85.0%
mul-1-neg85.0%
distribute-frac-neg85.0%
+-commutative85.0%
distribute-lft-in85.0%
*-rgt-identity85.0%
fma-undefine85.0%
associate-*l/85.0%
distribute-lft-neg-in85.0%
*-commutative85.0%
fma-undefine85.0%
*-rgt-identity85.0%
Simplified85.0%
Final simplification87.4%
(FPCore (x y z t) :precision binary64 (if (<= x -1080000000000.0) 1.0 (if (<= x 2.1e+22) (* (+ x (/ y t)) (/ 1.0 (+ x 1.0))) (/ x (+ x 1.0)))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1080000000000.0) {
tmp = 1.0;
} else if (x <= 2.1e+22) {
tmp = (x + (y / t)) * (1.0 / (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 <= (-1080000000000.0d0)) then
tmp = 1.0d0
else if (x <= 2.1d+22) then
tmp = (x + (y / t)) * (1.0d0 / (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 <= -1080000000000.0) {
tmp = 1.0;
} else if (x <= 2.1e+22) {
tmp = (x + (y / t)) * (1.0 / (x + 1.0));
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -1080000000000.0: tmp = 1.0 elif x <= 2.1e+22: tmp = (x + (y / t)) * (1.0 / (x + 1.0)) else: tmp = x / (x + 1.0) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -1080000000000.0) tmp = 1.0; elseif (x <= 2.1e+22) tmp = Float64(Float64(x + Float64(y / t)) * Float64(1.0 / 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 <= -1080000000000.0) tmp = 1.0; elseif (x <= 2.1e+22) tmp = (x + (y / t)) * (1.0 / (x + 1.0)); else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -1080000000000.0], 1.0, If[LessEqual[x, 2.1e+22], N[(N[(x + N[(y / t), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1080000000000:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{+22}:\\
\;\;\;\;\left(x + \frac{y}{t}\right) \cdot \frac{1}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -1.08e12Initial program 90.6%
*-commutative90.6%
Simplified90.6%
Taylor expanded in z around inf 74.9%
Taylor expanded in x around inf 97.0%
if -1.08e12 < x < 2.0999999999999998e22Initial program 88.4%
*-commutative88.4%
Simplified88.4%
Taylor expanded in z around inf 65.7%
div-inv65.7%
Applied egg-rr65.7%
*-commutative65.7%
+-commutative65.7%
Simplified65.7%
if 2.0999999999999998e22 < x Initial program 89.5%
*-commutative89.5%
Simplified89.5%
Taylor expanded in t around inf 91.2%
+-commutative91.2%
Simplified91.2%
Final simplification79.9%
(FPCore (x y z t) :precision binary64 (if (or (<= x -7.2e-15) (not (<= x 1.65e-59))) (/ x (+ x 1.0)) (* y (/ z (- (* z t) x)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -7.2e-15) || !(x <= 1.65e-59)) {
tmp = x / (x + 1.0);
} else {
tmp = y * (z / ((z * t) - 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 <= (-7.2d-15)) .or. (.not. (x <= 1.65d-59))) then
tmp = x / (x + 1.0d0)
else
tmp = y * (z / ((z * t) - x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -7.2e-15) || !(x <= 1.65e-59)) {
tmp = x / (x + 1.0);
} else {
tmp = y * (z / ((z * t) - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -7.2e-15) or not (x <= 1.65e-59): tmp = x / (x + 1.0) else: tmp = y * (z / ((z * t) - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -7.2e-15) || !(x <= 1.65e-59)) tmp = Float64(x / Float64(x + 1.0)); else tmp = Float64(y * Float64(z / Float64(Float64(z * t) - x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -7.2e-15) || ~((x <= 1.65e-59))) tmp = x / (x + 1.0); else tmp = y * (z / ((z * t) - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -7.2e-15], N[Not[LessEqual[x, 1.65e-59]], $MachinePrecision]], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(y * N[(z / N[(N[(z * t), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.2 \cdot 10^{-15} \lor \neg \left(x \leq 1.65 \cdot 10^{-59}\right):\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{z}{z \cdot t - x}\\
\end{array}
\end{array}
if x < -7.2000000000000002e-15 or 1.64999999999999991e-59 < x Initial program 88.8%
*-commutative88.8%
Simplified88.8%
Taylor expanded in t around inf 86.5%
+-commutative86.5%
Simplified86.5%
if -7.2000000000000002e-15 < x < 1.64999999999999991e-59Initial program 89.8%
*-commutative89.8%
Simplified89.8%
Taylor expanded in y around inf 64.9%
associate-/l*69.4%
associate-/r*69.4%
+-commutative69.4%
Simplified69.4%
Taylor expanded in x around 0 69.3%
Final simplification79.3%
(FPCore (x y z t) :precision binary64 (if (<= x -130000000.0) 1.0 (if (<= x 2.65e+36) (/ (+ x (/ y t)) (+ x 1.0)) (/ x (+ x 1.0)))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -130000000.0) {
tmp = 1.0;
} else if (x <= 2.65e+36) {
tmp = (x + (y / t)) / (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 <= (-130000000.0d0)) then
tmp = 1.0d0
else if (x <= 2.65d+36) then
tmp = (x + (y / t)) / (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 <= -130000000.0) {
tmp = 1.0;
} else if (x <= 2.65e+36) {
tmp = (x + (y / t)) / (x + 1.0);
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -130000000.0: tmp = 1.0 elif x <= 2.65e+36: tmp = (x + (y / t)) / (x + 1.0) else: tmp = x / (x + 1.0) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -130000000.0) tmp = 1.0; elseif (x <= 2.65e+36) tmp = Float64(Float64(x + Float64(y / t)) / 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 <= -130000000.0) tmp = 1.0; elseif (x <= 2.65e+36) tmp = (x + (y / t)) / (x + 1.0); else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -130000000.0], 1.0, If[LessEqual[x, 2.65e+36], N[(N[(x + N[(y / t), $MachinePrecision]), $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 -130000000:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2.65 \cdot 10^{+36}:\\
\;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -1.3e8Initial program 90.6%
*-commutative90.6%
Simplified90.6%
Taylor expanded in z around inf 74.9%
Taylor expanded in x around inf 97.0%
if -1.3e8 < x < 2.65e36Initial program 88.5%
*-commutative88.5%
Simplified88.5%
Taylor expanded in z around inf 65.9%
if 2.65e36 < x Initial program 89.4%
*-commutative89.4%
Simplified89.4%
Taylor expanded in t around inf 91.1%
+-commutative91.1%
Simplified91.1%
(FPCore (x y z t) :precision binary64 (if (<= x -175.0) 1.0 (if (<= x 5.1e-59) (/ y (* t (+ x 1.0))) (/ x (+ x 1.0)))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -175.0) {
tmp = 1.0;
} else if (x <= 5.1e-59) {
tmp = y / (t * (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 <= (-175.0d0)) then
tmp = 1.0d0
else if (x <= 5.1d-59) then
tmp = y / (t * (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 <= -175.0) {
tmp = 1.0;
} else if (x <= 5.1e-59) {
tmp = y / (t * (x + 1.0));
} else {
tmp = x / (x + 1.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -175.0: tmp = 1.0 elif x <= 5.1e-59: tmp = y / (t * (x + 1.0)) else: tmp = x / (x + 1.0) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -175.0) tmp = 1.0; elseif (x <= 5.1e-59) tmp = Float64(y / Float64(t * 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 <= -175.0) tmp = 1.0; elseif (x <= 5.1e-59) tmp = y / (t * (x + 1.0)); else tmp = x / (x + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -175.0], 1.0, If[LessEqual[x, 5.1e-59], N[(y / N[(t * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -175:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 5.1 \cdot 10^{-59}:\\
\;\;\;\;\frac{y}{t \cdot \left(x + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1}\\
\end{array}
\end{array}
if x < -175Initial program 90.6%
*-commutative90.6%
Simplified90.6%
Taylor expanded in z around inf 74.9%
Taylor expanded in x around inf 97.0%
if -175 < x < 5.0999999999999996e-59Initial program 89.4%
*-commutative89.4%
Simplified89.4%
Taylor expanded in z around inf 66.1%
Taylor expanded in y around inf 55.3%
+-commutative55.3%
Simplified55.3%
if 5.0999999999999996e-59 < x Initial program 87.9%
*-commutative87.9%
Simplified87.9%
Taylor expanded in t around inf 81.3%
+-commutative81.3%
Simplified81.3%
(FPCore (x y z t) :precision binary64 (if (or (<= x -5.1e-40) (not (<= x 1.9e-57))) (/ x (+ x 1.0)) (/ y t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -5.1e-40) || !(x <= 1.9e-57)) {
tmp = x / (x + 1.0);
} else {
tmp = y / 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 ((x <= (-5.1d-40)) .or. (.not. (x <= 1.9d-57))) then
tmp = x / (x + 1.0d0)
else
tmp = y / t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -5.1e-40) || !(x <= 1.9e-57)) {
tmp = x / (x + 1.0);
} else {
tmp = y / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -5.1e-40) or not (x <= 1.9e-57): tmp = x / (x + 1.0) else: tmp = y / t return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -5.1e-40) || !(x <= 1.9e-57)) tmp = Float64(x / Float64(x + 1.0)); else tmp = Float64(y / t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -5.1e-40) || ~((x <= 1.9e-57))) tmp = x / (x + 1.0); else tmp = y / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -5.1e-40], N[Not[LessEqual[x, 1.9e-57]], $MachinePrecision]], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(y / t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.1 \cdot 10^{-40} \lor \neg \left(x \leq 1.9 \cdot 10^{-57}\right):\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{t}\\
\end{array}
\end{array}
if x < -5.10000000000000037e-40 or 1.8999999999999999e-57 < x Initial program 89.0%
*-commutative89.0%
Simplified89.0%
Taylor expanded in t around inf 84.9%
+-commutative84.9%
Simplified84.9%
if -5.10000000000000037e-40 < x < 1.8999999999999999e-57Initial program 89.6%
*-commutative89.6%
Simplified89.6%
Taylor expanded in z around inf 67.2%
Taylor expanded in x around 0 56.6%
Final simplification73.3%
(FPCore (x y z t) :precision binary64 (if (<= x -7.5e-54) 1.0 (if (<= x 1.2e-31) (/ y t) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -7.5e-54) {
tmp = 1.0;
} else if (x <= 1.2e-31) {
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 <= (-7.5d-54)) then
tmp = 1.0d0
else if (x <= 1.2d-31) 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 <= -7.5e-54) {
tmp = 1.0;
} else if (x <= 1.2e-31) {
tmp = y / t;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -7.5e-54: tmp = 1.0 elif x <= 1.2e-31: tmp = y / t else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -7.5e-54) tmp = 1.0; elseif (x <= 1.2e-31) 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 <= -7.5e-54) tmp = 1.0; elseif (x <= 1.2e-31) tmp = y / t; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -7.5e-54], 1.0, If[LessEqual[x, 1.2e-31], N[(y / t), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.5 \cdot 10^{-54}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{-31}:\\
\;\;\;\;\frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -7.5000000000000005e-54 or 1.2e-31 < x Initial program 90.1%
*-commutative90.1%
Simplified90.1%
Taylor expanded in z around inf 70.7%
Taylor expanded in x around inf 85.2%
if -7.5000000000000005e-54 < x < 1.2e-31Initial program 87.9%
*-commutative87.9%
Simplified87.9%
Taylor expanded in z around inf 68.6%
Taylor expanded in x around 0 56.2%
(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 89.2%
*-commutative89.2%
Simplified89.2%
Taylor expanded in z around inf 69.8%
Taylor expanded in x around inf 55.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 2024103
(FPCore (x y z t)
:name "Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, A"
:precision binary64
:alt
(/ (+ x (- (/ y (- t (/ x z))) (/ x (- (* t z) x)))) (+ x 1.0))
(/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0)))