
(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 11 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
(let* ((t_0 (+ 1.0 (/ (* y 0.25) y))))
(if (<= y -0.032)
t_0
(if (<= y 1.16e+30) (+ 1.0 (+ 1.0 (- (+ x (* y 0.25)) z))) t_0))))
double code(double x, double y, double z) {
double t_0 = 1.0 + ((y * 0.25) / y);
double tmp;
if (y <= -0.032) {
tmp = t_0;
} else if (y <= 1.16e+30) {
tmp = 1.0 + (1.0 + ((x + (y * 0.25)) - 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 = 1.0d0 + ((y * 0.25d0) / y)
if (y <= (-0.032d0)) then
tmp = t_0
else if (y <= 1.16d+30) then
tmp = 1.0d0 + (1.0d0 + ((x + (y * 0.25d0)) - z))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 + ((y * 0.25) / y);
double tmp;
if (y <= -0.032) {
tmp = t_0;
} else if (y <= 1.16e+30) {
tmp = 1.0 + (1.0 + ((x + (y * 0.25)) - z));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + ((y * 0.25) / y) tmp = 0 if y <= -0.032: tmp = t_0 elif y <= 1.16e+30: tmp = 1.0 + (1.0 + ((x + (y * 0.25)) - z)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(Float64(y * 0.25) / y)) tmp = 0.0 if (y <= -0.032) tmp = t_0; elseif (y <= 1.16e+30) tmp = Float64(1.0 + Float64(1.0 + Float64(Float64(x + Float64(y * 0.25)) - z))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + ((y * 0.25) / y); tmp = 0.0; if (y <= -0.032) tmp = t_0; elseif (y <= 1.16e+30) tmp = 1.0 + (1.0 + ((x + (y * 0.25)) - z)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(N[(y * 0.25), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -0.032], t$95$0, If[LessEqual[y, 1.16e+30], N[(1.0 + N[(1.0 + N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{y \cdot 0.25}{y}\\
\mathbf{if}\;y \leq -0.032:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.16 \cdot 10^{+30}:\\
\;\;\;\;1 + \left(1 + \left(\left(x + y \cdot 0.25\right) - z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -0.032000000000000001 or 1.16e30 < y Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites13.8%
if -0.032000000000000001 < y < 1.16e30Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites6.5%
Taylor expanded in x around 0
Applied rewrites17.3%
(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 rewrites68.3%
(FPCore (x y z) :precision binary64 (if (<= y -0.032) (/ (* 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 <= -0.032) {
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 <= (-0.032d0)) 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 <= -0.032) {
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 <= -0.032: 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 <= -0.032) 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 <= -0.032) 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, -0.032], 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 -0.032:\\
\;\;\;\;\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 < -0.032000000000000001Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites44.2%
Taylor expanded in x around inf
Applied rewrites12.0%
if -0.032000000000000001 < y Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites6.0%
Taylor expanded in x around 0
Applied rewrites13.8%
(FPCore (x y z) :precision binary64 (if (<= y -16000000.0) (/ (* y 0.25) y) (+ 1.0 (+ 1.0 (- (* y 0.25) z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -16000000.0) {
tmp = (y * 0.25) / y;
} else {
tmp = 1.0 + (1.0 + ((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 <= (-16000000.0d0)) then
tmp = (y * 0.25d0) / y
else
tmp = 1.0d0 + (1.0d0 + ((y * 0.25d0) - z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -16000000.0) {
tmp = (y * 0.25) / y;
} else {
tmp = 1.0 + (1.0 + ((y * 0.25) - z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -16000000.0: tmp = (y * 0.25) / y else: tmp = 1.0 + (1.0 + ((y * 0.25) - z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -16000000.0) tmp = Float64(Float64(y * 0.25) / y); else tmp = Float64(1.0 + Float64(1.0 + Float64(Float64(y * 0.25) - z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -16000000.0) tmp = (y * 0.25) / y; else tmp = 1.0 + (1.0 + ((y * 0.25) - z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -16000000.0], N[(N[(y * 0.25), $MachinePrecision] / y), $MachinePrecision], N[(1.0 + N[(1.0 + N[(N[(y * 0.25), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -16000000:\\
\;\;\;\;\frac{y \cdot 0.25}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + \left(1 + \left(y \cdot 0.25 - z\right)\right)\\
\end{array}
\end{array}
if y < -1.6e7Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites41.6%
Taylor expanded in x around inf
Applied rewrites12.5%
if -1.6e7 < y Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites5.9%
Taylor expanded in x around 0
Applied rewrites13.6%
Taylor expanded in x around 0
Applied rewrites12.8%
(FPCore (x y z) :precision binary64 (+ 1.0 (+ 1.0 (- (* y 0.25) z))))
double code(double x, double y, double z) {
return 1.0 + (1.0 + ((y * 0.25) - z));
}
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) - z))
end function
public static double code(double x, double y, double z) {
return 1.0 + (1.0 + ((y * 0.25) - z));
}
def code(x, y, z): return 1.0 + (1.0 + ((y * 0.25) - z))
function code(x, y, z) return Float64(1.0 + Float64(1.0 + Float64(Float64(y * 0.25) - z))) end
function tmp = code(x, y, z) tmp = 1.0 + (1.0 + ((y * 0.25) - z)); end
code[x_, y_, z_] := N[(1.0 + N[(1.0 + N[(N[(y * 0.25), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \left(1 + \left(y \cdot 0.25 - z\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites4.7%
Taylor expanded in x around 0
Applied rewrites10.4%
Taylor expanded in x around 0
Applied rewrites9.9%
(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 rewrites5.0%
Taylor expanded in x around 0
Applied rewrites5.0%
Taylor expanded in x around 0
Applied rewrites9.6%
(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 rewrites4.7%
Taylor expanded in x around 0
Applied rewrites10.4%
Taylor expanded in x around 0
Applied rewrites3.8%
(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 rewrites4.7%
Taylor expanded in x around 0
Applied rewrites10.4%
Taylor expanded in x around inf
Applied rewrites3.4%
(FPCore (x y z) :precision binary64 (- (* y 0.25) z))
double code(double x, double y, double z) {
return (y * 0.25) - z;
}
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) - z
end function
public static double code(double x, double y, double z) {
return (y * 0.25) - z;
}
def code(x, y, z): return (y * 0.25) - z
function code(x, y, z) return Float64(Float64(y * 0.25) - z) end
function tmp = code(x, y, z) tmp = (y * 0.25) - z; end
code[x_, y_, z_] := N[(N[(y * 0.25), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
y \cdot 0.25 - z
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites68.3%
Taylor expanded in x around 0
Applied rewrites3.7%
Taylor expanded in x around 0
Applied rewrites3.2%
(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 rewrites68.3%
Taylor expanded in x around inf
Applied rewrites2.7%
herbie shell --seed 2024313
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, C"
:precision binary64
(+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))