
(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 11 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+108) (not (<= z 1.5e+64))) (* (/ (+ (- y z) 1.0) z) x) (/ (fma x (- y z) x) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2e+108) || !(z <= 1.5e+64)) {
tmp = (((y - z) + 1.0) / z) * x;
} else {
tmp = fma(x, (y - z), x) / z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((z <= -2e+108) || !(z <= 1.5e+64)) tmp = Float64(Float64(Float64(Float64(y - z) + 1.0) / z) * x); else tmp = Float64(fma(x, Float64(y - z), x) / z); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[z, -2e+108], N[Not[LessEqual[z, 1.5e+64]], $MachinePrecision]], N[(N[(N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision] / z), $MachinePrecision] * x), $MachinePrecision], N[(N[(x * N[(y - z), $MachinePrecision] + x), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{+108} \lor \neg \left(z \leq 1.5 \cdot 10^{+64}\right):\\
\;\;\;\;\frac{\left(y - z\right) + 1}{z} \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y - z, x\right)}{z}\\
\end{array}
\end{array}
if z < -2.0000000000000001e108 or 1.5000000000000001e64 < z Initial program 79.2%
*-commutative79.2%
associate-/l*58.1%
associate-/r/100.0%
Applied egg-rr100.0%
if -2.0000000000000001e108 < z < 1.5000000000000001e64Initial program 99.8%
distribute-lft-in99.8%
*-rgt-identity99.8%
fma-def99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= z -9.8e+29)
(- x)
(if (<= z -0.0072)
t_0
(if (<= z -1.9e-180)
(/ x z)
(if (<= z -1.12e-305)
t_0
(if (<= z 2.8e-44) (/ x z) (if (<= z 6.2e+65) t_0 (- x)))))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -9.8e+29) {
tmp = -x;
} else if (z <= -0.0072) {
tmp = t_0;
} else if (z <= -1.9e-180) {
tmp = x / z;
} else if (z <= -1.12e-305) {
tmp = t_0;
} else if (z <= 2.8e-44) {
tmp = x / z;
} else if (z <= 6.2e+65) {
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 <= (-9.8d+29)) then
tmp = -x
else if (z <= (-0.0072d0)) then
tmp = t_0
else if (z <= (-1.9d-180)) then
tmp = x / z
else if (z <= (-1.12d-305)) then
tmp = t_0
else if (z <= 2.8d-44) then
tmp = x / z
else if (z <= 6.2d+65) 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 <= -9.8e+29) {
tmp = -x;
} else if (z <= -0.0072) {
tmp = t_0;
} else if (z <= -1.9e-180) {
tmp = x / z;
} else if (z <= -1.12e-305) {
tmp = t_0;
} else if (z <= 2.8e-44) {
tmp = x / z;
} else if (z <= 6.2e+65) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if z <= -9.8e+29: tmp = -x elif z <= -0.0072: tmp = t_0 elif z <= -1.9e-180: tmp = x / z elif z <= -1.12e-305: tmp = t_0 elif z <= 2.8e-44: tmp = x / z elif z <= 6.2e+65: 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 <= -9.8e+29) tmp = Float64(-x); elseif (z <= -0.0072) tmp = t_0; elseif (z <= -1.9e-180) tmp = Float64(x / z); elseif (z <= -1.12e-305) tmp = t_0; elseif (z <= 2.8e-44) tmp = Float64(x / z); elseif (z <= 6.2e+65) 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 <= -9.8e+29) tmp = -x; elseif (z <= -0.0072) tmp = t_0; elseif (z <= -1.9e-180) tmp = x / z; elseif (z <= -1.12e-305) tmp = t_0; elseif (z <= 2.8e-44) tmp = x / z; elseif (z <= 6.2e+65) 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, -9.8e+29], (-x), If[LessEqual[z, -0.0072], t$95$0, If[LessEqual[z, -1.9e-180], N[(x / z), $MachinePrecision], If[LessEqual[z, -1.12e-305], t$95$0, If[LessEqual[z, 2.8e-44], N[(x / z), $MachinePrecision], If[LessEqual[z, 6.2e+65], t$95$0, (-x)]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -9.8 \cdot 10^{+29}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -0.0072:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -1.9 \cdot 10^{-180}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq -1.12 \cdot 10^{-305}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{-44}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 6.2 \cdot 10^{+65}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -9.8000000000000003e29 or 6.19999999999999981e65 < z Initial program 84.9%
Taylor expanded in z around inf 77.4%
mul-1-neg77.4%
Simplified77.4%
if -9.8000000000000003e29 < z < -0.0071999999999999998 or -1.9e-180 < z < -1.1200000000000001e-305 or 2.8e-44 < z < 6.19999999999999981e65Initial program 98.3%
Taylor expanded in y around inf 67.2%
associate-*l/70.1%
*-commutative70.1%
Simplified70.1%
if -0.0071999999999999998 < z < -1.9e-180 or -1.1200000000000001e-305 < z < 2.8e-44Initial program 99.9%
Taylor expanded in z around 0 98.6%
Taylor expanded in y around 0 64.6%
Final simplification71.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= z -9.5e+131)
(- x)
(if (<= z -0.0072)
(* x (/ y z))
(if (<= z -5.1e-179)
(/ x z)
(if (<= z -2.1e-300)
t_0
(if (<= z 8.5e-43) (/ x z) (if (<= z 6.5e+65) t_0 (- x)))))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -9.5e+131) {
tmp = -x;
} else if (z <= -0.0072) {
tmp = x * (y / z);
} else if (z <= -5.1e-179) {
tmp = x / z;
} else if (z <= -2.1e-300) {
tmp = t_0;
} else if (z <= 8.5e-43) {
tmp = x / z;
} else if (z <= 6.5e+65) {
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 <= (-9.5d+131)) then
tmp = -x
else if (z <= (-0.0072d0)) then
tmp = x * (y / z)
else if (z <= (-5.1d-179)) then
tmp = x / z
else if (z <= (-2.1d-300)) then
tmp = t_0
else if (z <= 8.5d-43) then
tmp = x / z
else if (z <= 6.5d+65) 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 <= -9.5e+131) {
tmp = -x;
} else if (z <= -0.0072) {
tmp = x * (y / z);
} else if (z <= -5.1e-179) {
tmp = x / z;
} else if (z <= -2.1e-300) {
tmp = t_0;
} else if (z <= 8.5e-43) {
tmp = x / z;
} else if (z <= 6.5e+65) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if z <= -9.5e+131: tmp = -x elif z <= -0.0072: tmp = x * (y / z) elif z <= -5.1e-179: tmp = x / z elif z <= -2.1e-300: tmp = t_0 elif z <= 8.5e-43: tmp = x / z elif z <= 6.5e+65: 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 <= -9.5e+131) tmp = Float64(-x); elseif (z <= -0.0072) tmp = Float64(x * Float64(y / z)); elseif (z <= -5.1e-179) tmp = Float64(x / z); elseif (z <= -2.1e-300) tmp = t_0; elseif (z <= 8.5e-43) tmp = Float64(x / z); elseif (z <= 6.5e+65) 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 <= -9.5e+131) tmp = -x; elseif (z <= -0.0072) tmp = x * (y / z); elseif (z <= -5.1e-179) tmp = x / z; elseif (z <= -2.1e-300) tmp = t_0; elseif (z <= 8.5e-43) tmp = x / z; elseif (z <= 6.5e+65) 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, -9.5e+131], (-x), If[LessEqual[z, -0.0072], N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -5.1e-179], N[(x / z), $MachinePrecision], If[LessEqual[z, -2.1e-300], t$95$0, If[LessEqual[z, 8.5e-43], N[(x / z), $MachinePrecision], If[LessEqual[z, 6.5e+65], t$95$0, (-x)]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -9.5 \cdot 10^{+131}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -0.0072:\\
\;\;\;\;x \cdot \frac{y}{z}\\
\mathbf{elif}\;z \leq -5.1 \cdot 10^{-179}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq -2.1 \cdot 10^{-300}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 8.5 \cdot 10^{-43}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 6.5 \cdot 10^{+65}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -9.50000000000000015e131 or 6.5000000000000003e65 < z Initial program 79.3%
Taylor expanded in z around inf 89.5%
mul-1-neg89.5%
Simplified89.5%
if -9.50000000000000015e131 < z < -0.0071999999999999998Initial program 99.7%
*-commutative99.7%
associate-/l*82.9%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 63.0%
if -0.0071999999999999998 < z < -5.10000000000000028e-179 or -2.10000000000000004e-300 < z < 8.50000000000000056e-43Initial program 99.9%
Taylor expanded in z around 0 98.6%
Taylor expanded in y around 0 64.6%
if -5.10000000000000028e-179 < z < -2.10000000000000004e-300 or 8.50000000000000056e-43 < z < 6.5000000000000003e65Initial program 98.0%
Taylor expanded in y around inf 65.8%
associate-*l/69.3%
*-commutative69.3%
Simplified69.3%
Final simplification72.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ x z) x)) (t_1 (/ (* x (+ y 1.0)) z)))
(if (<= y -1.1e-8)
t_1
(if (<= y 50000.0)
t_0
(if (<= y 3.4e+31) t_1 (if (<= y 8.6e+84) t_0 (/ (* y x) z)))))))
double code(double x, double y, double z) {
double t_0 = (x / z) - x;
double t_1 = (x * (y + 1.0)) / z;
double tmp;
if (y <= -1.1e-8) {
tmp = t_1;
} else if (y <= 50000.0) {
tmp = t_0;
} else if (y <= 3.4e+31) {
tmp = t_1;
} else if (y <= 8.6e+84) {
tmp = t_0;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (x / z) - x
t_1 = (x * (y + 1.0d0)) / z
if (y <= (-1.1d-8)) then
tmp = t_1
else if (y <= 50000.0d0) then
tmp = t_0
else if (y <= 3.4d+31) then
tmp = t_1
else if (y <= 8.6d+84) then
tmp = t_0
else
tmp = (y * x) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x / z) - x;
double t_1 = (x * (y + 1.0)) / z;
double tmp;
if (y <= -1.1e-8) {
tmp = t_1;
} else if (y <= 50000.0) {
tmp = t_0;
} else if (y <= 3.4e+31) {
tmp = t_1;
} else if (y <= 8.6e+84) {
tmp = t_0;
} else {
tmp = (y * x) / z;
}
return tmp;
}
def code(x, y, z): t_0 = (x / z) - x t_1 = (x * (y + 1.0)) / z tmp = 0 if y <= -1.1e-8: tmp = t_1 elif y <= 50000.0: tmp = t_0 elif y <= 3.4e+31: tmp = t_1 elif y <= 8.6e+84: tmp = t_0 else: tmp = (y * x) / z return tmp
function code(x, y, z) t_0 = Float64(Float64(x / z) - x) t_1 = Float64(Float64(x * Float64(y + 1.0)) / z) tmp = 0.0 if (y <= -1.1e-8) tmp = t_1; elseif (y <= 50000.0) tmp = t_0; elseif (y <= 3.4e+31) tmp = t_1; elseif (y <= 8.6e+84) tmp = t_0; else tmp = Float64(Float64(y * x) / z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x / z) - x; t_1 = (x * (y + 1.0)) / z; tmp = 0.0; if (y <= -1.1e-8) tmp = t_1; elseif (y <= 50000.0) tmp = t_0; elseif (y <= 3.4e+31) tmp = t_1; elseif (y <= 8.6e+84) tmp = t_0; else tmp = (y * x) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * N[(y + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[y, -1.1e-8], t$95$1, If[LessEqual[y, 50000.0], t$95$0, If[LessEqual[y, 3.4e+31], t$95$1, If[LessEqual[y, 8.6e+84], t$95$0, N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{z} - x\\
t_1 := \frac{x \cdot \left(y + 1\right)}{z}\\
\mathbf{if}\;y \leq -1.1 \cdot 10^{-8}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 50000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{+31}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 8.6 \cdot 10^{+84}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{z}\\
\end{array}
\end{array}
if y < -1.0999999999999999e-8 or 5e4 < y < 3.3999999999999998e31Initial program 96.9%
Taylor expanded in z around 0 85.6%
if -1.0999999999999999e-8 < y < 5e4 or 3.3999999999999998e31 < y < 8.5999999999999992e84Initial program 92.7%
Taylor expanded in y around 0 90.4%
Taylor expanded in z around 0 97.7%
+-commutative97.7%
mul-1-neg97.7%
unsub-neg97.7%
Simplified97.7%
if 8.5999999999999992e84 < y Initial program 91.7%
Taylor expanded in y around inf 83.4%
Final simplification92.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -1e-17) (not (<= z 1e-5))) (* (/ (+ (- y z) 1.0) z) x) (/ (* x (+ y 1.0)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1e-17) || !(z <= 1e-5)) {
tmp = (((y - z) + 1.0) / 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 <= (-1d-17)) .or. (.not. (z <= 1d-5))) then
tmp = (((y - z) + 1.0d0) / 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 <= -1e-17) || !(z <= 1e-5)) {
tmp = (((y - z) + 1.0) / z) * x;
} else {
tmp = (x * (y + 1.0)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1e-17) or not (z <= 1e-5): tmp = (((y - z) + 1.0) / z) * x else: tmp = (x * (y + 1.0)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1e-17) || !(z <= 1e-5)) tmp = Float64(Float64(Float64(Float64(y - z) + 1.0) / 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 <= -1e-17) || ~((z <= 1e-5))) tmp = (((y - z) + 1.0) / z) * x; else tmp = (x * (y + 1.0)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1e-17], N[Not[LessEqual[z, 1e-5]], $MachinePrecision]], N[(N[(N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision] / z), $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 \cdot 10^{-17} \lor \neg \left(z \leq 10^{-5}\right):\\
\;\;\;\;\frac{\left(y - z\right) + 1}{z} \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(y + 1\right)}{z}\\
\end{array}
\end{array}
if z < -1.00000000000000007e-17 or 1.00000000000000008e-5 < z Initial program 87.7%
*-commutative87.7%
associate-/l*71.9%
associate-/r/99.8%
Applied egg-rr99.8%
if -1.00000000000000007e-17 < z < 1.00000000000000008e-5Initial program 99.9%
Taylor expanded in z around 0 99.9%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (- y z) 1.0)))
(if (or (<= z -2e+108) (not (<= z 2.9e+64)))
(* (/ t_0 z) x)
(/ (* t_0 x) z))))
double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if ((z <= -2e+108) || !(z <= 2.9e+64)) {
tmp = (t_0 / z) * x;
} 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 <= (-2d+108)) .or. (.not. (z <= 2.9d+64))) then
tmp = (t_0 / z) * x
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 <= -2e+108) || !(z <= 2.9e+64)) {
tmp = (t_0 / z) * x;
} else {
tmp = (t_0 * x) / z;
}
return tmp;
}
def code(x, y, z): t_0 = (y - z) + 1.0 tmp = 0 if (z <= -2e+108) or not (z <= 2.9e+64): tmp = (t_0 / z) * x 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 <= -2e+108) || !(z <= 2.9e+64)) tmp = Float64(Float64(t_0 / z) * x); else tmp = Float64(Float64(t_0 * x) / z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y - z) + 1.0; tmp = 0.0; if ((z <= -2e+108) || ~((z <= 2.9e+64))) tmp = (t_0 / z) * x; 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, -2e+108], N[Not[LessEqual[z, 2.9e+64]], $MachinePrecision]], N[(N[(t$95$0 / z), $MachinePrecision] * x), $MachinePrecision], N[(N[(t$95$0 * x), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y - z\right) + 1\\
\mathbf{if}\;z \leq -2 \cdot 10^{+108} \lor \neg \left(z \leq 2.9 \cdot 10^{+64}\right):\\
\;\;\;\;\frac{t_0}{z} \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 \cdot x}{z}\\
\end{array}
\end{array}
if z < -2.0000000000000001e108 or 2.89999999999999993e64 < z Initial program 79.2%
*-commutative79.2%
associate-/l*58.1%
associate-/r/100.0%
Applied egg-rr100.0%
if -2.0000000000000001e108 < z < 2.89999999999999993e64Initial program 99.8%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -11500000.0) (not (<= y 8.6e+84))) (* y (/ x z)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -11500000.0) || !(y <= 8.6e+84)) {
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 <= (-11500000.0d0)) .or. (.not. (y <= 8.6d+84))) 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 <= -11500000.0) || !(y <= 8.6e+84)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -11500000.0) or not (y <= 8.6e+84): tmp = y * (x / z) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -11500000.0) || !(y <= 8.6e+84)) 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 <= -11500000.0) || ~((y <= 8.6e+84))) tmp = y * (x / z); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -11500000.0], N[Not[LessEqual[y, 8.6e+84]], $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 -11500000 \lor \neg \left(y \leq 8.6 \cdot 10^{+84}\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -1.15e7 or 8.5999999999999992e84 < y Initial program 94.0%
Taylor expanded in y around inf 83.9%
associate-*l/80.7%
*-commutative80.7%
Simplified80.7%
if -1.15e7 < y < 8.5999999999999992e84Initial program 93.3%
Taylor expanded in y around 0 86.0%
Taylor expanded in z around 0 92.6%
+-commutative92.6%
mul-1-neg92.6%
unsub-neg92.6%
Simplified92.6%
Final simplification88.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -1300000.0) (not (<= y 8.6e+84))) (/ (* y x) z) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1300000.0) || !(y <= 8.6e+84)) {
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 <= (-1300000.0d0)) .or. (.not. (y <= 8.6d+84))) 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 <= -1300000.0) || !(y <= 8.6e+84)) {
tmp = (y * x) / z;
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1300000.0) or not (y <= 8.6e+84): tmp = (y * x) / z else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1300000.0) || !(y <= 8.6e+84)) tmp = Float64(Float64(y * 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 <= -1300000.0) || ~((y <= 8.6e+84))) tmp = (y * x) / z; else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1300000.0], N[Not[LessEqual[y, 8.6e+84]], $MachinePrecision]], N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1300000 \lor \neg \left(y \leq 8.6 \cdot 10^{+84}\right):\\
\;\;\;\;\frac{y \cdot x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -1.3e6 or 8.5999999999999992e84 < y Initial program 94.0%
Taylor expanded in y around inf 83.9%
if -1.3e6 < y < 8.5999999999999992e84Initial program 93.3%
Taylor expanded in y around 0 86.0%
Taylor expanded in z around 0 92.6%
+-commutative92.6%
mul-1-neg92.6%
unsub-neg92.6%
Simplified92.6%
Final simplification89.3%
(FPCore (x y z) :precision binary64 (if (<= y -5000000.0) (* y (/ x z)) (if (<= y 9e+84) (- (/ x z) x) (/ y (/ z x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5000000.0) {
tmp = y * (x / z);
} else if (y <= 9e+84) {
tmp = (x / z) - x;
} else {
tmp = y / (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 <= (-5000000.0d0)) then
tmp = y * (x / z)
else if (y <= 9d+84) then
tmp = (x / z) - x
else
tmp = y / (z / x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5000000.0) {
tmp = y * (x / z);
} else if (y <= 9e+84) {
tmp = (x / z) - x;
} else {
tmp = y / (z / x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5000000.0: tmp = y * (x / z) elif y <= 9e+84: tmp = (x / z) - x else: tmp = y / (z / x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5000000.0) tmp = Float64(y * Float64(x / z)); elseif (y <= 9e+84) tmp = Float64(Float64(x / z) - x); else tmp = Float64(y / Float64(z / x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5000000.0) tmp = y * (x / z); elseif (y <= 9e+84) tmp = (x / z) - x; else tmp = y / (z / x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5000000.0], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 9e+84], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5000000:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{elif}\;y \leq 9 \cdot 10^{+84}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\
\end{array}
\end{array}
if y < -5e6Initial program 96.2%
Taylor expanded in y around inf 84.4%
associate-*l/78.6%
*-commutative78.6%
Simplified78.6%
if -5e6 < y < 8.9999999999999994e84Initial program 93.3%
Taylor expanded in y around 0 86.0%
Taylor expanded in z around 0 92.6%
+-commutative92.6%
mul-1-neg92.6%
unsub-neg92.6%
Simplified92.6%
if 8.9999999999999994e84 < y Initial program 91.7%
*-commutative91.7%
associate-/l*87.3%
associate-/r/89.6%
Applied egg-rr89.6%
Taylor expanded in y around inf 79.3%
associate-/r/83.3%
Applied egg-rr83.3%
Final simplification88.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 9500.0))) (- x) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 9500.0)) {
tmp = -x;
} else {
tmp = x / z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.0d0)) .or. (.not. (z <= 9500.0d0))) then
tmp = -x
else
tmp = x / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 9500.0)) {
tmp = -x;
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 9500.0): tmp = -x else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 9500.0)) tmp = Float64(-x); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 9500.0))) 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, 9500.0]], $MachinePrecision]], (-x), N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 9500\right):\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if z < -1 or 9500 < z Initial program 87.2%
Taylor expanded in z around inf 68.6%
mul-1-neg68.6%
Simplified68.6%
if -1 < z < 9500Initial program 99.9%
Taylor expanded in z around 0 98.3%
Taylor expanded in y around 0 57.0%
Final simplification62.7%
(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 93.6%
Taylor expanded in z around inf 35.7%
mul-1-neg35.7%
Simplified35.7%
Final simplification35.7%
(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 2023301
(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))