
(FPCore (x y z) :precision binary64 (- (/ (* x y) 2.0) (/ z 8.0)))
double code(double x, double y, double z) {
return ((x * y) / 2.0) - (z / 8.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 * y) / 2.0d0) - (z / 8.0d0)
end function
public static double code(double x, double y, double z) {
return ((x * y) / 2.0) - (z / 8.0);
}
def code(x, y, z): return ((x * y) / 2.0) - (z / 8.0)
function code(x, y, z) return Float64(Float64(Float64(x * y) / 2.0) - Float64(z / 8.0)) end
function tmp = code(x, y, z) tmp = ((x * y) / 2.0) - (z / 8.0); end
code[x_, y_, z_] := N[(N[(N[(x * y), $MachinePrecision] / 2.0), $MachinePrecision] - N[(z / 8.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{2} - \frac{z}{8}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (- (/ (* x y) 2.0) (/ z 8.0)))
double code(double x, double y, double z) {
return ((x * y) / 2.0) - (z / 8.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 * y) / 2.0d0) - (z / 8.0d0)
end function
public static double code(double x, double y, double z) {
return ((x * y) / 2.0) - (z / 8.0);
}
def code(x, y, z): return ((x * y) / 2.0) - (z / 8.0)
function code(x, y, z) return Float64(Float64(Float64(x * y) / 2.0) - Float64(z / 8.0)) end
function tmp = code(x, y, z) tmp = ((x * y) / 2.0) - (z / 8.0); end
code[x_, y_, z_] := N[(N[(N[(x * y), $MachinePrecision] / 2.0), $MachinePrecision] - N[(z / 8.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{2} - \frac{z}{8}
\end{array}
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (- (/ x (/ 2.0 y)) (/ z 8.0)))
assert(x < y && y < z);
double code(double x, double y, double z) {
return (x / (2.0 / y)) - (z / 8.0);
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x / (2.0d0 / y)) - (z / 8.0d0)
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return (x / (2.0 / y)) - (z / 8.0);
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return (x / (2.0 / y)) - (z / 8.0)
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(Float64(x / Float64(2.0 / y)) - Float64(z / 8.0)) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = (x / (2.0 / y)) - (z / 8.0);
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(N[(x / N[(2.0 / y), $MachinePrecision]), $MachinePrecision] - N[(z / 8.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\frac{x}{\frac{2}{y}} - \frac{z}{8}
\end{array}
Initial program 99.7%
Applied egg-rr0
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -2.9e-87) (* 0.5 (* x y)) (if (<= y 4.8e+42) (* -0.125 z) (* (/ y 2.0) x))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -2.9e-87) {
tmp = 0.5 * (x * y);
} else if (y <= 4.8e+42) {
tmp = -0.125 * z;
} else {
tmp = (y / 2.0) * x;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
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.9d-87)) then
tmp = 0.5d0 * (x * y)
else if (y <= 4.8d+42) then
tmp = (-0.125d0) * z
else
tmp = (y / 2.0d0) * x
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.9e-87) {
tmp = 0.5 * (x * y);
} else if (y <= 4.8e+42) {
tmp = -0.125 * z;
} else {
tmp = (y / 2.0) * x;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -2.9e-87: tmp = 0.5 * (x * y) elif y <= 4.8e+42: tmp = -0.125 * z else: tmp = (y / 2.0) * x return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -2.9e-87) tmp = Float64(0.5 * Float64(x * y)); elseif (y <= 4.8e+42) tmp = Float64(-0.125 * z); else tmp = Float64(Float64(y / 2.0) * x); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= -2.9e-87)
tmp = 0.5 * (x * y);
elseif (y <= 4.8e+42)
tmp = -0.125 * z;
else
tmp = (y / 2.0) * x;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -2.9e-87], N[(0.5 * N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.8e+42], N[(-0.125 * z), $MachinePrecision], N[(N[(y / 2.0), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.9 \cdot 10^{-87}:\\
\;\;\;\;0.5 \cdot \left(x \cdot y\right)\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{+42}:\\
\;\;\;\;-0.125 \cdot z\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{2} \cdot x\\
\end{array}
\end{array}
if y < -2.8999999999999999e-87Initial program 100.0%
Taylor expanded in x around inf 0
Simplified0
if -2.8999999999999999e-87 < y < 4.7999999999999997e42Initial program 100.0%
Taylor expanded in x around 0 0
Simplified0
if 4.7999999999999997e42 < y Initial program 98.5%
Taylor expanded in x around inf 0
Simplified0
Applied egg-rr0
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (let* ((t_0 (* 0.5 (* x y)))) (if (<= y -5.4e-88) t_0 (if (<= y 2e+43) (* -0.125 z) t_0))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double t_0 = 0.5 * (x * y);
double tmp;
if (y <= -5.4e-88) {
tmp = t_0;
} else if (y <= 2e+43) {
tmp = -0.125 * z;
} else {
tmp = t_0;
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
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 = 0.5d0 * (x * y)
if (y <= (-5.4d-88)) then
tmp = t_0
else if (y <= 2d+43) then
tmp = (-0.125d0) * z
else
tmp = t_0
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double t_0 = 0.5 * (x * y);
double tmp;
if (y <= -5.4e-88) {
tmp = t_0;
} else if (y <= 2e+43) {
tmp = -0.125 * z;
} else {
tmp = t_0;
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): t_0 = 0.5 * (x * y) tmp = 0 if y <= -5.4e-88: tmp = t_0 elif y <= 2e+43: tmp = -0.125 * z else: tmp = t_0 return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) t_0 = Float64(0.5 * Float64(x * y)) tmp = 0.0 if (y <= -5.4e-88) tmp = t_0; elseif (y <= 2e+43) tmp = Float64(-0.125 * z); else tmp = t_0; end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
t_0 = 0.5 * (x * y);
tmp = 0.0;
if (y <= -5.4e-88)
tmp = t_0;
elseif (y <= 2e+43)
tmp = -0.125 * z;
else
tmp = t_0;
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[(0.5 * N[(x * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5.4e-88], t$95$0, If[LessEqual[y, 2e+43], N[(-0.125 * z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(x \cdot y\right)\\
\mathbf{if}\;y \leq -5.4 \cdot 10^{-88}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2 \cdot 10^{+43}:\\
\;\;\;\;-0.125 \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -5.39999999999999989e-88 or 2.00000000000000003e43 < y Initial program 99.4%
Taylor expanded in x around inf 0
Simplified0
if -5.39999999999999989e-88 < y < 2.00000000000000003e43Initial program 100.0%
Taylor expanded in x around 0 0
Simplified0
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* -0.125 z))
assert(x < y && y < z);
double code(double x, double y, double z) {
return -0.125 * z;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (-0.125d0) * z
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return -0.125 * z;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return -0.125 * z
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(-0.125 * z) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = -0.125 * z;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(-0.125 * z), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
-0.125 \cdot z
\end{array}
Initial program 99.7%
Taylor expanded in x around 0 0
Simplified0
herbie shell --seed 2024110
(FPCore (x y z)
:name "Diagrams.Solve.Polynomial:quartForm from diagrams-solve-0.1, D"
:precision binary64
(- (/ (* x y) 2.0) (/ z 8.0)))