
(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 (+ (+ (+ (+ (+ x y) y) x) x) z))
double code(double x, double y, double z) {
return ((((x + y) + y) + x) + x) + 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) + y) + x) + x) + z
end function
public static double code(double x, double y, double z) {
return ((((x + y) + y) + x) + x) + z;
}
def code(x, y, z): return ((((x + y) + y) + x) + x) + z
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x + y) + y) + x) + x) + z) end
function tmp = code(x, y, z) tmp = ((((x + y) + y) + x) + x) + z; end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x + y), $MachinePrecision] + y), $MachinePrecision] + x), $MachinePrecision] + x), $MachinePrecision] + z), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right) + z
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites71.6%
Taylor expanded in x around 0
Applied rewrites99.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (+ (+ x y) y) x)) (t_1 (+ t_0 x))) (if (<= x -32000.0) t_1 (if (<= x 5.4e+153) (+ t_0 z) t_1))))
double code(double x, double y, double z) {
double t_0 = ((x + y) + y) + x;
double t_1 = t_0 + x;
double tmp;
if (x <= -32000.0) {
tmp = t_1;
} else if (x <= 5.4e+153) {
tmp = t_0 + z;
} else {
tmp = t_1;
}
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 + y) + y) + x
t_1 = t_0 + x
if (x <= (-32000.0d0)) then
tmp = t_1
else if (x <= 5.4d+153) then
tmp = t_0 + z
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((x + y) + y) + x;
double t_1 = t_0 + x;
double tmp;
if (x <= -32000.0) {
tmp = t_1;
} else if (x <= 5.4e+153) {
tmp = t_0 + z;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = ((x + y) + y) + x t_1 = t_0 + x tmp = 0 if x <= -32000.0: tmp = t_1 elif x <= 5.4e+153: tmp = t_0 + z else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(x + y) + y) + x) t_1 = Float64(t_0 + x) tmp = 0.0 if (x <= -32000.0) tmp = t_1; elseif (x <= 5.4e+153) tmp = Float64(t_0 + z); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((x + y) + y) + x; t_1 = t_0 + x; tmp = 0.0; if (x <= -32000.0) tmp = t_1; elseif (x <= 5.4e+153) tmp = t_0 + z; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(x + y), $MachinePrecision] + y), $MachinePrecision] + x), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 + x), $MachinePrecision]}, If[LessEqual[x, -32000.0], t$95$1, If[LessEqual[x, 5.4e+153], N[(t$95$0 + z), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(x + y\right) + y\right) + x\\
t_1 := t\_0 + x\\
\mathbf{if}\;x \leq -32000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 5.4 \cdot 10^{+153}:\\
\;\;\;\;t\_0 + z\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -32000 or 5.4000000000000001e153 < x Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites89.9%
if -32000 < x < 5.4000000000000001e153Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites90.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (+ x y) y))) (if (<= y -3.3e+114) t_0 (if (<= y 5.6e+75) (+ (+ x y) z) t_0))))
double code(double x, double y, double z) {
double t_0 = (x + y) + y;
double tmp;
if (y <= -3.3e+114) {
tmp = t_0;
} else if (y <= 5.6e+75) {
tmp = (x + y) + 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 = (x + y) + y
if (y <= (-3.3d+114)) then
tmp = t_0
else if (y <= 5.6d+75) then
tmp = (x + y) + z
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x + y) + y;
double tmp;
if (y <= -3.3e+114) {
tmp = t_0;
} else if (y <= 5.6e+75) {
tmp = (x + y) + z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x + y) + y tmp = 0 if y <= -3.3e+114: tmp = t_0 elif y <= 5.6e+75: tmp = (x + y) + z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x + y) + y) tmp = 0.0 if (y <= -3.3e+114) tmp = t_0; elseif (y <= 5.6e+75) tmp = Float64(Float64(x + y) + z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x + y) + y; tmp = 0.0; if (y <= -3.3e+114) tmp = t_0; elseif (y <= 5.6e+75) tmp = (x + y) + z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[y, -3.3e+114], t$95$0, If[LessEqual[y, 5.6e+75], N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x + y\right) + y\\
\mathbf{if}\;y \leq -3.3 \cdot 10^{+114}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 5.6 \cdot 10^{+75}:\\
\;\;\;\;\left(x + y\right) + z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -3.3000000000000001e114 or 5.60000000000000023e75 < y Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites87.1%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around inf
Applied rewrites70.1%
if -3.3000000000000001e114 < y < 5.60000000000000023e75Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites61.4%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites52.7%
(FPCore (x y z) :precision binary64 (+ (+ (+ (+ x y) y) x) z))
double code(double x, double y, double z) {
return (((x + y) + y) + x) + 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) + y) + x) + z
end function
public static double code(double x, double y, double z) {
return (((x + y) + y) + x) + z;
}
def code(x, y, z): return (((x + y) + y) + x) + z
function code(x, y, z) return Float64(Float64(Float64(Float64(x + y) + y) + x) + z) end
function tmp = code(x, y, z) tmp = (((x + y) + y) + x) + z; end
code[x_, y_, z_] := N[(N[(N[(N[(x + y), $MachinePrecision] + y), $MachinePrecision] + x), $MachinePrecision] + z), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(x + y\right) + y\right) + x\right) + z
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites71.6%
(FPCore (x y z) :precision binary64 (+ (+ (+ x y) y) z))
double code(double x, double y, double z) {
return ((x + y) + y) + 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) + y) + z
end function
public static double code(double x, double y, double z) {
return ((x + y) + y) + z;
}
def code(x, y, z): return ((x + y) + y) + z
function code(x, y, z) return Float64(Float64(Float64(x + y) + y) + z) end
function tmp = code(x, y, z) tmp = ((x + y) + y) + z; end
code[x_, y_, z_] := N[(N[(N[(x + y), $MachinePrecision] + y), $MachinePrecision] + z), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x + y\right) + y\right) + z
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites71.6%
Taylor expanded in x around 0
Applied rewrites70.8%
(FPCore (x y z) :precision binary64 (+ (+ x y) z))
double code(double x, double y, double z) {
return (x + y) + 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
end function
public static double code(double x, double y, double z) {
return (x + y) + z;
}
def code(x, y, z): return (x + y) + z
function code(x, y, z) return Float64(Float64(x + y) + z) end
function tmp = code(x, y, z) tmp = (x + y) + z; end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision]
\begin{array}{l}
\\
\left(x + y\right) + z
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites71.6%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites43.8%
(FPCore (x y z) :precision binary64 (+ (+ x y) x))
double code(double x, double y, double z) {
return (x + y) + 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) + x
end function
public static double code(double x, double y, double z) {
return (x + y) + x;
}
def code(x, y, z): return (x + y) + x
function code(x, y, z) return Float64(Float64(x + y) + x) end
function tmp = code(x, y, z) tmp = (x + y) + x; end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\left(x + y\right) + x
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites71.6%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites43.8%
Taylor expanded in x around inf
Applied rewrites14.3%
(FPCore (x y z) :precision binary64 (+ x y))
double code(double x, double y, double z) {
return x + y;
}
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
end function
public static double code(double x, double y, double z) {
return x + y;
}
def code(x, y, z): return x + y
function code(x, y, z) return Float64(x + y) end
function tmp = code(x, y, z) tmp = x + y; end
code[x_, y_, z_] := N[(x + y), $MachinePrecision]
\begin{array}{l}
\\
x + y
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites71.6%
Taylor expanded in x around inf
Applied rewrites13.5%
herbie shell --seed 2024313
(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))