
(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 6 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 rewrites70.9%
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 -3.1e-34) t_1 (if (<= x 5.7e-47) (+ 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 <= -3.1e-34) {
tmp = t_1;
} else if (x <= 5.7e-47) {
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 <= (-3.1d-34)) then
tmp = t_1
else if (x <= 5.7d-47) 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 <= -3.1e-34) {
tmp = t_1;
} else if (x <= 5.7e-47) {
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 <= -3.1e-34: tmp = t_1 elif x <= 5.7e-47: 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 <= -3.1e-34) tmp = t_1; elseif (x <= 5.7e-47) 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 <= -3.1e-34) tmp = t_1; elseif (x <= 5.7e-47) 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, -3.1e-34], t$95$1, If[LessEqual[x, 5.7e-47], 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 -3.1 \cdot 10^{-34}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 5.7 \cdot 10^{-47}:\\
\;\;\;\;t\_0 + z\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -3.0999999999999998e-34 or 5.70000000000000046e-47 < x Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites83.5%
if -3.0999999999999998e-34 < x < 5.70000000000000046e-47Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites97.2%
(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 rewrites70.9%
(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 rewrites70.9%
Taylor expanded in x around 0
Applied rewrites70.0%
(FPCore (x y z) :precision binary64 (+ (+ x y) y))
double code(double x, double y, double z) {
return (x + y) + 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) + y
end function
public static double code(double x, double y, double z) {
return (x + y) + y;
}
def code(x, y, z): return (x + y) + y
function code(x, y, z) return Float64(Float64(x + y) + y) end
function tmp = code(x, y, z) tmp = (x + y) + y; end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] + y), $MachinePrecision]
\begin{array}{l}
\\
\left(x + y\right) + y
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites70.9%
Taylor expanded in x around 0
Applied rewrites70.0%
Taylor expanded in x around 0
Applied rewrites39.8%
(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 rewrites70.9%
Taylor expanded in x around inf
Applied rewrites13.7%
herbie shell --seed 2024321
(FPCore (x y z)
:name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendInside from plot-0.2.3.4"
:precision binary64
:pre (TRUE)
(+ (+ (+ (+ (+ x y) y) x) z) x))