
(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
(let* ((t_0 (+ (- y z) 1.0)))
(if (or (<= z -4.1e+37) (not (<= z 1e-16)))
(* x (/ t_0 z))
(* t_0 (/ x z)))))
double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if ((z <= -4.1e+37) || !(z <= 1e-16)) {
tmp = x * (t_0 / z);
} else {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = (y - z) + 1.0d0
if ((z <= (-4.1d+37)) .or. (.not. (z <= 1d-16))) then
tmp = x * (t_0 / z)
else
tmp = t_0 * (x / 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 ((z <= -4.1e+37) || !(z <= 1e-16)) {
tmp = x * (t_0 / z);
} else {
tmp = t_0 * (x / z);
}
return tmp;
}
def code(x, y, z): t_0 = (y - z) + 1.0 tmp = 0 if (z <= -4.1e+37) or not (z <= 1e-16): tmp = x * (t_0 / z) else: tmp = t_0 * (x / z) return tmp
function code(x, y, z) t_0 = Float64(Float64(y - z) + 1.0) tmp = 0.0 if ((z <= -4.1e+37) || !(z <= 1e-16)) tmp = Float64(x * Float64(t_0 / z)); else tmp = Float64(t_0 * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y - z) + 1.0; tmp = 0.0; if ((z <= -4.1e+37) || ~((z <= 1e-16))) tmp = x * (t_0 / z); else tmp = t_0 * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]}, If[Or[LessEqual[z, -4.1e+37], N[Not[LessEqual[z, 1e-16]], $MachinePrecision]], N[(x * N[(t$95$0 / z), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(x / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y - z\right) + 1\\
\mathbf{if}\;z \leq -4.1 \cdot 10^{+37} \lor \neg \left(z \leq 10^{-16}\right):\\
\;\;\;\;x \cdot \frac{t\_0}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{x}{z}\\
\end{array}
\end{array}
if z < -4.0999999999999998e37 or 9.9999999999999998e-17 < z Initial program 72.6%
associate-/l*99.9%
Simplified99.9%
if -4.0999999999999998e37 < z < 9.9999999999999998e-17Initial program 99.2%
*-commutative99.2%
associate-/l*99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= z -2.2e+58)
(- x)
(if (<= z -1.22e-155)
t_0
(if (<= z 1.6e-265)
(/ x z)
(if (<= z 2.8e-195)
t_0
(if (<= z 1.85e-26)
(/ x z)
(if (<= z 5e+67) (* x (/ y z)) (- x)))))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -2.2e+58) {
tmp = -x;
} else if (z <= -1.22e-155) {
tmp = t_0;
} else if (z <= 1.6e-265) {
tmp = x / z;
} else if (z <= 2.8e-195) {
tmp = t_0;
} else if (z <= 1.85e-26) {
tmp = x / z;
} else if (z <= 5e+67) {
tmp = x * (y / 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) :: t_0
real(8) :: tmp
t_0 = y * (x / z)
if (z <= (-2.2d+58)) then
tmp = -x
else if (z <= (-1.22d-155)) then
tmp = t_0
else if (z <= 1.6d-265) then
tmp = x / z
else if (z <= 2.8d-195) then
tmp = t_0
else if (z <= 1.85d-26) then
tmp = x / z
else if (z <= 5d+67) then
tmp = x * (y / z)
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 <= -2.2e+58) {
tmp = -x;
} else if (z <= -1.22e-155) {
tmp = t_0;
} else if (z <= 1.6e-265) {
tmp = x / z;
} else if (z <= 2.8e-195) {
tmp = t_0;
} else if (z <= 1.85e-26) {
tmp = x / z;
} else if (z <= 5e+67) {
tmp = x * (y / z);
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if z <= -2.2e+58: tmp = -x elif z <= -1.22e-155: tmp = t_0 elif z <= 1.6e-265: tmp = x / z elif z <= 2.8e-195: tmp = t_0 elif z <= 1.85e-26: tmp = x / z elif z <= 5e+67: tmp = x * (y / z) else: tmp = -x return tmp
function code(x, y, z) t_0 = Float64(y * Float64(x / z)) tmp = 0.0 if (z <= -2.2e+58) tmp = Float64(-x); elseif (z <= -1.22e-155) tmp = t_0; elseif (z <= 1.6e-265) tmp = Float64(x / z); elseif (z <= 2.8e-195) tmp = t_0; elseif (z <= 1.85e-26) tmp = Float64(x / z); elseif (z <= 5e+67) tmp = Float64(x * Float64(y / z)); 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 <= -2.2e+58) tmp = -x; elseif (z <= -1.22e-155) tmp = t_0; elseif (z <= 1.6e-265) tmp = x / z; elseif (z <= 2.8e-195) tmp = t_0; elseif (z <= 1.85e-26) tmp = x / z; elseif (z <= 5e+67) tmp = x * (y / z); 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, -2.2e+58], (-x), If[LessEqual[z, -1.22e-155], t$95$0, If[LessEqual[z, 1.6e-265], N[(x / z), $MachinePrecision], If[LessEqual[z, 2.8e-195], t$95$0, If[LessEqual[z, 1.85e-26], N[(x / z), $MachinePrecision], If[LessEqual[z, 5e+67], N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision], (-x)]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -2.2 \cdot 10^{+58}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -1.22 \cdot 10^{-155}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.6 \cdot 10^{-265}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{-195}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.85 \cdot 10^{-26}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 5 \cdot 10^{+67}:\\
\;\;\;\;x \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -2.2000000000000001e58 or 4.99999999999999976e67 < z Initial program 70.5%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around inf 78.9%
neg-mul-178.9%
Simplified78.9%
if -2.2000000000000001e58 < z < -1.22000000000000001e-155 or 1.6e-265 < z < 2.80000000000000003e-195Initial program 95.6%
associate-/l*92.3%
Simplified92.3%
Taylor expanded in y around inf 70.4%
*-commutative70.4%
associate-/l*75.4%
Applied egg-rr75.4%
if -1.22000000000000001e-155 < z < 1.6e-265 or 2.80000000000000003e-195 < z < 1.8499999999999999e-26Initial program 99.9%
associate-/l*94.9%
Simplified94.9%
Taylor expanded in z around 0 99.9%
associate-/l*94.9%
Simplified94.9%
Taylor expanded in y around 0 70.0%
if 1.8499999999999999e-26 < z < 4.99999999999999976e67Initial program 93.3%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in y around inf 59.7%
associate-/l*66.1%
Simplified66.1%
Final simplification74.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ y z))))
(if (<= z -1.55e+59)
(- x)
(if (<= z -8e-148)
t_0
(if (<= z 3.5e-36) (/ x z) (if (<= z 4.5e+67) t_0 (- x)))))))
double code(double x, double y, double z) {
double t_0 = x * (y / z);
double tmp;
if (z <= -1.55e+59) {
tmp = -x;
} else if (z <= -8e-148) {
tmp = t_0;
} else if (z <= 3.5e-36) {
tmp = x / z;
} else if (z <= 4.5e+67) {
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.55d+59)) then
tmp = -x
else if (z <= (-8d-148)) then
tmp = t_0
else if (z <= 3.5d-36) then
tmp = x / z
else if (z <= 4.5d+67) 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.55e+59) {
tmp = -x;
} else if (z <= -8e-148) {
tmp = t_0;
} else if (z <= 3.5e-36) {
tmp = x / z;
} else if (z <= 4.5e+67) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = x * (y / z) tmp = 0 if z <= -1.55e+59: tmp = -x elif z <= -8e-148: tmp = t_0 elif z <= 3.5e-36: tmp = x / z elif z <= 4.5e+67: 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.55e+59) tmp = Float64(-x); elseif (z <= -8e-148) tmp = t_0; elseif (z <= 3.5e-36) tmp = Float64(x / z); elseif (z <= 4.5e+67) 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.55e+59) tmp = -x; elseif (z <= -8e-148) tmp = t_0; elseif (z <= 3.5e-36) tmp = x / z; elseif (z <= 4.5e+67) 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.55e+59], (-x), If[LessEqual[z, -8e-148], t$95$0, If[LessEqual[z, 3.5e-36], N[(x / z), $MachinePrecision], If[LessEqual[z, 4.5e+67], t$95$0, (-x)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{y}{z}\\
\mathbf{if}\;z \leq -1.55 \cdot 10^{+59}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -8 \cdot 10^{-148}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 3.5 \cdot 10^{-36}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 4.5 \cdot 10^{+67}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1.55000000000000007e59 or 4.4999999999999998e67 < z Initial program 70.5%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around inf 78.9%
neg-mul-178.9%
Simplified78.9%
if -1.55000000000000007e59 < z < -7.99999999999999949e-148 or 3.5e-36 < z < 4.4999999999999998e67Initial program 93.7%
associate-/l*98.1%
Simplified98.1%
Taylor expanded in y around inf 67.1%
associate-/l*71.5%
Simplified71.5%
if -7.99999999999999949e-148 < z < 3.5e-36Initial program 99.9%
associate-/l*91.9%
Simplified91.9%
Taylor expanded in z around 0 99.9%
associate-/l*91.9%
Simplified91.9%
Taylor expanded in y around 0 65.4%
Final simplification72.2%
(FPCore (x y z) :precision binary64 (if (<= y -2.8e+44) (* y (/ x z)) (if (<= y 2.5e+22) (- (/ x z) x) (* x (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.8e+44) {
tmp = y * (x / z);
} else if (y <= 2.5e+22) {
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 <= (-2.8d+44)) then
tmp = y * (x / z)
else if (y <= 2.5d+22) 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 <= -2.8e+44) {
tmp = y * (x / z);
} else if (y <= 2.5e+22) {
tmp = (x / z) - x;
} else {
tmp = x * (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.8e+44: tmp = y * (x / z) elif y <= 2.5e+22: tmp = (x / z) - x else: tmp = x * (y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.8e+44) tmp = Float64(y * Float64(x / z)); elseif (y <= 2.5e+22) tmp = Float64(Float64(x / z) - x); else tmp = Float64(x * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.8e+44) tmp = y * (x / z); elseif (y <= 2.5e+22) tmp = (x / z) - x; else tmp = x * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.8e+44], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.5e+22], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.8 \cdot 10^{+44}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{+22}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < -2.8000000000000001e44Initial program 87.1%
associate-/l*92.7%
Simplified92.7%
Taylor expanded in y around inf 73.9%
*-commutative73.9%
associate-/l*77.2%
Applied egg-rr77.2%
if -2.8000000000000001e44 < y < 2.4999999999999998e22Initial program 82.5%
associate-/l*99.8%
Simplified99.8%
clear-num99.8%
un-div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 96.6%
Taylor expanded in z around 0 96.6%
neg-mul-196.6%
+-commutative96.6%
unsub-neg96.6%
Simplified96.6%
if 2.4999999999999998e22 < y Initial program 96.4%
associate-/l*93.1%
Simplified93.1%
Taylor expanded in y around inf 86.9%
associate-/l*81.7%
Simplified81.7%
Final simplification88.4%
(FPCore (x y z) :precision binary64 (if (<= y -2.8e+44) (* y (/ x z)) (if (<= y 3e+23) (- (/ x z) x) (/ x (/ z y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.8e+44) {
tmp = y * (x / z);
} else if (y <= 3e+23) {
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 <= (-2.8d+44)) then
tmp = y * (x / z)
else if (y <= 3d+23) 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 <= -2.8e+44) {
tmp = y * (x / z);
} else if (y <= 3e+23) {
tmp = (x / z) - x;
} else {
tmp = x / (z / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.8e+44: tmp = y * (x / z) elif y <= 3e+23: tmp = (x / z) - x else: tmp = x / (z / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.8e+44) tmp = Float64(y * Float64(x / z)); elseif (y <= 3e+23) 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 <= -2.8e+44) tmp = y * (x / z); elseif (y <= 3e+23) tmp = (x / z) - x; else tmp = x / (z / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.8e+44], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3e+23], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.8 \cdot 10^{+44}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{elif}\;y \leq 3 \cdot 10^{+23}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\
\end{array}
\end{array}
if y < -2.8000000000000001e44Initial program 87.1%
associate-/l*92.7%
Simplified92.7%
Taylor expanded in y around inf 73.9%
*-commutative73.9%
associate-/l*77.2%
Applied egg-rr77.2%
if -2.8000000000000001e44 < y < 3.0000000000000001e23Initial program 82.5%
associate-/l*99.8%
Simplified99.8%
clear-num99.8%
un-div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 96.6%
Taylor expanded in z around 0 96.6%
neg-mul-196.6%
+-commutative96.6%
unsub-neg96.6%
Simplified96.6%
if 3.0000000000000001e23 < y Initial program 96.4%
associate-/l*93.1%
Simplified93.1%
clear-num93.0%
un-div-inv93.1%
Applied egg-rr93.1%
Taylor expanded in y around inf 81.8%
Final simplification88.4%
(FPCore (x y z) :precision binary64 (if (<= y -2.8e+44) (* y (/ x z)) (if (<= y 3.3e+22) (- (/ x z) x) (/ (* x y) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.8e+44) {
tmp = y * (x / z);
} else if (y <= 3.3e+22) {
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 <= (-2.8d+44)) then
tmp = y * (x / z)
else if (y <= 3.3d+22) 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 <= -2.8e+44) {
tmp = y * (x / z);
} else if (y <= 3.3e+22) {
tmp = (x / z) - x;
} else {
tmp = (x * y) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.8e+44: tmp = y * (x / z) elif y <= 3.3e+22: tmp = (x / z) - x else: tmp = (x * y) / z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.8e+44) tmp = Float64(y * Float64(x / z)); elseif (y <= 3.3e+22) 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 <= -2.8e+44) tmp = y * (x / z); elseif (y <= 3.3e+22) tmp = (x / z) - x; else tmp = (x * y) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.8e+44], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.3e+22], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.8 \cdot 10^{+44}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{elif}\;y \leq 3.3 \cdot 10^{+22}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\end{array}
\end{array}
if y < -2.8000000000000001e44Initial program 87.1%
associate-/l*92.7%
Simplified92.7%
Taylor expanded in y around inf 73.9%
*-commutative73.9%
associate-/l*77.2%
Applied egg-rr77.2%
if -2.8000000000000001e44 < y < 3.2999999999999998e22Initial program 82.5%
associate-/l*99.8%
Simplified99.8%
clear-num99.8%
un-div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 96.6%
Taylor expanded in z around 0 96.6%
neg-mul-196.6%
+-commutative96.6%
unsub-neg96.6%
Simplified96.6%
if 3.2999999999999998e22 < y Initial program 96.4%
associate-/l*93.1%
Simplified93.1%
Taylor expanded in y around inf 86.9%
Final simplification89.5%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (- y z) 1.0))) (if (<= x 3.2e+21) (/ (* x t_0) z) (/ x (/ z t_0)))))
double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if (x <= 3.2e+21) {
tmp = (x * t_0) / z;
} else {
tmp = x / (z / 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 = (y - z) + 1.0d0
if (x <= 3.2d+21) then
tmp = (x * t_0) / z
else
tmp = x / (z / t_0)
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 <= 3.2e+21) {
tmp = (x * t_0) / z;
} else {
tmp = x / (z / t_0);
}
return tmp;
}
def code(x, y, z): t_0 = (y - z) + 1.0 tmp = 0 if x <= 3.2e+21: tmp = (x * t_0) / z 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 (x <= 3.2e+21) tmp = Float64(Float64(x * t_0) / z); else tmp = Float64(x / Float64(z / t_0)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y - z) + 1.0; tmp = 0.0; if (x <= 3.2e+21) tmp = (x * t_0) / z; else tmp = x / (z / t_0); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, 3.2e+21], N[(N[(x * t$95$0), $MachinePrecision] / z), $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}\;x \leq 3.2 \cdot 10^{+21}:\\
\;\;\;\;\frac{x \cdot t\_0}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{t\_0}}\\
\end{array}
\end{array}
if x < 3.2e21Initial program 91.8%
if 3.2e21 < x Initial program 69.8%
associate-/l*99.8%
Simplified99.8%
clear-num99.9%
un-div-inv99.9%
Applied egg-rr99.9%
Final simplification93.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.00024) (not (<= z 5e-17))) (- x) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.00024) || !(z <= 5e-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 <= (-0.00024d0)) .or. (.not. (z <= 5d-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 <= -0.00024) || !(z <= 5e-17)) {
tmp = -x;
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.00024) or not (z <= 5e-17): tmp = -x else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.00024) || !(z <= 5e-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 <= -0.00024) || ~((z <= 5e-17))) tmp = -x; else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.00024], N[Not[LessEqual[z, 5e-17]], $MachinePrecision]], (-x), N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.00024 \lor \neg \left(z \leq 5 \cdot 10^{-17}\right):\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if z < -2.40000000000000006e-4 or 4.9999999999999999e-17 < z Initial program 74.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in z around inf 65.9%
neg-mul-165.9%
Simplified65.9%
if -2.40000000000000006e-4 < z < 4.9999999999999999e-17Initial program 99.9%
associate-/l*92.8%
Simplified92.8%
Taylor expanded in z around 0 99.9%
associate-/l*92.8%
Simplified92.8%
Taylor expanded in y around 0 57.2%
Final simplification61.8%
(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(x * Float64(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[(x * N[(N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{\left(y - z\right) + 1}{z}
\end{array}
Initial program 86.8%
associate-/l*96.5%
Simplified96.5%
Final simplification96.5%
(FPCore (x y z) :precision binary64 (/ x (/ z (+ (- y z) 1.0))))
double code(double x, double y, double z) {
return x / (z / ((y - z) + 1.0));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x / (z / ((y - z) + 1.0d0))
end function
public static double code(double x, double y, double z) {
return x / (z / ((y - z) + 1.0));
}
def code(x, y, z): return x / (z / ((y - z) + 1.0))
function code(x, y, z) return Float64(x / Float64(z / Float64(Float64(y - z) + 1.0))) end
function tmp = code(x, y, z) tmp = x / (z / ((y - z) + 1.0)); end
code[x_, y_, z_] := N[(x / N[(z / N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{\frac{z}{\left(y - z\right) + 1}}
\end{array}
Initial program 86.8%
associate-/l*96.5%
Simplified96.5%
clear-num96.4%
un-div-inv96.9%
Applied egg-rr96.9%
Final simplification96.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 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 86.8%
associate-/l*96.5%
Simplified96.5%
Taylor expanded in z around inf 35.9%
neg-mul-135.9%
Simplified35.9%
Final simplification35.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 86.8%
Taylor expanded in z around inf 25.6%
mul-1-neg25.6%
distribute-rgt-neg-in25.6%
Simplified25.6%
associate-/l*35.9%
add-sqr-sqrt18.3%
sqrt-unprod10.8%
sqr-neg10.8%
sqrt-unprod1.8%
add-sqr-sqrt3.1%
Applied egg-rr3.1%
*-inverses3.1%
*-rgt-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 2024040
(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))