
(FPCore (x y z) :precision binary64 (+ (+ (+ (+ (+ x y) y) x) z) x))
double code(double x, double y, double z) {
return ((((x + y) + y) + x) + z) + 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 + y) + y) + x) + z) + x
end function
public static double code(double x, double y, double z) {
return ((((x + y) + y) + x) + z) + x;
}
def code(x, y, z): return ((((x + y) + y) + x) + z) + x
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x + y) + y) + x) + z) + x) end
function tmp = code(x, y, z) tmp = ((((x + y) + y) + x) + z) + x; end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x + y), $MachinePrecision] + y), $MachinePrecision] + x), $MachinePrecision] + z), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (+ (+ (+ (+ x y) y) x) z) x))
double code(double x, double y, double z) {
return ((((x + y) + y) + x) + z) + 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 + y) + y) + x) + z) + x
end function
public static double code(double x, double y, double z) {
return ((((x + y) + y) + x) + z) + x;
}
def code(x, y, z): return ((((x + y) + y) + x) + z) + x
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x + y) + y) + x) + z) + x) end
function tmp = code(x, y, z) tmp = ((((x + y) + y) + x) + z) + x; end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x + y), $MachinePrecision] + y), $MachinePrecision] + x), $MachinePrecision] + z), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x
\end{array}
(FPCore (x y z) :precision binary64 (- z (fma x -3.0 (* y -2.0))))
double code(double x, double y, double z) {
return z - fma(x, -3.0, (y * -2.0));
}
function code(x, y, z) return Float64(z - fma(x, -3.0, Float64(y * -2.0))) end
code[x_, y_, z_] := N[(z - N[(x * -3.0 + N[(y * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z - \mathsf{fma}\left(x, -3, y \cdot -2\right)
\end{array}
(FPCore (x y z)
:precision binary64
(if (<= x -9.5e+90)
(* x 3.0)
(if (<= x -1.42e-5)
(* y 2.0)
(if (<= x -4.8e-94)
z
(if (<= x -5.2e-231)
(* y 2.0)
(if (<= x -1.3e-282)
z
(if (<= x 9e-280)
(* y 2.0)
(if (<= x 9e-210)
z
(if (<= x 2.6e-87)
(* y 2.0)
(if (<= x 5000000.0) z (* x 3.0)))))))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -9.5e+90) {
tmp = x * 3.0;
} else if (x <= -1.42e-5) {
tmp = y * 2.0;
} else if (x <= -4.8e-94) {
tmp = z;
} else if (x <= -5.2e-231) {
tmp = y * 2.0;
} else if (x <= -1.3e-282) {
tmp = z;
} else if (x <= 9e-280) {
tmp = y * 2.0;
} else if (x <= 9e-210) {
tmp = z;
} else if (x <= 2.6e-87) {
tmp = y * 2.0;
} else if (x <= 5000000.0) {
tmp = z;
} else {
tmp = x * 3.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.5d+90)) then
tmp = x * 3.0d0
else if (x <= (-1.42d-5)) then
tmp = y * 2.0d0
else if (x <= (-4.8d-94)) then
tmp = z
else if (x <= (-5.2d-231)) then
tmp = y * 2.0d0
else if (x <= (-1.3d-282)) then
tmp = z
else if (x <= 9d-280) then
tmp = y * 2.0d0
else if (x <= 9d-210) then
tmp = z
else if (x <= 2.6d-87) then
tmp = y * 2.0d0
else if (x <= 5000000.0d0) then
tmp = z
else
tmp = x * 3.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -9.5e+90) {
tmp = x * 3.0;
} else if (x <= -1.42e-5) {
tmp = y * 2.0;
} else if (x <= -4.8e-94) {
tmp = z;
} else if (x <= -5.2e-231) {
tmp = y * 2.0;
} else if (x <= -1.3e-282) {
tmp = z;
} else if (x <= 9e-280) {
tmp = y * 2.0;
} else if (x <= 9e-210) {
tmp = z;
} else if (x <= 2.6e-87) {
tmp = y * 2.0;
} else if (x <= 5000000.0) {
tmp = z;
} else {
tmp = x * 3.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -9.5e+90: tmp = x * 3.0 elif x <= -1.42e-5: tmp = y * 2.0 elif x <= -4.8e-94: tmp = z elif x <= -5.2e-231: tmp = y * 2.0 elif x <= -1.3e-282: tmp = z elif x <= 9e-280: tmp = y * 2.0 elif x <= 9e-210: tmp = z elif x <= 2.6e-87: tmp = y * 2.0 elif x <= 5000000.0: tmp = z else: tmp = x * 3.0 return tmp
function code(x, y, z) tmp = 0.0 if (x <= -9.5e+90) tmp = Float64(x * 3.0); elseif (x <= -1.42e-5) tmp = Float64(y * 2.0); elseif (x <= -4.8e-94) tmp = z; elseif (x <= -5.2e-231) tmp = Float64(y * 2.0); elseif (x <= -1.3e-282) tmp = z; elseif (x <= 9e-280) tmp = Float64(y * 2.0); elseif (x <= 9e-210) tmp = z; elseif (x <= 2.6e-87) tmp = Float64(y * 2.0); elseif (x <= 5000000.0) tmp = z; else tmp = Float64(x * 3.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -9.5e+90) tmp = x * 3.0; elseif (x <= -1.42e-5) tmp = y * 2.0; elseif (x <= -4.8e-94) tmp = z; elseif (x <= -5.2e-231) tmp = y * 2.0; elseif (x <= -1.3e-282) tmp = z; elseif (x <= 9e-280) tmp = y * 2.0; elseif (x <= 9e-210) tmp = z; elseif (x <= 2.6e-87) tmp = y * 2.0; elseif (x <= 5000000.0) tmp = z; else tmp = x * 3.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -9.5e+90], N[(x * 3.0), $MachinePrecision], If[LessEqual[x, -1.42e-5], N[(y * 2.0), $MachinePrecision], If[LessEqual[x, -4.8e-94], z, If[LessEqual[x, -5.2e-231], N[(y * 2.0), $MachinePrecision], If[LessEqual[x, -1.3e-282], z, If[LessEqual[x, 9e-280], N[(y * 2.0), $MachinePrecision], If[LessEqual[x, 9e-210], z, If[LessEqual[x, 2.6e-87], N[(y * 2.0), $MachinePrecision], If[LessEqual[x, 5000000.0], z, N[(x * 3.0), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.5 \cdot 10^{+90}:\\
\;\;\;\;x \cdot 3\\
\mathbf{elif}\;x \leq -1.42 \cdot 10^{-5}:\\
\;\;\;\;y \cdot 2\\
\mathbf{elif}\;x \leq -4.8 \cdot 10^{-94}:\\
\;\;\;\;z\\
\mathbf{elif}\;x \leq -5.2 \cdot 10^{-231}:\\
\;\;\;\;y \cdot 2\\
\mathbf{elif}\;x \leq -1.3 \cdot 10^{-282}:\\
\;\;\;\;z\\
\mathbf{elif}\;x \leq 9 \cdot 10^{-280}:\\
\;\;\;\;y \cdot 2\\
\mathbf{elif}\;x \leq 9 \cdot 10^{-210}:\\
\;\;\;\;z\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{-87}:\\
\;\;\;\;y \cdot 2\\
\mathbf{elif}\;x \leq 5000000:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;x \cdot 3\\
\end{array}
\end{array}
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ x (* 2.0 (+ x y)))))
(if (<= x -49.0)
t_0
(if (<= x 1.9e-85)
(- z (* y -2.0))
(if (<= x 3.7e+96) (- z (* x -3.0)) t_0)))))
double code(double x, double y, double z) {
double t_0 = x + (2.0 * (x + y));
double tmp;
if (x <= -49.0) {
tmp = t_0;
} else if (x <= 1.9e-85) {
tmp = z - (y * -2.0);
} else if (x <= 3.7e+96) {
tmp = z - (x * -3.0);
} 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 = x + (2.0d0 * (x + y))
if (x <= (-49.0d0)) then
tmp = t_0
else if (x <= 1.9d-85) then
tmp = z - (y * (-2.0d0))
else if (x <= 3.7d+96) then
tmp = z - (x * (-3.0d0))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x + (2.0 * (x + y));
double tmp;
if (x <= -49.0) {
tmp = t_0;
} else if (x <= 1.9e-85) {
tmp = z - (y * -2.0);
} else if (x <= 3.7e+96) {
tmp = z - (x * -3.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x + (2.0 * (x + y)) tmp = 0 if x <= -49.0: tmp = t_0 elif x <= 1.9e-85: tmp = z - (y * -2.0) elif x <= 3.7e+96: tmp = z - (x * -3.0) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x + Float64(2.0 * Float64(x + y))) tmp = 0.0 if (x <= -49.0) tmp = t_0; elseif (x <= 1.9e-85) tmp = Float64(z - Float64(y * -2.0)); elseif (x <= 3.7e+96) tmp = Float64(z - Float64(x * -3.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x + (2.0 * (x + y)); tmp = 0.0; if (x <= -49.0) tmp = t_0; elseif (x <= 1.9e-85) tmp = z - (y * -2.0); elseif (x <= 3.7e+96) tmp = z - (x * -3.0); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[(2.0 * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -49.0], t$95$0, If[LessEqual[x, 1.9e-85], N[(z - N[(y * -2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.7e+96], N[(z - N[(x * -3.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + 2 \cdot \left(x + y\right)\\
\mathbf{if}\;x \leq -49:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-85}:\\
\;\;\;\;z - y \cdot -2\\
\mathbf{elif}\;x \leq 3.7 \cdot 10^{+96}:\\
\;\;\;\;z - x \cdot -3\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= y -6e+205) (not (<= y 7e+85))) (* y 2.0) (- z (* x -3.0))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6e+205) || !(y <= 7e+85)) {
tmp = y * 2.0;
} else {
tmp = z - (x * -3.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 ((y <= (-6d+205)) .or. (.not. (y <= 7d+85))) then
tmp = y * 2.0d0
else
tmp = z - (x * (-3.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -6e+205) || !(y <= 7e+85)) {
tmp = y * 2.0;
} else {
tmp = z - (x * -3.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6e+205) or not (y <= 7e+85): tmp = y * 2.0 else: tmp = z - (x * -3.0) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6e+205) || !(y <= 7e+85)) tmp = Float64(y * 2.0); else tmp = Float64(z - Float64(x * -3.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -6e+205) || ~((y <= 7e+85))) tmp = y * 2.0; else tmp = z - (x * -3.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6e+205], N[Not[LessEqual[y, 7e+85]], $MachinePrecision]], N[(y * 2.0), $MachinePrecision], N[(z - N[(x * -3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{+205} \lor \neg \left(y \leq 7 \cdot 10^{+85}\right):\\
\;\;\;\;y \cdot 2\\
\mathbf{else}:\\
\;\;\;\;z - x \cdot -3\\
\end{array}
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= y -2.8e+101) (not (<= y 2.45e+27))) (- z (* y -2.0)) (- z (* x -3.0))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.8e+101) || !(y <= 2.45e+27)) {
tmp = z - (y * -2.0);
} else {
tmp = z - (x * -3.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 ((y <= (-2.8d+101)) .or. (.not. (y <= 2.45d+27))) then
tmp = z - (y * (-2.0d0))
else
tmp = z - (x * (-3.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -2.8e+101) || !(y <= 2.45e+27)) {
tmp = z - (y * -2.0);
} else {
tmp = z - (x * -3.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.8e+101) or not (y <= 2.45e+27): tmp = z - (y * -2.0) else: tmp = z - (x * -3.0) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.8e+101) || !(y <= 2.45e+27)) tmp = Float64(z - Float64(y * -2.0)); else tmp = Float64(z - Float64(x * -3.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.8e+101) || ~((y <= 2.45e+27))) tmp = z - (y * -2.0); else tmp = z - (x * -3.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.8e+101], N[Not[LessEqual[y, 2.45e+27]], $MachinePrecision]], N[(z - N[(y * -2.0), $MachinePrecision]), $MachinePrecision], N[(z - N[(x * -3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.8 \cdot 10^{+101} \lor \neg \left(y \leq 2.45 \cdot 10^{+27}\right):\\
\;\;\;\;z - y \cdot -2\\
\mathbf{else}:\\
\;\;\;\;z - x \cdot -3\\
\end{array}
\end{array}
(FPCore (x y z) :precision binary64 (+ (* 2.0 (+ x y)) (+ z x)))
double code(double x, double y, double z) {
return (2.0 * (x + y)) + (z + x);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (2.0d0 * (x + y)) + (z + x)
end function
public static double code(double x, double y, double z) {
return (2.0 * (x + y)) + (z + x);
}
def code(x, y, z): return (2.0 * (x + y)) + (z + x)
function code(x, y, z) return Float64(Float64(2.0 * Float64(x + y)) + Float64(z + x)) end
function tmp = code(x, y, z) tmp = (2.0 * (x + y)) + (z + x); end
code[x_, y_, z_] := N[(N[(2.0 * N[(x + y), $MachinePrecision]), $MachinePrecision] + N[(z + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(x + y\right) + \left(z + x\right)
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= y -1.9e+57) (not (<= y 2.9e+35))) (* y 2.0) z))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.9e+57) || !(y <= 2.9e+35)) {
tmp = y * 2.0;
} else {
tmp = 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 <= (-1.9d+57)) .or. (.not. (y <= 2.9d+35))) then
tmp = y * 2.0d0
else
tmp = z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.9e+57) || !(y <= 2.9e+35)) {
tmp = y * 2.0;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.9e+57) or not (y <= 2.9e+35): tmp = y * 2.0 else: tmp = z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.9e+57) || !(y <= 2.9e+35)) tmp = Float64(y * 2.0); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.9e+57) || ~((y <= 2.9e+35))) tmp = y * 2.0; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.9e+57], N[Not[LessEqual[y, 2.9e+35]], $MachinePrecision]], N[(y * 2.0), $MachinePrecision], z]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.9 \cdot 10^{+57} \lor \neg \left(y \leq 2.9 \cdot 10^{+35}\right):\\
\;\;\;\;y \cdot 2\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
(FPCore (x y z) :precision binary64 z)
double code(double x, double y, double z) {
return z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z
end function
public static double code(double x, double y, double z) {
return z;
}
def code(x, y, z): return z
function code(x, y, z) return z end
function tmp = code(x, y, z) tmp = z; end
code[x_, y_, z_] := z
\begin{array}{l}
\\
z
\end{array}
herbie shell --seed 2023343
(FPCore (x y z)
:name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendInside from plot-0.2.3.4"
:precision binary64
(+ (+ (+ (+ (+ x y) y) x) z) x))