
(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 10 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 -0.08) (not (<= z 6e-69))) (* x (+ (/ (+ y 1.0) z) -1.0)) (* (+ y 1.0) (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.08) || !(z <= 6e-69)) {
tmp = x * (((y + 1.0) / z) + -1.0);
} else {
tmp = (y + 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 <= (-0.08d0)) .or. (.not. (z <= 6d-69))) then
tmp = x * (((y + 1.0d0) / z) + (-1.0d0))
else
tmp = (y + 1.0d0) * (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.08) || !(z <= 6e-69)) {
tmp = x * (((y + 1.0) / z) + -1.0);
} else {
tmp = (y + 1.0) * (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.08) or not (z <= 6e-69): tmp = x * (((y + 1.0) / z) + -1.0) else: tmp = (y + 1.0) * (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.08) || !(z <= 6e-69)) tmp = Float64(x * Float64(Float64(Float64(y + 1.0) / z) + -1.0)); else tmp = Float64(Float64(y + 1.0) * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.08) || ~((z <= 6e-69))) tmp = x * (((y + 1.0) / z) + -1.0); else tmp = (y + 1.0) * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.08], N[Not[LessEqual[z, 6e-69]], $MachinePrecision]], N[(x * N[(N[(N[(y + 1.0), $MachinePrecision] / z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(y + 1.0), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.08 \lor \neg \left(z \leq 6 \cdot 10^{-69}\right):\\
\;\;\;\;x \cdot \left(\frac{y + 1}{z} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y + 1\right) \cdot \frac{x}{z}\\
\end{array}
\end{array}
if z < -0.0800000000000000017 or 5.99999999999999978e-69 < z Initial program 76.9%
Taylor expanded in x around 0 76.9%
associate--l+76.9%
+-commutative76.9%
associate-*r/99.8%
+-commutative99.8%
associate--l+99.8%
div-sub99.8%
sub-neg99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
if -0.0800000000000000017 < z < 5.99999999999999978e-69Initial program 99.9%
Taylor expanded in z around 0 99.9%
associate-/l*92.9%
associate-/r/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= z -1.75e+74)
(- x)
(if (<= z -1.55e-18)
t_0
(if (<= z -1.82e-190)
(/ x z)
(if (<= z 2e-256)
t_0
(if (<= z 1.08e-131)
(/ x z)
(if (<= z 2.4e-95)
t_0
(if (<= z 2e-68)
(/ x z)
(if (or (<= z 4.8e+32)
(and (not (<= z 1.58e+72)) (<= z 2.4e+117)))
t_0
(- x)))))))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -1.75e+74) {
tmp = -x;
} else if (z <= -1.55e-18) {
tmp = t_0;
} else if (z <= -1.82e-190) {
tmp = x / z;
} else if (z <= 2e-256) {
tmp = t_0;
} else if (z <= 1.08e-131) {
tmp = x / z;
} else if (z <= 2.4e-95) {
tmp = t_0;
} else if (z <= 2e-68) {
tmp = x / z;
} else if ((z <= 4.8e+32) || (!(z <= 1.58e+72) && (z <= 2.4e+117))) {
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 <= (-1.75d+74)) then
tmp = -x
else if (z <= (-1.55d-18)) then
tmp = t_0
else if (z <= (-1.82d-190)) then
tmp = x / z
else if (z <= 2d-256) then
tmp = t_0
else if (z <= 1.08d-131) then
tmp = x / z
else if (z <= 2.4d-95) then
tmp = t_0
else if (z <= 2d-68) then
tmp = x / z
else if ((z <= 4.8d+32) .or. (.not. (z <= 1.58d+72)) .and. (z <= 2.4d+117)) 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 <= -1.75e+74) {
tmp = -x;
} else if (z <= -1.55e-18) {
tmp = t_0;
} else if (z <= -1.82e-190) {
tmp = x / z;
} else if (z <= 2e-256) {
tmp = t_0;
} else if (z <= 1.08e-131) {
tmp = x / z;
} else if (z <= 2.4e-95) {
tmp = t_0;
} else if (z <= 2e-68) {
tmp = x / z;
} else if ((z <= 4.8e+32) || (!(z <= 1.58e+72) && (z <= 2.4e+117))) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if z <= -1.75e+74: tmp = -x elif z <= -1.55e-18: tmp = t_0 elif z <= -1.82e-190: tmp = x / z elif z <= 2e-256: tmp = t_0 elif z <= 1.08e-131: tmp = x / z elif z <= 2.4e-95: tmp = t_0 elif z <= 2e-68: tmp = x / z elif (z <= 4.8e+32) or (not (z <= 1.58e+72) and (z <= 2.4e+117)): 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 <= -1.75e+74) tmp = Float64(-x); elseif (z <= -1.55e-18) tmp = t_0; elseif (z <= -1.82e-190) tmp = Float64(x / z); elseif (z <= 2e-256) tmp = t_0; elseif (z <= 1.08e-131) tmp = Float64(x / z); elseif (z <= 2.4e-95) tmp = t_0; elseif (z <= 2e-68) tmp = Float64(x / z); elseif ((z <= 4.8e+32) || (!(z <= 1.58e+72) && (z <= 2.4e+117))) 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 <= -1.75e+74) tmp = -x; elseif (z <= -1.55e-18) tmp = t_0; elseif (z <= -1.82e-190) tmp = x / z; elseif (z <= 2e-256) tmp = t_0; elseif (z <= 1.08e-131) tmp = x / z; elseif (z <= 2.4e-95) tmp = t_0; elseif (z <= 2e-68) tmp = x / z; elseif ((z <= 4.8e+32) || (~((z <= 1.58e+72)) && (z <= 2.4e+117))) 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, -1.75e+74], (-x), If[LessEqual[z, -1.55e-18], t$95$0, If[LessEqual[z, -1.82e-190], N[(x / z), $MachinePrecision], If[LessEqual[z, 2e-256], t$95$0, If[LessEqual[z, 1.08e-131], N[(x / z), $MachinePrecision], If[LessEqual[z, 2.4e-95], t$95$0, If[LessEqual[z, 2e-68], N[(x / z), $MachinePrecision], If[Or[LessEqual[z, 4.8e+32], And[N[Not[LessEqual[z, 1.58e+72]], $MachinePrecision], LessEqual[z, 2.4e+117]]], t$95$0, (-x)]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -1.75 \cdot 10^{+74}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -1.55 \cdot 10^{-18}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1.82 \cdot 10^{-190}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 2 \cdot 10^{-256}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.08 \cdot 10^{-131}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 2.4 \cdot 10^{-95}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2 \cdot 10^{-68}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 4.8 \cdot 10^{+32} \lor \neg \left(z \leq 1.58 \cdot 10^{+72}\right) \land z \leq 2.4 \cdot 10^{+117}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1.75000000000000007e74 or 4.79999999999999983e32 < z < 1.58000000000000006e72 or 2.3999999999999999e117 < z Initial program 68.0%
Taylor expanded in z around inf 84.4%
mul-1-neg84.4%
Simplified84.4%
if -1.75000000000000007e74 < z < -1.55000000000000003e-18 or -1.82000000000000006e-190 < z < 1.99999999999999995e-256 or 1.07999999999999996e-131 < z < 2.4e-95 or 2.00000000000000013e-68 < z < 4.79999999999999983e32 or 1.58000000000000006e72 < z < 2.3999999999999999e117Initial program 96.8%
Taylor expanded in y around inf 69.3%
associate-/l*65.2%
associate-/r/70.9%
Simplified70.9%
if -1.55000000000000003e-18 < z < -1.82000000000000006e-190 or 1.99999999999999995e-256 < z < 1.07999999999999996e-131 or 2.4e-95 < z < 2.00000000000000013e-68Initial program 99.9%
Taylor expanded in y around 0 75.5%
associate-/l*75.5%
Simplified75.5%
Taylor expanded in z around 0 75.5%
Final simplification77.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.6%
Taylor expanded in x around 0 85.6%
associate--l+85.6%
+-commutative85.6%
associate-*r/93.5%
+-commutative93.5%
associate--l+93.5%
div-sub93.5%
sub-neg93.5%
*-inverses93.5%
metadata-eval93.5%
Simplified93.5%
Taylor expanded in y around inf 92.5%
if -1 < y < 1Initial program 89.5%
Taylor expanded in x around 0 89.5%
associate--l+89.5%
+-commutative89.5%
associate-*r/99.8%
+-commutative99.8%
associate--l+99.8%
div-sub99.8%
sub-neg99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 98.9%
sub-neg98.9%
metadata-eval98.9%
distribute-rgt-in98.9%
associate-*l/99.1%
*-lft-identity99.1%
neg-mul-199.1%
unsub-neg99.1%
Simplified99.1%
Final simplification95.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.98) (not (<= z 1.0))) (* x (+ -1.0 (/ y z))) (* (+ y 1.0) (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.98) || !(z <= 1.0)) {
tmp = x * (-1.0 + (y / z));
} else {
tmp = (y + 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 <= (-0.98d0)) .or. (.not. (z <= 1.0d0))) then
tmp = x * ((-1.0d0) + (y / z))
else
tmp = (y + 1.0d0) * (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.98) || !(z <= 1.0)) {
tmp = x * (-1.0 + (y / z));
} else {
tmp = (y + 1.0) * (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.98) or not (z <= 1.0): tmp = x * (-1.0 + (y / z)) else: tmp = (y + 1.0) * (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.98) || !(z <= 1.0)) tmp = Float64(x * Float64(-1.0 + Float64(y / z))); else tmp = Float64(Float64(y + 1.0) * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.98) || ~((z <= 1.0))) tmp = x * (-1.0 + (y / z)); else tmp = (y + 1.0) * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.98], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(x * N[(-1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y + 1.0), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.98 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x \cdot \left(-1 + \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y + 1\right) \cdot \frac{x}{z}\\
\end{array}
\end{array}
if z < -0.97999999999999998 or 1 < z Initial program 73.6%
Taylor expanded in x around 0 73.6%
associate--l+73.6%
+-commutative73.6%
associate-*r/99.8%
+-commutative99.8%
associate--l+99.8%
div-sub99.8%
sub-neg99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 98.4%
if -0.97999999999999998 < z < 1Initial program 99.9%
Taylor expanded in z around 0 98.7%
associate-/l*92.5%
associate-/r/98.7%
Simplified98.7%
Final simplification98.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -8000.0) (not (<= y 4.7e+173))) (* y (/ x z)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -8000.0) || !(y <= 4.7e+173)) {
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 <= (-8000.0d0)) .or. (.not. (y <= 4.7d+173))) 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 <= -8000.0) || !(y <= 4.7e+173)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -8000.0) or not (y <= 4.7e+173): tmp = y * (x / z) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -8000.0) || !(y <= 4.7e+173)) 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 <= -8000.0) || ~((y <= 4.7e+173))) tmp = y * (x / z); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -8000.0], N[Not[LessEqual[y, 4.7e+173]], $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 -8000 \lor \neg \left(y \leq 4.7 \cdot 10^{+173}\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -8e3 or 4.70000000000000015e173 < y Initial program 86.6%
Taylor expanded in y around inf 77.2%
associate-/l*76.4%
associate-/r/80.0%
Simplified80.0%
if -8e3 < y < 4.70000000000000015e173Initial program 88.0%
Taylor expanded in x around 0 88.0%
associate--l+88.0%
+-commutative88.0%
associate-*r/98.7%
+-commutative98.7%
associate--l+98.7%
div-sub98.7%
sub-neg98.7%
*-inverses98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in y around 0 88.5%
sub-neg88.5%
metadata-eval88.5%
distribute-rgt-in88.5%
associate-*l/88.6%
*-lft-identity88.6%
neg-mul-188.6%
unsub-neg88.6%
Simplified88.6%
Final simplification85.5%
(FPCore (x y z) :precision binary64 (if (<= y -105000.0) (* y (/ x z)) (if (<= y 4.7e+173) (- (/ x z) x) (/ x (/ z y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -105000.0) {
tmp = y * (x / z);
} else if (y <= 4.7e+173) {
tmp = (x / z) - x;
} else {
tmp = x / (z / y);
}
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 <= (-105000.0d0)) then
tmp = y * (x / z)
else if (y <= 4.7d+173) then
tmp = (x / z) - x
else
tmp = x / (z / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -105000.0) {
tmp = y * (x / z);
} else if (y <= 4.7e+173) {
tmp = (x / z) - x;
} else {
tmp = x / (z / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -105000.0: tmp = y * (x / z) elif y <= 4.7e+173: tmp = (x / z) - x else: tmp = x / (z / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -105000.0) tmp = Float64(y * Float64(x / z)); elseif (y <= 4.7e+173) tmp = Float64(Float64(x / z) - x); else tmp = Float64(x / Float64(z / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -105000.0) tmp = y * (x / z); elseif (y <= 4.7e+173) tmp = (x / z) - x; else tmp = x / (z / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -105000.0], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.7e+173], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -105000:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{elif}\;y \leq 4.7 \cdot 10^{+173}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\
\end{array}
\end{array}
if y < -105000Initial program 86.1%
Taylor expanded in y around inf 73.5%
associate-/l*72.1%
associate-/r/77.7%
Simplified77.7%
if -105000 < y < 4.70000000000000015e173Initial program 88.0%
Taylor expanded in x around 0 88.0%
associate--l+88.0%
+-commutative88.0%
associate-*r/98.7%
+-commutative98.7%
associate--l+98.7%
div-sub98.7%
sub-neg98.7%
*-inverses98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in y around 0 88.5%
sub-neg88.5%
metadata-eval88.5%
distribute-rgt-in88.5%
associate-*l/88.6%
*-lft-identity88.6%
neg-mul-188.6%
unsub-neg88.6%
Simplified88.6%
if 4.70000000000000015e173 < y Initial program 87.6%
Taylor expanded in y around inf 84.6%
associate-/l*84.8%
Simplified84.8%
Final simplification85.5%
(FPCore (x y z) :precision binary64 (if (<= x 9.2e-42) (/ (* 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 <= 9.2e-42) {
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 <= 9.2d-42) 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 <= 9.2e-42) {
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 <= 9.2e-42: 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 <= 9.2e-42) 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 <= 9.2e-42) 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, 9.2e-42], 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 9.2 \cdot 10^{-42}:\\
\;\;\;\;\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 < 9.20000000000000015e-42Initial program 90.3%
if 9.20000000000000015e-42 < x Initial program 79.8%
Taylor expanded in x around 0 79.8%
associate--l+79.8%
+-commutative79.8%
associate-*r/99.8%
+-commutative99.8%
associate--l+99.8%
div-sub99.8%
sub-neg99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification92.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.65e-18) (not (<= z 1.75))) (- x) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.65e-18) || !(z <= 1.75)) {
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 <= (-2.65d-18)) .or. (.not. (z <= 1.75d0))) 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 <= -2.65e-18) || !(z <= 1.75)) {
tmp = -x;
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.65e-18) or not (z <= 1.75): tmp = -x else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.65e-18) || !(z <= 1.75)) tmp = Float64(-x); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.65e-18) || ~((z <= 1.75))) tmp = -x; else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.65e-18], N[Not[LessEqual[z, 1.75]], $MachinePrecision]], (-x), N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.65 \cdot 10^{-18} \lor \neg \left(z \leq 1.75\right):\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if z < -2.65000000000000015e-18 or 1.75 < z Initial program 74.1%
Taylor expanded in z around inf 69.1%
mul-1-neg69.1%
Simplified69.1%
if -2.65000000000000015e-18 < z < 1.75Initial program 99.9%
Taylor expanded in y around 0 61.4%
associate-/l*61.4%
Simplified61.4%
Taylor expanded in z around 0 60.2%
Final simplification64.5%
(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.5%
Taylor expanded in z around inf 34.9%
mul-1-neg34.9%
Simplified34.9%
Final simplification34.9%
(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 87.5%
Taylor expanded in z around inf 25.6%
associate-*r*25.6%
mul-1-neg25.6%
Simplified25.6%
div-inv25.6%
associate-*l*34.8%
div-inv34.9%
*-inverses34.9%
*-commutative34.9%
*-un-lft-identity34.9%
neg-sub034.9%
sub-neg34.9%
add-sqr-sqrt17.6%
sqrt-unprod18.3%
sqr-neg18.3%
sqrt-unprod1.3%
add-sqr-sqrt3.1%
Applied egg-rr3.1%
+-lft-identity3.1%
Simplified3.1%
Final simplification3.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 2024030
(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))