
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * ((y - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * ((y - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= z -1e+22) (not (<= z 1.05e+15))) (* x (+ -1.0 (/ y z))) (* (+ (- y z) 1.0) (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1e+22) || !(z <= 1.05e+15)) {
tmp = x * (-1.0 + (y / z));
} else {
tmp = ((y - z) + 1.0) * (x / z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1d+22)) .or. (.not. (z <= 1.05d+15))) then
tmp = x * ((-1.0d0) + (y / z))
else
tmp = ((y - z) + 1.0d0) * (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1e+22) || !(z <= 1.05e+15)) {
tmp = x * (-1.0 + (y / z));
} else {
tmp = ((y - z) + 1.0) * (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1e+22) or not (z <= 1.05e+15): tmp = x * (-1.0 + (y / z)) else: tmp = ((y - z) + 1.0) * (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1e+22) || !(z <= 1.05e+15)) tmp = Float64(x * Float64(-1.0 + Float64(y / z))); else tmp = Float64(Float64(Float64(y - z) + 1.0) * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1e+22) || ~((z <= 1.05e+15))) tmp = x * (-1.0 + (y / z)); else tmp = ((y - z) + 1.0) * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1e+22], N[Not[LessEqual[z, 1.05e+15]], $MachinePrecision]], N[(x * N[(-1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{+22} \lor \neg \left(z \leq 1.05 \cdot 10^{+15}\right):\\
\;\;\;\;x \cdot \left(-1 + \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(y - z\right) + 1\right) \cdot \frac{x}{z}\\
\end{array}
\end{array}
if z < -1e22 or 1.05e15 < z Initial program 70.5%
associate-/l*99.8%
+-commutative99.8%
associate-+r-99.8%
div-sub99.9%
*-inverses99.9%
sub-neg99.9%
metadata-eval99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in y around inf 99.9%
if -1e22 < z < 1.05e15Initial program 99.9%
*-commutative99.9%
associate-/l*99.9%
+-commutative99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= x 2.25e-54) (/ (fma x (- y z) x) z) (* x (+ (/ (+ y 1.0) z) -1.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= 2.25e-54) {
tmp = fma(x, (y - z), x) / z;
} else {
tmp = x * (((y + 1.0) / z) + -1.0);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 2.25e-54) tmp = Float64(fma(x, Float64(y - z), x) / z); else tmp = Float64(x * Float64(Float64(Float64(y + 1.0) / z) + -1.0)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 2.25e-54], N[(N[(x * N[(y - z), $MachinePrecision] + x), $MachinePrecision] / z), $MachinePrecision], N[(x * N[(N[(N[(y + 1.0), $MachinePrecision] / z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.25 \cdot 10^{-54}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y - z, x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\frac{y + 1}{z} + -1\right)\\
\end{array}
\end{array}
if x < 2.2499999999999999e-54Initial program 88.0%
distribute-lft-in88.0%
fma-define88.0%
*-rgt-identity88.0%
Simplified88.0%
if 2.2499999999999999e-54 < x Initial program 80.6%
associate-/l*99.9%
+-commutative99.9%
associate-+r-99.9%
div-sub99.9%
*-inverses99.9%
sub-neg99.9%
metadata-eval99.9%
+-commutative99.9%
Simplified99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ y z))))
(if (<= z -1.3e+115)
(- x)
(if (<= z -6.8e-165)
t_0
(if (<= z 2.5e-275)
(/ x z)
(if (<= z 1.35e-177)
(* y (/ x z))
(if (<= z 2.7e-28) (/ x z) (if (<= z 9.5e+51) t_0 (- x)))))))))
double code(double x, double y, double z) {
double t_0 = x * (y / z);
double tmp;
if (z <= -1.3e+115) {
tmp = -x;
} else if (z <= -6.8e-165) {
tmp = t_0;
} else if (z <= 2.5e-275) {
tmp = x / z;
} else if (z <= 1.35e-177) {
tmp = y * (x / z);
} else if (z <= 2.7e-28) {
tmp = x / z;
} else if (z <= 9.5e+51) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = x * (y / z)
if (z <= (-1.3d+115)) then
tmp = -x
else if (z <= (-6.8d-165)) then
tmp = t_0
else if (z <= 2.5d-275) then
tmp = x / z
else if (z <= 1.35d-177) then
tmp = y * (x / z)
else if (z <= 2.7d-28) then
tmp = x / z
else if (z <= 9.5d+51) then
tmp = t_0
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (y / z);
double tmp;
if (z <= -1.3e+115) {
tmp = -x;
} else if (z <= -6.8e-165) {
tmp = t_0;
} else if (z <= 2.5e-275) {
tmp = x / z;
} else if (z <= 1.35e-177) {
tmp = y * (x / z);
} else if (z <= 2.7e-28) {
tmp = x / z;
} else if (z <= 9.5e+51) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = x * (y / z) tmp = 0 if z <= -1.3e+115: tmp = -x elif z <= -6.8e-165: tmp = t_0 elif z <= 2.5e-275: tmp = x / z elif z <= 1.35e-177: tmp = y * (x / z) elif z <= 2.7e-28: tmp = x / z elif z <= 9.5e+51: tmp = t_0 else: tmp = -x return tmp
function code(x, y, z) t_0 = Float64(x * Float64(y / z)) tmp = 0.0 if (z <= -1.3e+115) tmp = Float64(-x); elseif (z <= -6.8e-165) tmp = t_0; elseif (z <= 2.5e-275) tmp = Float64(x / z); elseif (z <= 1.35e-177) tmp = Float64(y * Float64(x / z)); elseif (z <= 2.7e-28) tmp = Float64(x / z); elseif (z <= 9.5e+51) tmp = t_0; else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (y / z); tmp = 0.0; if (z <= -1.3e+115) tmp = -x; elseif (z <= -6.8e-165) tmp = t_0; elseif (z <= 2.5e-275) tmp = x / z; elseif (z <= 1.35e-177) tmp = y * (x / z); elseif (z <= 2.7e-28) tmp = x / z; elseif (z <= 9.5e+51) tmp = t_0; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.3e+115], (-x), If[LessEqual[z, -6.8e-165], t$95$0, If[LessEqual[z, 2.5e-275], N[(x / z), $MachinePrecision], If[LessEqual[z, 1.35e-177], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.7e-28], N[(x / z), $MachinePrecision], If[LessEqual[z, 9.5e+51], t$95$0, (-x)]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{y}{z}\\
\mathbf{if}\;z \leq -1.3 \cdot 10^{+115}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -6.8 \cdot 10^{-165}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.5 \cdot 10^{-275}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 1.35 \cdot 10^{-177}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{elif}\;z \leq 2.7 \cdot 10^{-28}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 9.5 \cdot 10^{+51}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1.3e115 or 9.4999999999999999e51 < z Initial program 64.6%
associate-/l*99.9%
+-commutative99.9%
associate-+r-99.9%
div-sub99.9%
*-inverses99.9%
sub-neg99.9%
metadata-eval99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in z around inf 81.1%
neg-mul-181.1%
Simplified81.1%
if -1.3e115 < z < -6.8e-165 or 2.6999999999999999e-28 < z < 9.4999999999999999e51Initial program 97.0%
associate-/l*98.3%
+-commutative98.3%
associate-+r-98.3%
div-sub98.3%
*-inverses98.3%
sub-neg98.3%
metadata-eval98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in y around inf 62.6%
associate-/l*63.9%
Simplified63.9%
if -6.8e-165 < z < 2.49999999999999992e-275 or 1.3500000000000001e-177 < z < 2.6999999999999999e-28Initial program 100.0%
associate-/l*94.8%
+-commutative94.8%
associate-+r-94.8%
div-sub94.8%
*-inverses94.8%
sub-neg94.8%
metadata-eval94.8%
+-commutative94.8%
Simplified94.8%
Taylor expanded in y around 0 70.8%
sub-neg70.8%
metadata-eval70.8%
distribute-rgt-in70.8%
associate-*l/70.9%
*-lft-identity70.9%
neg-mul-170.9%
unsub-neg70.9%
Simplified70.9%
Taylor expanded in z around 0 70.9%
if 2.49999999999999992e-275 < z < 1.3500000000000001e-177Initial program 99.7%
associate-/l*79.1%
+-commutative79.1%
associate-+r-79.1%
div-sub79.1%
*-inverses79.1%
sub-neg79.1%
metadata-eval79.1%
+-commutative79.1%
Simplified79.1%
distribute-lft-in79.1%
clear-num79.0%
un-div-inv79.1%
*-commutative79.1%
mul-1-neg79.1%
Applied egg-rr79.1%
Taylor expanded in y around inf 73.8%
associate-*l/74.1%
*-commutative74.1%
Simplified74.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ y z))))
(if (<= z -3.3e+118)
(- x)
(if (<= z -1.62e-167)
t_0
(if (<= z 1.8e-28) (/ x z) (if (<= z 1.5e+53) t_0 (- x)))))))
double code(double x, double y, double z) {
double t_0 = x * (y / z);
double tmp;
if (z <= -3.3e+118) {
tmp = -x;
} else if (z <= -1.62e-167) {
tmp = t_0;
} else if (z <= 1.8e-28) {
tmp = x / z;
} else if (z <= 1.5e+53) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = x * (y / z)
if (z <= (-3.3d+118)) then
tmp = -x
else if (z <= (-1.62d-167)) then
tmp = t_0
else if (z <= 1.8d-28) then
tmp = x / z
else if (z <= 1.5d+53) then
tmp = t_0
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (y / z);
double tmp;
if (z <= -3.3e+118) {
tmp = -x;
} else if (z <= -1.62e-167) {
tmp = t_0;
} else if (z <= 1.8e-28) {
tmp = x / z;
} else if (z <= 1.5e+53) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = x * (y / z) tmp = 0 if z <= -3.3e+118: tmp = -x elif z <= -1.62e-167: tmp = t_0 elif z <= 1.8e-28: tmp = x / z elif z <= 1.5e+53: tmp = t_0 else: tmp = -x return tmp
function code(x, y, z) t_0 = Float64(x * Float64(y / z)) tmp = 0.0 if (z <= -3.3e+118) tmp = Float64(-x); elseif (z <= -1.62e-167) tmp = t_0; elseif (z <= 1.8e-28) tmp = Float64(x / z); elseif (z <= 1.5e+53) tmp = t_0; else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (y / z); tmp = 0.0; if (z <= -3.3e+118) tmp = -x; elseif (z <= -1.62e-167) tmp = t_0; elseif (z <= 1.8e-28) tmp = x / z; elseif (z <= 1.5e+53) tmp = t_0; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.3e+118], (-x), If[LessEqual[z, -1.62e-167], t$95$0, If[LessEqual[z, 1.8e-28], N[(x / z), $MachinePrecision], If[LessEqual[z, 1.5e+53], t$95$0, (-x)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{y}{z}\\
\mathbf{if}\;z \leq -3.3 \cdot 10^{+118}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -1.62 \cdot 10^{-167}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.8 \cdot 10^{-28}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 1.5 \cdot 10^{+53}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -3.3e118 or 1.49999999999999999e53 < z Initial program 64.6%
associate-/l*99.9%
+-commutative99.9%
associate-+r-99.9%
div-sub99.9%
*-inverses99.9%
sub-neg99.9%
metadata-eval99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in z around inf 81.1%
neg-mul-181.1%
Simplified81.1%
if -3.3e118 < z < -1.62e-167 or 1.7999999999999999e-28 < z < 1.49999999999999999e53Initial program 97.0%
associate-/l*98.3%
+-commutative98.3%
associate-+r-98.3%
div-sub98.3%
*-inverses98.3%
sub-neg98.3%
metadata-eval98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in y around inf 62.6%
associate-/l*63.9%
Simplified63.9%
if -1.62e-167 < z < 1.7999999999999999e-28Initial program 99.9%
associate-/l*91.7%
+-commutative91.7%
associate-+r-91.7%
div-sub91.7%
*-inverses91.7%
sub-neg91.7%
metadata-eval91.7%
+-commutative91.7%
Simplified91.7%
Taylor expanded in y around 0 62.7%
sub-neg62.7%
metadata-eval62.7%
distribute-rgt-in62.7%
associate-*l/62.7%
*-lft-identity62.7%
neg-mul-162.7%
unsub-neg62.7%
Simplified62.7%
Taylor expanded in z around 0 62.7%
(FPCore (x y z) :precision binary64 (if (<= z -1.95e+19) (* x (+ -1.0 (/ y z))) (if (<= z 1e-63) (/ (+ x (* x y)) z) (* x (+ (/ (+ y 1.0) z) -1.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.95e+19) {
tmp = x * (-1.0 + (y / z));
} else if (z <= 1e-63) {
tmp = (x + (x * y)) / z;
} else {
tmp = x * (((y + 1.0) / z) + -1.0);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-1.95d+19)) then
tmp = x * ((-1.0d0) + (y / z))
else if (z <= 1d-63) then
tmp = (x + (x * y)) / z
else
tmp = x * (((y + 1.0d0) / z) + (-1.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.95e+19) {
tmp = x * (-1.0 + (y / z));
} else if (z <= 1e-63) {
tmp = (x + (x * y)) / z;
} else {
tmp = x * (((y + 1.0) / z) + -1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.95e+19: tmp = x * (-1.0 + (y / z)) elif z <= 1e-63: tmp = (x + (x * y)) / z else: tmp = x * (((y + 1.0) / z) + -1.0) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.95e+19) tmp = Float64(x * Float64(-1.0 + Float64(y / z))); elseif (z <= 1e-63) tmp = Float64(Float64(x + Float64(x * y)) / z); else tmp = Float64(x * Float64(Float64(Float64(y + 1.0) / z) + -1.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.95e+19) tmp = x * (-1.0 + (y / z)); elseif (z <= 1e-63) tmp = (x + (x * y)) / z; else tmp = x * (((y + 1.0) / z) + -1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.95e+19], N[(x * N[(-1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1e-63], N[(N[(x + N[(x * y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(x * N[(N[(N[(y + 1.0), $MachinePrecision] / z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.95 \cdot 10^{+19}:\\
\;\;\;\;x \cdot \left(-1 + \frac{y}{z}\right)\\
\mathbf{elif}\;z \leq 10^{-63}:\\
\;\;\;\;\frac{x + x \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\frac{y + 1}{z} + -1\right)\\
\end{array}
\end{array}
if z < -1.95e19Initial program 70.8%
associate-/l*99.9%
+-commutative99.9%
associate-+r-99.9%
div-sub99.9%
*-inverses99.9%
sub-neg99.9%
metadata-eval99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in y around inf 99.9%
if -1.95e19 < z < 1.00000000000000007e-63Initial program 99.9%
distribute-lft-in99.9%
fma-define99.9%
*-rgt-identity99.9%
Simplified99.9%
Taylor expanded in z around 0 99.9%
if 1.00000000000000007e-63 < z Initial program 77.3%
associate-/l*99.8%
+-commutative99.8%
associate-+r-99.8%
div-sub99.8%
*-inverses99.8%
sub-neg99.8%
metadata-eval99.8%
+-commutative99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.95e+19) (not (<= z 1.0))) (* x (+ -1.0 (/ y z))) (/ (+ x (* x y)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.95e+19) || !(z <= 1.0)) {
tmp = x * (-1.0 + (y / z));
} else {
tmp = (x + (x * y)) / z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.95d+19)) .or. (.not. (z <= 1.0d0))) then
tmp = x * ((-1.0d0) + (y / z))
else
tmp = (x + (x * y)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.95e+19) || !(z <= 1.0)) {
tmp = x * (-1.0 + (y / z));
} else {
tmp = (x + (x * y)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.95e+19) or not (z <= 1.0): tmp = x * (-1.0 + (y / z)) else: tmp = (x + (x * y)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.95e+19) || !(z <= 1.0)) tmp = Float64(x * Float64(-1.0 + Float64(y / z))); else tmp = Float64(Float64(x + Float64(x * y)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.95e+19) || ~((z <= 1.0))) tmp = x * (-1.0 + (y / z)); else tmp = (x + (x * y)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.95e+19], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(x * N[(-1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(x * y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.95 \cdot 10^{+19} \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x \cdot \left(-1 + \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x + x \cdot y}{z}\\
\end{array}
\end{array}
if z < -1.95e19 or 1 < z Initial program 71.8%
associate-/l*99.8%
+-commutative99.8%
associate-+r-99.8%
div-sub99.9%
*-inverses99.9%
sub-neg99.9%
metadata-eval99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in y around inf 98.8%
if -1.95e19 < z < 1Initial program 99.9%
distribute-lft-in99.9%
fma-define99.9%
*-rgt-identity99.9%
Simplified99.9%
Taylor expanded in z around 0 99.4%
Final simplification99.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (* x (+ -1.0 (/ y z))) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = x * (-1.0 + (y / z));
} else {
tmp = (x / z) - x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-1.0d0)) .or. (.not. (y <= 1.0d0))) then
tmp = x * ((-1.0d0) + (y / z))
else
tmp = (x / z) - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = x * (-1.0 + (y / z));
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.0) or not (y <= 1.0): tmp = x * (-1.0 + (y / z)) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.0) || !(y <= 1.0)) tmp = Float64(x * Float64(-1.0 + Float64(y / z))); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.0) || ~((y <= 1.0))) tmp = x * (-1.0 + (y / z)); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(x * N[(-1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;x \cdot \left(-1 + \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 85.5%
associate-/l*93.6%
+-commutative93.6%
associate-+r-93.6%
div-sub93.6%
*-inverses93.6%
sub-neg93.6%
metadata-eval93.6%
+-commutative93.6%
Simplified93.6%
Taylor expanded in y around inf 92.8%
if -1 < y < 1Initial program 85.8%
associate-/l*99.9%
+-commutative99.9%
associate-+r-99.9%
div-sub99.9%
*-inverses99.9%
sub-neg99.9%
metadata-eval99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 98.8%
sub-neg98.8%
metadata-eval98.8%
distribute-rgt-in98.8%
associate-*l/98.9%
*-lft-identity98.9%
neg-mul-198.9%
unsub-neg98.9%
Simplified98.9%
Final simplification95.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.95e+15) (not (<= y 8e+41))) (/ (* x y) z) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.95e+15) || !(y <= 8e+41)) {
tmp = (x * y) / z;
} else {
tmp = (x / z) - x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-1.95d+15)) .or. (.not. (y <= 8d+41))) then
tmp = (x * y) / z
else
tmp = (x / z) - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.95e+15) || !(y <= 8e+41)) {
tmp = (x * y) / z;
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.95e+15) or not (y <= 8e+41): tmp = (x * y) / z else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.95e+15) || !(y <= 8e+41)) tmp = Float64(Float64(x * y) / z); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.95e+15) || ~((y <= 8e+41))) tmp = (x * y) / z; else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.95e+15], N[Not[LessEqual[y, 8e+41]], $MachinePrecision]], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.95 \cdot 10^{+15} \lor \neg \left(y \leq 8 \cdot 10^{+41}\right):\\
\;\;\;\;\frac{x \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -1.95e15 or 8.00000000000000005e41 < y Initial program 85.6%
associate-/l*93.0%
+-commutative93.0%
associate-+r-93.0%
div-sub93.0%
*-inverses93.0%
sub-neg93.0%
metadata-eval93.0%
+-commutative93.0%
Simplified93.0%
Taylor expanded in y around inf 73.3%
if -1.95e15 < y < 8.00000000000000005e41Initial program 85.6%
associate-/l*99.9%
+-commutative99.9%
associate-+r-99.9%
div-sub99.9%
*-inverses99.9%
sub-neg99.9%
metadata-eval99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 97.5%
sub-neg97.5%
metadata-eval97.5%
distribute-rgt-in97.5%
associate-*l/97.6%
*-lft-identity97.6%
neg-mul-197.6%
unsub-neg97.6%
Simplified97.6%
Final simplification85.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -5.5e+22) (not (<= y 3.4e+38))) (* y (/ x z)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5.5e+22) || !(y <= 3.4e+38)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-5.5d+22)) .or. (.not. (y <= 3.4d+38))) then
tmp = y * (x / z)
else
tmp = (x / z) - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -5.5e+22) || !(y <= 3.4e+38)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5.5e+22) or not (y <= 3.4e+38): tmp = y * (x / z) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5.5e+22) || !(y <= 3.4e+38)) tmp = Float64(y * Float64(x / z)); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -5.5e+22) || ~((y <= 3.4e+38))) tmp = y * (x / z); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5.5e+22], N[Not[LessEqual[y, 3.4e+38]], $MachinePrecision]], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{+22} \lor \neg \left(y \leq 3.4 \cdot 10^{+38}\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -5.50000000000000021e22 or 3.39999999999999996e38 < y Initial program 85.6%
associate-/l*93.0%
+-commutative93.0%
associate-+r-93.0%
div-sub93.0%
*-inverses93.0%
sub-neg93.0%
metadata-eval93.0%
+-commutative93.0%
Simplified93.0%
distribute-lft-in93.0%
clear-num92.9%
un-div-inv93.1%
*-commutative93.1%
mul-1-neg93.1%
Applied egg-rr93.1%
Taylor expanded in y around inf 73.3%
associate-*l/72.1%
*-commutative72.1%
Simplified72.1%
if -5.50000000000000021e22 < y < 3.39999999999999996e38Initial program 85.6%
associate-/l*99.9%
+-commutative99.9%
associate-+r-99.9%
div-sub99.9%
*-inverses99.9%
sub-neg99.9%
metadata-eval99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 97.5%
sub-neg97.5%
metadata-eval97.5%
distribute-rgt-in97.5%
associate-*l/97.6%
*-lft-identity97.6%
neg-mul-197.6%
unsub-neg97.6%
Simplified97.6%
Final simplification85.1%
(FPCore (x y z) :precision binary64 (if (<= x 2e-54) (/ (* x (+ (- y z) 1.0)) z) (* x (+ (/ (+ y 1.0) z) -1.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= 2e-54) {
tmp = (x * ((y - z) + 1.0)) / z;
} else {
tmp = x * (((y + 1.0) / z) + -1.0);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= 2d-54) then
tmp = (x * ((y - z) + 1.0d0)) / z
else
tmp = x * (((y + 1.0d0) / z) + (-1.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 2e-54) {
tmp = (x * ((y - z) + 1.0)) / z;
} else {
tmp = x * (((y + 1.0) / z) + -1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 2e-54: tmp = (x * ((y - z) + 1.0)) / z else: tmp = x * (((y + 1.0) / z) + -1.0) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 2e-54) tmp = Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z); else tmp = Float64(x * Float64(Float64(Float64(y + 1.0) / z) + -1.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 2e-54) tmp = (x * ((y - z) + 1.0)) / z; else tmp = x * (((y + 1.0) / z) + -1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 2e-54], N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(x * N[(N[(N[(y + 1.0), $MachinePrecision] / z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2 \cdot 10^{-54}:\\
\;\;\;\;\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\frac{y + 1}{z} + -1\right)\\
\end{array}
\end{array}
if x < 2.0000000000000001e-54Initial program 88.0%
if 2.0000000000000001e-54 < x Initial program 80.6%
associate-/l*99.9%
+-commutative99.9%
associate-+r-99.9%
div-sub99.9%
*-inverses99.9%
sub-neg99.9%
metadata-eval99.9%
+-commutative99.9%
Simplified99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.95e+19) (not (<= z 1.0))) (- x) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.95e+19) || !(z <= 1.0)) {
tmp = -x;
} else {
tmp = x / z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.95d+19)) .or. (.not. (z <= 1.0d0))) then
tmp = -x
else
tmp = x / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.95e+19) || !(z <= 1.0)) {
tmp = -x;
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.95e+19) or not (z <= 1.0): tmp = -x else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.95e+19) || !(z <= 1.0)) tmp = Float64(-x); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.95e+19) || ~((z <= 1.0))) tmp = -x; else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.95e+19], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], (-x), N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.95 \cdot 10^{+19} \lor \neg \left(z \leq 1\right):\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if z < -1.95e19 or 1 < z Initial program 71.8%
associate-/l*99.8%
+-commutative99.8%
associate-+r-99.8%
div-sub99.9%
*-inverses99.9%
sub-neg99.9%
metadata-eval99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in z around inf 70.9%
neg-mul-170.9%
Simplified70.9%
if -1.95e19 < z < 1Initial program 99.9%
associate-/l*93.2%
+-commutative93.2%
associate-+r-93.2%
div-sub93.2%
*-inverses93.2%
sub-neg93.2%
metadata-eval93.2%
+-commutative93.2%
Simplified93.2%
Taylor expanded in y around 0 54.2%
sub-neg54.2%
metadata-eval54.2%
distribute-rgt-in54.2%
associate-*l/54.2%
*-lft-identity54.2%
neg-mul-154.2%
unsub-neg54.2%
Simplified54.2%
Taylor expanded in z around 0 53.7%
Final simplification62.4%
(FPCore (x y z) :precision binary64 (- x))
double code(double x, double y, double z) {
return -x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -x
end function
public static double code(double x, double y, double z) {
return -x;
}
def code(x, y, z): return -x
function code(x, y, z) return Float64(-x) end
function tmp = code(x, y, z) tmp = -x; end
code[x_, y_, z_] := (-x)
\begin{array}{l}
\\
-x
\end{array}
Initial program 85.6%
associate-/l*96.6%
+-commutative96.6%
associate-+r-96.6%
div-sub96.6%
*-inverses96.6%
sub-neg96.6%
metadata-eval96.6%
+-commutative96.6%
Simplified96.6%
Taylor expanded in z around inf 37.4%
neg-mul-137.4%
Simplified37.4%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 85.6%
associate-/l*96.6%
+-commutative96.6%
associate-+r-96.6%
div-sub96.6%
*-inverses96.6%
sub-neg96.6%
metadata-eval96.6%
+-commutative96.6%
Simplified96.6%
Taylor expanded in z around inf 37.4%
neg-mul-137.4%
Simplified37.4%
neg-sub037.4%
sub-neg37.4%
add-sqr-sqrt18.3%
sqrt-unprod19.5%
sqr-neg19.5%
sqrt-unprod1.8%
add-sqr-sqrt3.1%
Applied egg-rr3.1%
+-lft-identity3.1%
Simplified3.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* (+ 1.0 y) (/ x z)) x)))
(if (< x -2.71483106713436e-162)
t_0
(if (< x 3.874108816439546e-197)
(* (* x (+ (- y z) 1.0)) (/ 1.0 z))
t_0))))
double code(double x, double y, double z) {
double t_0 = ((1.0 + y) * (x / z)) - x;
double tmp;
if (x < -2.71483106713436e-162) {
tmp = t_0;
} else if (x < 3.874108816439546e-197) {
tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = ((1.0d0 + y) * (x / z)) - x
if (x < (-2.71483106713436d-162)) then
tmp = t_0
else if (x < 3.874108816439546d-197) then
tmp = (x * ((y - z) + 1.0d0)) * (1.0d0 / z)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((1.0 + y) * (x / z)) - x;
double tmp;
if (x < -2.71483106713436e-162) {
tmp = t_0;
} else if (x < 3.874108816439546e-197) {
tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = ((1.0 + y) * (x / z)) - x tmp = 0 if x < -2.71483106713436e-162: tmp = t_0 elif x < 3.874108816439546e-197: tmp = (x * ((y - z) + 1.0)) * (1.0 / z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(1.0 + y) * Float64(x / z)) - x) tmp = 0.0 if (x < -2.71483106713436e-162) tmp = t_0; elseif (x < 3.874108816439546e-197) tmp = Float64(Float64(x * Float64(Float64(y - z) + 1.0)) * Float64(1.0 / z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((1.0 + y) * (x / z)) - x; tmp = 0.0; if (x < -2.71483106713436e-162) tmp = t_0; elseif (x < 3.874108816439546e-197) tmp = (x * ((y - z) + 1.0)) * (1.0 / z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(1.0 + y), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]}, If[Less[x, -2.71483106713436e-162], t$95$0, If[Less[x, 3.874108816439546e-197], N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 + y\right) \cdot \frac{x}{z} - x\\
\mathbf{if}\;x < -2.71483106713436 \cdot 10^{-162}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x < 3.874108816439546 \cdot 10^{-197}:\\
\;\;\;\;\left(x \cdot \left(\left(y - z\right) + 1\right)\right) \cdot \frac{1}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
herbie shell --seed 2024144
(FPCore (x y z)
:name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
:precision binary64
:alt
(! :herbie-platform default (if (< x -67870776678359/25000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* (+ 1 y) (/ x z)) x) (if (< x 1937054408219773/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (* (* x (+ (- y z) 1)) (/ 1 z)) (- (* (+ 1 y) (/ x z)) x))))
(/ (* x (+ (- y z) 1.0)) z))