
(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 12 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 -1.85e-13) (not (<= z 1.22e-17))) (* x (+ (/ (+ y 1.0) z) -1.0)) (/ (* x (+ y 1.0)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.85e-13) || !(z <= 1.22e-17)) {
tmp = x * (((y + 1.0) / z) + -1.0);
} else {
tmp = (x * (y + 1.0)) / 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.85d-13)) .or. (.not. (z <= 1.22d-17))) then
tmp = x * (((y + 1.0d0) / z) + (-1.0d0))
else
tmp = (x * (y + 1.0d0)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.85e-13) || !(z <= 1.22e-17)) {
tmp = x * (((y + 1.0) / z) + -1.0);
} else {
tmp = (x * (y + 1.0)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.85e-13) or not (z <= 1.22e-17): tmp = x * (((y + 1.0) / z) + -1.0) else: tmp = (x * (y + 1.0)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.85e-13) || !(z <= 1.22e-17)) tmp = Float64(x * Float64(Float64(Float64(y + 1.0) / z) + -1.0)); else tmp = Float64(Float64(x * Float64(y + 1.0)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.85e-13) || ~((z <= 1.22e-17))) tmp = x * (((y + 1.0) / z) + -1.0); else tmp = (x * (y + 1.0)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.85e-13], N[Not[LessEqual[z, 1.22e-17]], $MachinePrecision]], N[(x * N[(N[(N[(y + 1.0), $MachinePrecision] / z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(y + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.85 \cdot 10^{-13} \lor \neg \left(z \leq 1.22 \cdot 10^{-17}\right):\\
\;\;\;\;x \cdot \left(\frac{y + 1}{z} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(y + 1\right)}{z}\\
\end{array}
\end{array}
if z < -1.84999999999999994e-13 or 1.22e-17 < z Initial program 80.9%
Taylor expanded in x around 0 80.9%
associate--l+80.9%
+-commutative80.9%
associate-*r/99.9%
+-commutative99.9%
associate--l+99.9%
div-sub100.0%
sub-neg100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
if -1.84999999999999994e-13 < z < 1.22e-17Initial program 99.9%
Taylor expanded in z around 0 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= x 4e-49) (/ (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 <= 4e-49) {
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 <= 4e-49) 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, 4e-49], 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 4 \cdot 10^{-49}:\\
\;\;\;\;\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 < 3.99999999999999975e-49Initial program 93.7%
distribute-lft-in93.7%
fma-def93.7%
*-rgt-identity93.7%
Simplified93.7%
if 3.99999999999999975e-49 < x Initial program 80.8%
Taylor expanded in x around 0 80.8%
associate--l+80.8%
+-commutative80.8%
associate-*r/99.9%
+-commutative99.9%
associate--l+99.9%
div-sub100.0%
sub-neg100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification95.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= z -4400000000000.0)
(- x)
(if (<= z 9.5e-230)
t_0
(if (<= z 3.8e-215)
(/ x z)
(if (<= z 2.75e-117)
t_0
(if (<= z 2.5e-65) (/ x z) (if (<= z 4.8e+42) t_0 (- x)))))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -4400000000000.0) {
tmp = -x;
} else if (z <= 9.5e-230) {
tmp = t_0;
} else if (z <= 3.8e-215) {
tmp = x / z;
} else if (z <= 2.75e-117) {
tmp = t_0;
} else if (z <= 2.5e-65) {
tmp = x / z;
} else if (z <= 4.8e+42) {
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 = y * (x / z)
if (z <= (-4400000000000.0d0)) then
tmp = -x
else if (z <= 9.5d-230) then
tmp = t_0
else if (z <= 3.8d-215) then
tmp = x / z
else if (z <= 2.75d-117) then
tmp = t_0
else if (z <= 2.5d-65) then
tmp = x / z
else if (z <= 4.8d+42) 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 = y * (x / z);
double tmp;
if (z <= -4400000000000.0) {
tmp = -x;
} else if (z <= 9.5e-230) {
tmp = t_0;
} else if (z <= 3.8e-215) {
tmp = x / z;
} else if (z <= 2.75e-117) {
tmp = t_0;
} else if (z <= 2.5e-65) {
tmp = x / z;
} else if (z <= 4.8e+42) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if z <= -4400000000000.0: tmp = -x elif z <= 9.5e-230: tmp = t_0 elif z <= 3.8e-215: tmp = x / z elif z <= 2.75e-117: tmp = t_0 elif z <= 2.5e-65: tmp = x / z elif z <= 4.8e+42: tmp = t_0 else: tmp = -x return tmp
function code(x, y, z) t_0 = Float64(y * Float64(x / z)) tmp = 0.0 if (z <= -4400000000000.0) tmp = Float64(-x); elseif (z <= 9.5e-230) tmp = t_0; elseif (z <= 3.8e-215) tmp = Float64(x / z); elseif (z <= 2.75e-117) tmp = t_0; elseif (z <= 2.5e-65) tmp = Float64(x / z); elseif (z <= 4.8e+42) tmp = t_0; else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (x / z); tmp = 0.0; if (z <= -4400000000000.0) tmp = -x; elseif (z <= 9.5e-230) tmp = t_0; elseif (z <= 3.8e-215) tmp = x / z; elseif (z <= 2.75e-117) tmp = t_0; elseif (z <= 2.5e-65) tmp = x / z; elseif (z <= 4.8e+42) tmp = t_0; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4400000000000.0], (-x), If[LessEqual[z, 9.5e-230], t$95$0, If[LessEqual[z, 3.8e-215], N[(x / z), $MachinePrecision], If[LessEqual[z, 2.75e-117], t$95$0, If[LessEqual[z, 2.5e-65], N[(x / z), $MachinePrecision], If[LessEqual[z, 4.8e+42], t$95$0, (-x)]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -4400000000000:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 9.5 \cdot 10^{-230}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 3.8 \cdot 10^{-215}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 2.75 \cdot 10^{-117}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.5 \cdot 10^{-65}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 4.8 \cdot 10^{+42}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -4.4e12 or 4.7999999999999997e42 < z Initial program 78.4%
Taylor expanded in z around inf 80.4%
mul-1-neg80.4%
Simplified80.4%
if -4.4e12 < z < 9.5000000000000004e-230 or 3.79999999999999977e-215 < z < 2.75000000000000013e-117 or 2.49999999999999991e-65 < z < 4.7999999999999997e42Initial program 99.8%
Taylor expanded in y around inf 64.8%
associate-/l*54.7%
associate-/r/71.9%
Simplified71.9%
if 9.5000000000000004e-230 < z < 3.79999999999999977e-215 or 2.75000000000000013e-117 < z < 2.49999999999999991e-65Initial program 100.0%
Taylor expanded in z around 0 100.0%
Taylor expanded in y around 0 81.8%
Final simplification76.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.0) (not (<= y 3.35e-46))) (* x (+ -1.0 (/ y z))) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 3.35e-46)) {
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 <= 3.35d-46))) 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 <= 3.35e-46)) {
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 <= 3.35e-46): 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 <= 3.35e-46)) 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 <= 3.35e-46))) 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, 3.35e-46]], $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 3.35 \cdot 10^{-46}\right):\\
\;\;\;\;x \cdot \left(-1 + \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -1 or 3.35e-46 < y Initial program 91.1%
Taylor expanded in x around 0 91.1%
associate--l+91.1%
+-commutative91.1%
associate-*r/89.8%
+-commutative89.8%
associate--l+89.8%
div-sub89.8%
sub-neg89.8%
*-inverses89.8%
metadata-eval89.8%
Simplified89.8%
Taylor expanded in y around inf 88.8%
if -1 < y < 3.35e-46Initial program 88.8%
Taylor expanded in x around 0 88.8%
associate--l+88.8%
+-commutative88.8%
associate-*r/99.9%
+-commutative99.9%
associate--l+99.9%
div-sub100.0%
sub-neg100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 99.5%
Taylor expanded in z around 0 99.5%
neg-mul-199.5%
+-commutative99.5%
unsub-neg99.5%
Simplified99.5%
Final simplification94.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -22000000000.0) (not (<= z 0.007))) (* x (+ -1.0 (/ y z))) (* x (/ (+ y 1.0) z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -22000000000.0) || !(z <= 0.007)) {
tmp = x * (-1.0 + (y / z));
} else {
tmp = x * ((y + 1.0) / 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 <= (-22000000000.0d0)) .or. (.not. (z <= 0.007d0))) then
tmp = x * ((-1.0d0) + (y / z))
else
tmp = x * ((y + 1.0d0) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -22000000000.0) || !(z <= 0.007)) {
tmp = x * (-1.0 + (y / z));
} else {
tmp = x * ((y + 1.0) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -22000000000.0) or not (z <= 0.007): tmp = x * (-1.0 + (y / z)) else: tmp = x * ((y + 1.0) / z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -22000000000.0) || !(z <= 0.007)) tmp = Float64(x * Float64(-1.0 + Float64(y / z))); else tmp = Float64(x * Float64(Float64(y + 1.0) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -22000000000.0) || ~((z <= 0.007))) tmp = x * (-1.0 + (y / z)); else tmp = x * ((y + 1.0) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -22000000000.0], N[Not[LessEqual[z, 0.007]], $MachinePrecision]], N[(x * N[(-1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(y + 1.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -22000000000 \lor \neg \left(z \leq 0.007\right):\\
\;\;\;\;x \cdot \left(-1 + \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y + 1}{z}\\
\end{array}
\end{array}
if z < -2.2e10 or 0.00700000000000000015 < z Initial program 80.1%
Taylor expanded in x around 0 80.1%
associate--l+80.1%
+-commutative80.1%
associate-*r/99.9%
+-commutative99.9%
associate--l+99.9%
div-sub100.0%
sub-neg100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 99.2%
if -2.2e10 < z < 0.00700000000000000015Initial program 99.9%
Taylor expanded in z around 0 99.3%
*-commutative99.3%
associate-*l/89.1%
Applied egg-rr89.1%
Final simplification94.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -22000000000.0) (not (<= z 0.007))) (* x (+ -1.0 (/ y z))) (/ (* x (+ y 1.0)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -22000000000.0) || !(z <= 0.007)) {
tmp = x * (-1.0 + (y / z));
} else {
tmp = (x * (y + 1.0)) / 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 <= (-22000000000.0d0)) .or. (.not. (z <= 0.007d0))) then
tmp = x * ((-1.0d0) + (y / z))
else
tmp = (x * (y + 1.0d0)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -22000000000.0) || !(z <= 0.007)) {
tmp = x * (-1.0 + (y / z));
} else {
tmp = (x * (y + 1.0)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -22000000000.0) or not (z <= 0.007): tmp = x * (-1.0 + (y / z)) else: tmp = (x * (y + 1.0)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -22000000000.0) || !(z <= 0.007)) tmp = Float64(x * Float64(-1.0 + Float64(y / z))); else tmp = Float64(Float64(x * Float64(y + 1.0)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -22000000000.0) || ~((z <= 0.007))) tmp = x * (-1.0 + (y / z)); else tmp = (x * (y + 1.0)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -22000000000.0], N[Not[LessEqual[z, 0.007]], $MachinePrecision]], N[(x * N[(-1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(y + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -22000000000 \lor \neg \left(z \leq 0.007\right):\\
\;\;\;\;x \cdot \left(-1 + \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(y + 1\right)}{z}\\
\end{array}
\end{array}
if z < -2.2e10 or 0.00700000000000000015 < z Initial program 80.1%
Taylor expanded in x around 0 80.1%
associate--l+80.1%
+-commutative80.1%
associate-*r/99.9%
+-commutative99.9%
associate--l+99.9%
div-sub100.0%
sub-neg100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 99.2%
if -2.2e10 < z < 0.00700000000000000015Initial program 99.9%
Taylor expanded in z around 0 99.3%
Final simplification99.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -1920000.0) (not (<= y 0.00023))) (* y (/ x z)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1920000.0) || !(y <= 0.00023)) {
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 <= (-1920000.0d0)) .or. (.not. (y <= 0.00023d0))) 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 <= -1920000.0) || !(y <= 0.00023)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1920000.0) or not (y <= 0.00023): tmp = y * (x / z) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1920000.0) || !(y <= 0.00023)) 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 <= -1920000.0) || ~((y <= 0.00023))) tmp = y * (x / z); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1920000.0], N[Not[LessEqual[y, 0.00023]], $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 -1920000 \lor \neg \left(y \leq 0.00023\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -1.92e6 or 2.3000000000000001e-4 < y Initial program 91.6%
Taylor expanded in y around inf 77.9%
associate-/l*70.9%
associate-/r/77.5%
Simplified77.5%
if -1.92e6 < y < 2.3000000000000001e-4Initial program 88.4%
Taylor expanded in x around 0 88.4%
associate--l+88.4%
+-commutative88.4%
associate-*r/99.9%
+-commutative99.9%
associate--l+99.9%
div-sub100.0%
sub-neg100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 99.5%
Taylor expanded in z around 0 99.5%
neg-mul-199.5%
+-commutative99.5%
unsub-neg99.5%
Simplified99.5%
Final simplification88.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -1100000.0) (not (<= y 0.00023))) (/ y (/ z x)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1100000.0) || !(y <= 0.00023)) {
tmp = y / (z / x);
} 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 <= (-1100000.0d0)) .or. (.not. (y <= 0.00023d0))) then
tmp = y / (z / x)
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 <= -1100000.0) || !(y <= 0.00023)) {
tmp = y / (z / x);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1100000.0) or not (y <= 0.00023): tmp = y / (z / x) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1100000.0) || !(y <= 0.00023)) tmp = Float64(y / Float64(z / x)); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1100000.0) || ~((y <= 0.00023))) tmp = y / (z / x); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1100000.0], N[Not[LessEqual[y, 0.00023]], $MachinePrecision]], N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1100000 \lor \neg \left(y \leq 0.00023\right):\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -1.1e6 or 2.3000000000000001e-4 < y Initial program 91.6%
Taylor expanded in y around inf 77.9%
associate-/l*70.9%
associate-/r/77.5%
Simplified77.5%
*-commutative77.5%
clear-num77.4%
un-div-inv77.6%
Applied egg-rr77.6%
if -1.1e6 < y < 2.3000000000000001e-4Initial program 88.4%
Taylor expanded in x around 0 88.4%
associate--l+88.4%
+-commutative88.4%
associate-*r/99.9%
+-commutative99.9%
associate--l+99.9%
div-sub100.0%
sub-neg100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 99.5%
Taylor expanded in z around 0 99.5%
neg-mul-199.5%
+-commutative99.5%
unsub-neg99.5%
Simplified99.5%
Final simplification88.7%
(FPCore (x y z) :precision binary64 (if (<= y -1850000.0) (/ y (/ z x)) (if (<= y 0.00023) (- (/ x z) x) (/ (* x y) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1850000.0) {
tmp = y / (z / x);
} else if (y <= 0.00023) {
tmp = (x / z) - x;
} else {
tmp = (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 (y <= (-1850000.0d0)) then
tmp = y / (z / x)
else if (y <= 0.00023d0) then
tmp = (x / z) - x
else
tmp = (x * y) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1850000.0) {
tmp = y / (z / x);
} else if (y <= 0.00023) {
tmp = (x / z) - x;
} else {
tmp = (x * y) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1850000.0: tmp = y / (z / x) elif y <= 0.00023: tmp = (x / z) - x else: tmp = (x * y) / z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1850000.0) tmp = Float64(y / Float64(z / x)); elseif (y <= 0.00023) tmp = Float64(Float64(x / z) - x); else tmp = Float64(Float64(x * y) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1850000.0) tmp = y / (z / x); elseif (y <= 0.00023) tmp = (x / z) - x; else tmp = (x * y) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1850000.0], N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 0.00023], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1850000:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\
\mathbf{elif}\;y \leq 0.00023:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\end{array}
\end{array}
if y < -1.85e6Initial program 88.5%
Taylor expanded in y around inf 68.6%
associate-/l*60.8%
associate-/r/69.6%
Simplified69.6%
*-commutative69.6%
clear-num69.5%
un-div-inv69.7%
Applied egg-rr69.7%
if -1.85e6 < y < 2.3000000000000001e-4Initial program 88.4%
Taylor expanded in x around 0 88.4%
associate--l+88.4%
+-commutative88.4%
associate-*r/99.9%
+-commutative99.9%
associate--l+99.9%
div-sub100.0%
sub-neg100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 99.5%
Taylor expanded in z around 0 99.5%
neg-mul-199.5%
+-commutative99.5%
unsub-neg99.5%
Simplified99.5%
if 2.3000000000000001e-4 < y Initial program 93.6%
Taylor expanded in y around inf 84.0%
Final simplification89.1%
(FPCore (x y z) :precision binary64 (if (<= x 1.22e-46) (/ (* 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 <= 1.22e-46) {
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 <= 1.22d-46) 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 <= 1.22e-46) {
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 <= 1.22e-46: 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 <= 1.22e-46) 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 <= 1.22e-46) 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, 1.22e-46], 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 1.22 \cdot 10^{-46}:\\
\;\;\;\;\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 < 1.22e-46Initial program 93.7%
if 1.22e-46 < x Initial program 80.8%
Taylor expanded in x around 0 80.8%
associate--l+80.8%
+-commutative80.8%
associate-*r/99.9%
+-commutative99.9%
associate--l+99.9%
div-sub100.0%
sub-neg100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification95.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 3.7e-17))) (- x) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 3.7e-17)) {
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.0d0)) .or. (.not. (z <= 3.7d-17))) 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.0) || !(z <= 3.7e-17)) {
tmp = -x;
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 3.7e-17): tmp = -x else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 3.7e-17)) 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.0) || ~((z <= 3.7e-17))) tmp = -x; else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 3.7e-17]], $MachinePrecision]], (-x), N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 3.7 \cdot 10^{-17}\right):\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if z < -1 or 3.6999999999999997e-17 < z Initial program 80.8%
Taylor expanded in z around inf 72.6%
mul-1-neg72.6%
Simplified72.6%
if -1 < z < 3.6999999999999997e-17Initial program 99.9%
Taylor expanded in z around 0 99.4%
Taylor expanded in y around 0 52.7%
Final simplification63.1%
(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 90.0%
Taylor expanded in z around inf 39.2%
mul-1-neg39.2%
Simplified39.2%
Final simplification39.2%
(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 2024031
(FPCore (x y z)
:name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
:precision binary64
:herbie-target
(if (< x -2.71483106713436e-162) (- (* (+ 1.0 y) (/ x z)) x) (if (< x 3.874108816439546e-197) (* (* x (+ (- y z) 1.0)) (/ 1.0 z)) (- (* (+ 1.0 y) (/ x z)) x)))
(/ (* x (+ (- y z) 1.0)) z))