
(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 -2e+36) (not (<= z 3800000000.0))) (- (* x (/ y z)) x) (* (/ x z) (- (+ y 1.0) z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2e+36) || !(z <= 3800000000.0)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x / z) * ((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 <= (-2d+36)) .or. (.not. (z <= 3800000000.0d0))) then
tmp = (x * (y / z)) - x
else
tmp = (x / z) * ((y + 1.0d0) - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2e+36) || !(z <= 3800000000.0)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x / z) * ((y + 1.0) - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2e+36) or not (z <= 3800000000.0): tmp = (x * (y / z)) - x else: tmp = (x / z) * ((y + 1.0) - z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2e+36) || !(z <= 3800000000.0)) tmp = Float64(Float64(x * Float64(y / z)) - x); else tmp = Float64(Float64(x / z) * Float64(Float64(y + 1.0) - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2e+36) || ~((z <= 3800000000.0))) tmp = (x * (y / z)) - x; else tmp = (x / z) * ((y + 1.0) - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2e+36], N[Not[LessEqual[z, 3800000000.0]], $MachinePrecision]], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * N[(N[(y + 1.0), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{+36} \lor \neg \left(z \leq 3800000000\right):\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(\left(y + 1\right) - z\right)\\
\end{array}
\end{array}
if z < -2.00000000000000008e36 or 3.8e9 < z Initial program 72.2%
+-commutative72.2%
sub-neg72.2%
+-commutative72.2%
associate-+r+72.2%
unsub-neg72.2%
associate-+l-72.2%
distribute-lft-out--72.2%
*-rgt-identity72.2%
distribute-rgt-out--70.2%
sub-neg70.2%
+-commutative70.2%
associate--r+70.2%
div-sub70.2%
Simplified93.1%
Taylor expanded in y around inf 93.1%
associate-/l*95.4%
associate-/r/100.0%
Simplified100.0%
if -2.00000000000000008e36 < z < 3.8e9Initial program 99.9%
associate-/l*95.4%
Simplified95.4%
Taylor expanded in x around 0 99.9%
associate-*l/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (- y z) 1.0))) (if (<= (/ (* x t_0) z) 2e+191) (- (/ (fma x y x) z) x) (/ x (/ z t_0)))))
double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if (((x * t_0) / z) <= 2e+191) {
tmp = (fma(x, y, x) / z) - x;
} else {
tmp = x / (z / t_0);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(y - z) + 1.0) tmp = 0.0 if (Float64(Float64(x * t_0) / z) <= 2e+191) tmp = Float64(Float64(fma(x, y, x) / z) - x); else tmp = Float64(x / Float64(z / t_0)); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[N[(N[(x * t$95$0), $MachinePrecision] / z), $MachinePrecision], 2e+191], N[(N[(N[(x * y + x), $MachinePrecision] / z), $MachinePrecision] - x), $MachinePrecision], N[(x / N[(z / t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y - z\right) + 1\\
\mathbf{if}\;\frac{x \cdot t_0}{z} \leq 2 \cdot 10^{+191}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y, x\right)}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{t_0}}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < 2.00000000000000015e191Initial program 93.3%
+-commutative93.3%
sub-neg93.3%
+-commutative93.3%
associate-+r+93.3%
unsub-neg93.3%
associate-+l-93.3%
distribute-lft-out--93.2%
*-rgt-identity93.2%
distribute-rgt-out--92.2%
sub-neg92.2%
+-commutative92.2%
associate--r+92.2%
div-sub92.2%
Simplified99.0%
if 2.00000000000000015e191 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) Initial program 67.7%
associate-/l*99.9%
Simplified99.9%
Final simplification99.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (- y z) 1.0)))
(if (<= (/ (* x t_0) z) 5e-74)
(/ x (/ z t_0))
(* (/ x z) (- (+ y 1.0) z)))))
double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if (((x * t_0) / z) <= 5e-74) {
tmp = x / (z / t_0);
} else {
tmp = (x / z) * ((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) :: t_0
real(8) :: tmp
t_0 = (y - z) + 1.0d0
if (((x * t_0) / z) <= 5d-74) then
tmp = x / (z / t_0)
else
tmp = (x / z) * ((y + 1.0d0) - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if (((x * t_0) / z) <= 5e-74) {
tmp = x / (z / t_0);
} else {
tmp = (x / z) * ((y + 1.0) - z);
}
return tmp;
}
def code(x, y, z): t_0 = (y - z) + 1.0 tmp = 0 if ((x * t_0) / z) <= 5e-74: tmp = x / (z / t_0) else: tmp = (x / z) * ((y + 1.0) - z) return tmp
function code(x, y, z) t_0 = Float64(Float64(y - z) + 1.0) tmp = 0.0 if (Float64(Float64(x * t_0) / z) <= 5e-74) tmp = Float64(x / Float64(z / t_0)); else tmp = Float64(Float64(x / z) * Float64(Float64(y + 1.0) - z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y - z) + 1.0; tmp = 0.0; if (((x * t_0) / z) <= 5e-74) tmp = x / (z / t_0); else tmp = (x / z) * ((y + 1.0) - z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[N[(N[(x * t$95$0), $MachinePrecision] / z), $MachinePrecision], 5e-74], N[(x / N[(z / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * N[(N[(y + 1.0), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y - z\right) + 1\\
\mathbf{if}\;\frac{x \cdot t_0}{z} \leq 5 \cdot 10^{-74}:\\
\;\;\;\;\frac{x}{\frac{z}{t_0}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(\left(y + 1\right) - z\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < 4.99999999999999998e-74Initial program 91.4%
associate-/l*98.7%
Simplified98.7%
if 4.99999999999999998e-74 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) Initial program 82.0%
associate-/l*95.4%
Simplified95.4%
Taylor expanded in x around 0 82.0%
associate-*l/99.8%
Simplified99.8%
Final simplification99.1%
(FPCore (x y z)
:precision binary64
(if (<= z -1.0)
(- x)
(if (<= z 3.45e-65)
(/ x z)
(if (or (<= z 1.5e+50) (and (not (<= z 2.9e+72)) (<= z 3.3e+102)))
(* y (/ x z))
(- x)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = -x;
} else if (z <= 3.45e-65) {
tmp = x / z;
} else if ((z <= 1.5e+50) || (!(z <= 2.9e+72) && (z <= 3.3e+102))) {
tmp = y * (x / z);
} 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) :: tmp
if (z <= (-1.0d0)) then
tmp = -x
else if (z <= 3.45d-65) then
tmp = x / z
else if ((z <= 1.5d+50) .or. (.not. (z <= 2.9d+72)) .and. (z <= 3.3d+102)) then
tmp = y * (x / z)
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = -x;
} else if (z <= 3.45e-65) {
tmp = x / z;
} else if ((z <= 1.5e+50) || (!(z <= 2.9e+72) && (z <= 3.3e+102))) {
tmp = y * (x / z);
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.0: tmp = -x elif z <= 3.45e-65: tmp = x / z elif (z <= 1.5e+50) or (not (z <= 2.9e+72) and (z <= 3.3e+102)): tmp = y * (x / z) else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.0) tmp = Float64(-x); elseif (z <= 3.45e-65) tmp = Float64(x / z); elseif ((z <= 1.5e+50) || (!(z <= 2.9e+72) && (z <= 3.3e+102))) tmp = Float64(y * Float64(x / z)); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.0) tmp = -x; elseif (z <= 3.45e-65) tmp = x / z; elseif ((z <= 1.5e+50) || (~((z <= 2.9e+72)) && (z <= 3.3e+102))) tmp = y * (x / z); else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.0], (-x), If[LessEqual[z, 3.45e-65], N[(x / z), $MachinePrecision], If[Or[LessEqual[z, 1.5e+50], And[N[Not[LessEqual[z, 2.9e+72]], $MachinePrecision], LessEqual[z, 3.3e+102]]], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], (-x)]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 3.45 \cdot 10^{-65}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 1.5 \cdot 10^{+50} \lor \neg \left(z \leq 2.9 \cdot 10^{+72}\right) \land z \leq 3.3 \cdot 10^{+102}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1 or 1.4999999999999999e50 < z < 2.90000000000000017e72 or 3.29999999999999999e102 < z Initial program 71.9%
+-commutative71.9%
sub-neg71.9%
+-commutative71.9%
associate-+r+71.9%
unsub-neg71.9%
associate-+l-71.9%
distribute-lft-out--71.9%
*-rgt-identity71.9%
distribute-rgt-out--69.7%
sub-neg69.7%
+-commutative69.7%
associate--r+69.7%
div-sub69.7%
Simplified94.4%
Taylor expanded in z around inf 82.7%
neg-mul-182.7%
Simplified82.7%
if -1 < z < 3.44999999999999996e-65Initial program 99.9%
Taylor expanded in z around 0 99.0%
Taylor expanded in y around 0 63.2%
if 3.44999999999999996e-65 < z < 1.4999999999999999e50 or 2.90000000000000017e72 < z < 3.29999999999999999e102Initial program 93.9%
associate-/l*96.6%
Simplified96.6%
Taylor expanded in y around inf 68.4%
associate-/r/74.5%
Applied egg-rr74.5%
Final simplification72.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.7e+27) (not (<= y 3.8e-14))) (- (* x (/ y z)) x) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.7e+27) || !(y <= 3.8e-14)) {
tmp = (x * (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 <= (-3.7d+27)) .or. (.not. (y <= 3.8d-14))) then
tmp = (x * (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 <= -3.7e+27) || !(y <= 3.8e-14)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.7e+27) or not (y <= 3.8e-14): tmp = (x * (y / z)) - x else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.7e+27) || !(y <= 3.8e-14)) tmp = Float64(Float64(x * Float64(y / 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 <= -3.7e+27) || ~((y <= 3.8e-14))) tmp = (x * (y / z)) - x; else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.7e+27], N[Not[LessEqual[y, 3.8e-14]], $MachinePrecision]], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.7 \cdot 10^{+27} \lor \neg \left(y \leq 3.8 \cdot 10^{-14}\right):\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -3.70000000000000002e27 or 3.8000000000000002e-14 < y Initial program 89.8%
+-commutative89.8%
sub-neg89.8%
+-commutative89.8%
associate-+r+89.8%
unsub-neg89.8%
associate-+l-89.8%
distribute-lft-out--89.8%
*-rgt-identity89.8%
distribute-rgt-out--88.0%
sub-neg88.0%
+-commutative88.0%
associate--r+88.0%
div-sub88.0%
Simplified93.6%
Taylor expanded in y around inf 92.8%
associate-/l*94.8%
associate-/r/93.6%
Simplified93.6%
if -3.70000000000000002e27 < y < 3.8000000000000002e-14Initial program 85.9%
+-commutative85.9%
sub-neg85.9%
+-commutative85.9%
associate-+r+85.9%
unsub-neg85.9%
associate-+l-85.9%
distribute-lft-out--85.8%
*-rgt-identity85.8%
distribute-rgt-out--85.8%
sub-neg85.8%
+-commutative85.8%
associate--r+85.8%
div-sub85.9%
Simplified100.0%
Taylor expanded in y around 0 99.6%
Final simplification96.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.06) (not (<= z 1.0))) (- (* x (/ y z)) x) (/ (* x (+ y 1.0)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.06) || !(z <= 1.0)) {
tmp = (x * (y / z)) - x;
} 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.06d0)) .or. (.not. (z <= 1.0d0))) then
tmp = (x * (y / z)) - x
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.06) || !(z <= 1.0)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x * (y + 1.0)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.06) or not (z <= 1.0): tmp = (x * (y / z)) - x else: tmp = (x * (y + 1.0)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.06) || !(z <= 1.0)) tmp = Float64(Float64(x * Float64(y / z)) - x); 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.06) || ~((z <= 1.0))) tmp = (x * (y / z)) - x; else tmp = (x * (y + 1.0)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.06], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x * N[(y + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.06 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(y + 1\right)}{z}\\
\end{array}
\end{array}
if z < -1.0600000000000001 or 1 < z Initial program 73.8%
+-commutative73.8%
sub-neg73.8%
+-commutative73.8%
associate-+r+73.8%
unsub-neg73.8%
associate-+l-73.8%
distribute-lft-out--73.8%
*-rgt-identity73.8%
distribute-rgt-out--72.0%
sub-neg72.0%
+-commutative72.0%
associate--r+72.0%
div-sub72.0%
Simplified93.5%
Taylor expanded in y around inf 92.4%
associate-/l*94.5%
associate-/r/98.8%
Simplified98.8%
if -1.0600000000000001 < z < 1Initial program 99.9%
Taylor expanded in z around 0 98.5%
Final simplification98.7%
(FPCore (x y z) :precision binary64 (if (<= y -3.7e+27) (- (* x (/ y z)) x) (if (<= y 3.8e-14) (- (/ x z) x) (- (/ y (/ z x)) x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.7e+27) {
tmp = (x * (y / z)) - x;
} else if (y <= 3.8e-14) {
tmp = (x / z) - x;
} else {
tmp = (y / (z / x)) - 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 <= (-3.7d+27)) then
tmp = (x * (y / z)) - x
else if (y <= 3.8d-14) then
tmp = (x / z) - x
else
tmp = (y / (z / x)) - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -3.7e+27) {
tmp = (x * (y / z)) - x;
} else if (y <= 3.8e-14) {
tmp = (x / z) - x;
} else {
tmp = (y / (z / x)) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.7e+27: tmp = (x * (y / z)) - x elif y <= 3.8e-14: tmp = (x / z) - x else: tmp = (y / (z / x)) - x return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.7e+27) tmp = Float64(Float64(x * Float64(y / z)) - x); elseif (y <= 3.8e-14) tmp = Float64(Float64(x / z) - x); else tmp = Float64(Float64(y / Float64(z / x)) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.7e+27) tmp = (x * (y / z)) - x; elseif (y <= 3.8e-14) tmp = (x / z) - x; else tmp = (y / (z / x)) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.7e+27], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], If[LessEqual[y, 3.8e-14], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.7 \cdot 10^{+27}:\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{-14}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{x}} - x\\
\end{array}
\end{array}
if y < -3.70000000000000002e27Initial program 86.9%
+-commutative86.9%
sub-neg86.9%
+-commutative86.9%
associate-+r+86.9%
unsub-neg86.9%
associate-+l-86.9%
distribute-lft-out--86.9%
*-rgt-identity86.9%
distribute-rgt-out--86.5%
sub-neg86.5%
+-commutative86.5%
associate--r+86.5%
div-sub86.6%
Simplified91.7%
Taylor expanded in y around inf 91.7%
associate-/l*93.3%
associate-/r/93.3%
Simplified93.3%
if -3.70000000000000002e27 < y < 3.8000000000000002e-14Initial program 85.9%
+-commutative85.9%
sub-neg85.9%
+-commutative85.9%
associate-+r+85.9%
unsub-neg85.9%
associate-+l-85.9%
distribute-lft-out--85.8%
*-rgt-identity85.8%
distribute-rgt-out--85.8%
sub-neg85.8%
+-commutative85.8%
associate--r+85.8%
div-sub85.9%
Simplified100.0%
Taylor expanded in y around 0 99.6%
if 3.8000000000000002e-14 < y Initial program 92.5%
+-commutative92.5%
sub-neg92.5%
+-commutative92.5%
associate-+r+92.5%
unsub-neg92.5%
associate-+l-92.5%
distribute-lft-out--92.4%
*-rgt-identity92.4%
distribute-rgt-out--89.3%
sub-neg89.3%
+-commutative89.3%
associate--r+89.3%
div-sub89.3%
Simplified95.4%
Taylor expanded in y around inf 93.7%
associate-/l*96.2%
Simplified96.2%
Final simplification97.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.6e+27) (not (<= y 3.05e+32))) (* y (/ x z)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.6e+27) || !(y <= 3.05e+32)) {
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 <= (-6.6d+27)) .or. (.not. (y <= 3.05d+32))) 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 <= -6.6e+27) || !(y <= 3.05e+32)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.6e+27) or not (y <= 3.05e+32): tmp = y * (x / z) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.6e+27) || !(y <= 3.05e+32)) 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 <= -6.6e+27) || ~((y <= 3.05e+32))) tmp = y * (x / z); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.6e+27], N[Not[LessEqual[y, 3.05e+32]], $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 -6.6 \cdot 10^{+27} \lor \neg \left(y \leq 3.05 \cdot 10^{+32}\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -6.5999999999999996e27 or 3.05000000000000014e32 < y Initial program 90.6%
associate-/l*94.2%
Simplified94.2%
Taylor expanded in y around inf 74.2%
associate-/r/75.5%
Applied egg-rr75.5%
if -6.5999999999999996e27 < y < 3.05000000000000014e32Initial program 85.5%
+-commutative85.5%
sub-neg85.5%
+-commutative85.5%
associate-+r+85.5%
unsub-neg85.5%
associate-+l-85.5%
distribute-lft-out--85.5%
*-rgt-identity85.5%
distribute-rgt-out--85.5%
sub-neg85.5%
+-commutative85.5%
associate--r+85.5%
div-sub85.5%
Simplified100.0%
Taylor expanded in y around 0 97.8%
Final simplification88.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -9.5e+27) (not (<= y 7e+30))) (/ (* x y) z) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -9.5e+27) || !(y <= 7e+30)) {
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 <= (-9.5d+27)) .or. (.not. (y <= 7d+30))) 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 <= -9.5e+27) || !(y <= 7e+30)) {
tmp = (x * y) / z;
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -9.5e+27) or not (y <= 7e+30): tmp = (x * y) / z else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -9.5e+27) || !(y <= 7e+30)) 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 <= -9.5e+27) || ~((y <= 7e+30))) tmp = (x * y) / z; else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -9.5e+27], N[Not[LessEqual[y, 7e+30]], $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 -9.5 \cdot 10^{+27} \lor \neg \left(y \leq 7 \cdot 10^{+30}\right):\\
\;\;\;\;\frac{x \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -9.4999999999999997e27 or 7.00000000000000042e30 < y Initial program 90.6%
Taylor expanded in y around inf 76.4%
if -9.4999999999999997e27 < y < 7.00000000000000042e30Initial program 85.5%
+-commutative85.5%
sub-neg85.5%
+-commutative85.5%
associate-+r+85.5%
unsub-neg85.5%
associate-+l-85.5%
distribute-lft-out--85.5%
*-rgt-identity85.5%
distribute-rgt-out--85.5%
sub-neg85.5%
+-commutative85.5%
associate--r+85.5%
div-sub85.5%
Simplified100.0%
Taylor expanded in y around 0 97.8%
Final simplification88.3%
(FPCore (x y z) :precision binary64 (if (<= y -2.6e+28) (/ x (/ z y)) (if (<= y 1.2e+33) (- (/ x z) x) (* y (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.6e+28) {
tmp = x / (z / y);
} else if (y <= 1.2e+33) {
tmp = (x / z) - x;
} else {
tmp = y * (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 (y <= (-2.6d+28)) then
tmp = x / (z / y)
else if (y <= 1.2d+33) then
tmp = (x / z) - x
else
tmp = y * (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.6e+28) {
tmp = x / (z / y);
} else if (y <= 1.2e+33) {
tmp = (x / z) - x;
} else {
tmp = y * (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.6e+28: tmp = x / (z / y) elif y <= 1.2e+33: tmp = (x / z) - x else: tmp = y * (x / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.6e+28) tmp = Float64(x / Float64(z / y)); elseif (y <= 1.2e+33) tmp = Float64(Float64(x / z) - x); else tmp = Float64(y * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.6e+28) tmp = x / (z / y); elseif (y <= 1.2e+33) tmp = (x / z) - x; else tmp = y * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.6e+28], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.2e+33], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.6 \cdot 10^{+28}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{+33}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\end{array}
\end{array}
if y < -2.6000000000000002e28Initial program 86.9%
associate-/l*93.9%
Simplified93.9%
Taylor expanded in y around inf 71.1%
if -2.6000000000000002e28 < y < 1.2e33Initial program 85.5%
+-commutative85.5%
sub-neg85.5%
+-commutative85.5%
associate-+r+85.5%
unsub-neg85.5%
associate-+l-85.5%
distribute-lft-out--85.5%
*-rgt-identity85.5%
distribute-rgt-out--85.5%
sub-neg85.5%
+-commutative85.5%
associate--r+85.5%
div-sub85.5%
Simplified100.0%
Taylor expanded in y around 0 97.8%
if 1.2e33 < y Initial program 94.6%
associate-/l*94.5%
Simplified94.5%
Taylor expanded in y around inf 77.4%
associate-/r/80.7%
Applied egg-rr80.7%
Final simplification88.1%
(FPCore (x y z) :precision binary64 (if (<= z -1.0) (- x) (if (<= z 3900000000.0) (/ x z) (- x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = -x;
} else if (z <= 3900000000.0) {
tmp = x / z;
} 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) :: tmp
if (z <= (-1.0d0)) then
tmp = -x
else if (z <= 3900000000.0d0) then
tmp = x / z
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = -x;
} else if (z <= 3900000000.0) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.0: tmp = -x elif z <= 3900000000.0: tmp = x / z else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.0) tmp = Float64(-x); elseif (z <= 3900000000.0) tmp = Float64(x / z); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.0) tmp = -x; elseif (z <= 3900000000.0) tmp = x / z; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.0], (-x), If[LessEqual[z, 3900000000.0], N[(x / z), $MachinePrecision], (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 3900000000:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1 or 3.9e9 < z Initial program 73.6%
+-commutative73.6%
sub-neg73.6%
+-commutative73.6%
associate-+r+73.6%
unsub-neg73.6%
associate-+l-73.6%
distribute-lft-out--73.6%
*-rgt-identity73.6%
distribute-rgt-out--71.7%
sub-neg71.7%
+-commutative71.7%
associate--r+71.7%
div-sub71.7%
Simplified93.5%
Taylor expanded in z around inf 76.6%
neg-mul-176.6%
Simplified76.6%
if -1 < z < 3.9e9Initial program 99.9%
Taylor expanded in z around 0 98.5%
Taylor expanded in y around 0 58.4%
Final simplification66.8%
(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 87.8%
+-commutative87.8%
sub-neg87.8%
+-commutative87.8%
associate-+r+87.8%
unsub-neg87.8%
associate-+l-87.8%
distribute-lft-out--87.8%
*-rgt-identity87.8%
distribute-rgt-out--86.9%
sub-neg86.9%
+-commutative86.9%
associate--r+86.9%
div-sub86.9%
Simplified96.9%
Taylor expanded in z around inf 37.0%
neg-mul-137.0%
Simplified37.0%
Final simplification37.0%
(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 2023178
(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))