
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 + ((4.0d0 * ((x + (y * 0.25d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.25)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 + ((4.0d0 * ((x + (y * 0.25d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.25)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}
\end{array}
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 + ((4.0d0 * ((x + (y * 0.25d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.25)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}
\end{array}
Initial program 100.0%
(FPCore (x y z) :precision binary64 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y))
double code(double x, double y, double z) {
return (4.0 * ((x + (y * 0.25)) - z)) / y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (4.0d0 * ((x + (y * 0.25d0)) - z)) / y
end function
public static double code(double x, double y, double z) {
return (4.0 * ((x + (y * 0.25)) - z)) / y;
}
def code(x, y, z): return (4.0 * ((x + (y * 0.25)) - z)) / y
function code(x, y, z) return Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.25)) - z)) / y) end
function tmp = code(x, y, z) tmp = (4.0 * ((x + (y * 0.25)) - z)) / y; end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites73.5%
(FPCore (x y z) :precision binary64 (if (<= y -3.9e-10) (/ (* y 0.25) y) (+ 1.0 (+ 1.0 (- (+ x (* y 0.25)) z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.9e-10) {
tmp = (y * 0.25) / y;
} else {
tmp = 1.0 + (1.0 + ((x + (y * 0.25)) - 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 <= (-3.9d-10)) then
tmp = (y * 0.25d0) / y
else
tmp = 1.0d0 + (1.0d0 + ((x + (y * 0.25d0)) - z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -3.9e-10) {
tmp = (y * 0.25) / y;
} else {
tmp = 1.0 + (1.0 + ((x + (y * 0.25)) - z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.9e-10: tmp = (y * 0.25) / y else: tmp = 1.0 + (1.0 + ((x + (y * 0.25)) - z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.9e-10) tmp = Float64(Float64(y * 0.25) / y); else tmp = Float64(1.0 + Float64(1.0 + Float64(Float64(x + Float64(y * 0.25)) - z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.9e-10) tmp = (y * 0.25) / y; else tmp = 1.0 + (1.0 + ((x + (y * 0.25)) - z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.9e-10], N[(N[(y * 0.25), $MachinePrecision] / y), $MachinePrecision], N[(1.0 + N[(1.0 + N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.9 \cdot 10^{-10}:\\
\;\;\;\;\frac{y \cdot 0.25}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + \left(1 + \left(\left(x + y \cdot 0.25\right) - z\right)\right)\\
\end{array}
\end{array}
if y < -3.9e-10Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites53.5%
Taylor expanded in x around inf
Applied rewrites10.6%
if -3.9e-10 < y Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites5.0%
Taylor expanded in x around 0
Applied rewrites8.1%
(FPCore (x y z) :precision binary64 (+ 1.0 (+ 1.0 (/ (* y 0.25) y))))
double code(double x, double y, double z) {
return 1.0 + (1.0 + ((y * 0.25) / y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 + (1.0d0 + ((y * 0.25d0) / y))
end function
public static double code(double x, double y, double z) {
return 1.0 + (1.0 + ((y * 0.25) / y));
}
def code(x, y, z): return 1.0 + (1.0 + ((y * 0.25) / y))
function code(x, y, z) return Float64(1.0 + Float64(1.0 + Float64(Float64(y * 0.25) / y))) end
function tmp = code(x, y, z) tmp = 1.0 + (1.0 + ((y * 0.25) / y)); end
code[x_, y_, z_] := N[(1.0 + N[(1.0 + N[(N[(y * 0.25), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \left(1 + \frac{y \cdot 0.25}{y}\right)
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites3.9%
Taylor expanded in x around 0
Applied rewrites7.6%
Taylor expanded in x around 0
Applied rewrites9.4%
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* y 0.25) y)))
double code(double x, double y, double z) {
return 1.0 + ((y * 0.25) / y);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 + ((y * 0.25d0) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((y * 0.25) / y);
}
def code(x, y, z): return 1.0 + ((y * 0.25) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(y * 0.25) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((y * 0.25) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(y * 0.25), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{y \cdot 0.25}{y}
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites8.1%
(FPCore (x y z) :precision binary64 (/ (* y 0.25) y))
double code(double x, double y, double z) {
return (y * 0.25) / y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y * 0.25d0) / y
end function
public static double code(double x, double y, double z) {
return (y * 0.25) / y;
}
def code(x, y, z): return (y * 0.25) / y
function code(x, y, z) return Float64(Float64(y * 0.25) / y) end
function tmp = code(x, y, z) tmp = (y * 0.25) / y; end
code[x_, y_, z_] := N[(N[(y * 0.25), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{y \cdot 0.25}{y}
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites73.5%
Taylor expanded in x around inf
Applied rewrites7.1%
(FPCore (x y z) :precision binary64 (+ 1.0 (+ 1.0 (* y 0.25))))
double code(double x, double y, double z) {
return 1.0 + (1.0 + (y * 0.25));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 + (1.0d0 + (y * 0.25d0))
end function
public static double code(double x, double y, double z) {
return 1.0 + (1.0 + (y * 0.25));
}
def code(x, y, z): return 1.0 + (1.0 + (y * 0.25))
function code(x, y, z) return Float64(1.0 + Float64(1.0 + Float64(y * 0.25))) end
function tmp = code(x, y, z) tmp = 1.0 + (1.0 + (y * 0.25)); end
code[x_, y_, z_] := N[(1.0 + N[(1.0 + N[(y * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \left(1 + y \cdot 0.25\right)
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites3.9%
Taylor expanded in x around 0
Applied rewrites7.6%
Taylor expanded in x around 0
Applied rewrites3.4%
Taylor expanded in x around 0
Applied rewrites5.7%
(FPCore (x y z) :precision binary64 (+ 1.0 (* y 0.25)))
double code(double x, double y, double z) {
return 1.0 + (y * 0.25);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 + (y * 0.25d0)
end function
public static double code(double x, double y, double z) {
return 1.0 + (y * 0.25);
}
def code(x, y, z): return 1.0 + (y * 0.25)
function code(x, y, z) return Float64(1.0 + Float64(y * 0.25)) end
function tmp = code(x, y, z) tmp = 1.0 + (y * 0.25); end
code[x_, y_, z_] := N[(1.0 + N[(y * 0.25), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + y \cdot 0.25
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites3.9%
Taylor expanded in x around 0
Applied rewrites7.6%
Taylor expanded in x around 0
Applied rewrites3.4%
(FPCore (x y z) :precision binary64 (+ x (* y 0.25)))
double code(double x, double y, double z) {
return x + (y * 0.25);
}
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 * 0.25d0)
end function
public static double code(double x, double y, double z) {
return x + (y * 0.25);
}
def code(x, y, z): return x + (y * 0.25)
function code(x, y, z) return Float64(x + Float64(y * 0.25)) end
function tmp = code(x, y, z) tmp = x + (y * 0.25); end
code[x_, y_, z_] := N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot 0.25
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites3.9%
Taylor expanded in x around 0
Applied rewrites7.6%
Taylor expanded in x around inf
Applied rewrites3.1%
(FPCore (x y z) :precision binary64 (* y 0.25))
double code(double x, double y, double z) {
return y * 0.25;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y * 0.25d0
end function
public static double code(double x, double y, double z) {
return y * 0.25;
}
def code(x, y, z): return y * 0.25
function code(x, y, z) return Float64(y * 0.25) end
function tmp = code(x, y, z) tmp = y * 0.25; end
code[x_, y_, z_] := N[(y * 0.25), $MachinePrecision]
\begin{array}{l}
\\
y \cdot 0.25
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites73.5%
Taylor expanded in x around inf
Applied rewrites2.6%
herbie shell --seed 2024321
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, C"
:precision binary64
:pre (TRUE)
(+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))