
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - 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.75d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.75)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\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.75)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - 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.75d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.75)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\right) - z\right)}{y}
\end{array}
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - 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.75d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.75)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\right) - z\right)}{y}
\end{array}
Initial program 99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ x (* y 0.75))) (t_1 (/ t_0 y)))
(if (<= x -4.6e-55)
t_1
(if (<= x 7e-72) (* 4.0 (- (+ 1.0 (- t_0 z)) z)) t_1))))
double code(double x, double y, double z) {
double t_0 = x + (y * 0.75);
double t_1 = t_0 / y;
double tmp;
if (x <= -4.6e-55) {
tmp = t_1;
} else if (x <= 7e-72) {
tmp = 4.0 * ((1.0 + (t_0 - z)) - 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 * 0.75d0)
t_1 = t_0 / y
if (x <= (-4.6d-55)) then
tmp = t_1
else if (x <= 7d-72) then
tmp = 4.0d0 * ((1.0d0 + (t_0 - z)) - 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 * 0.75);
double t_1 = t_0 / y;
double tmp;
if (x <= -4.6e-55) {
tmp = t_1;
} else if (x <= 7e-72) {
tmp = 4.0 * ((1.0 + (t_0 - z)) - z);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = x + (y * 0.75) t_1 = t_0 / y tmp = 0 if x <= -4.6e-55: tmp = t_1 elif x <= 7e-72: tmp = 4.0 * ((1.0 + (t_0 - z)) - z) else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(x + Float64(y * 0.75)) t_1 = Float64(t_0 / y) tmp = 0.0 if (x <= -4.6e-55) tmp = t_1; elseif (x <= 7e-72) tmp = Float64(4.0 * Float64(Float64(1.0 + Float64(t_0 - z)) - z)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x + (y * 0.75); t_1 = t_0 / y; tmp = 0.0; if (x <= -4.6e-55) tmp = t_1; elseif (x <= 7e-72) tmp = 4.0 * ((1.0 + (t_0 - z)) - z); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / y), $MachinePrecision]}, If[LessEqual[x, -4.6e-55], t$95$1, If[LessEqual[x, 7e-72], N[(4.0 * N[(N[(1.0 + N[(t$95$0 - z), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + y \cdot 0.75\\
t_1 := \frac{t\_0}{y}\\
\mathbf{if}\;x \leq -4.6 \cdot 10^{-55}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 7 \cdot 10^{-72}:\\
\;\;\;\;4 \cdot \left(\left(1 + \left(t\_0 - z\right)\right) - z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -4.60000000000000023e-55 or 7.00000000000000001e-72 < x Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites78.2%
Taylor expanded in x around inf
Applied rewrites31.9%
if -4.60000000000000023e-55 < x < 7.00000000000000001e-72Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites57.1%
Taylor expanded in x around 0
Applied rewrites3.7%
Taylor expanded in x around inf
Applied rewrites18.5%
(FPCore (x y z) :precision binary64 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y))
double code(double x, double y, double z) {
return (4.0 * ((x + (y * 0.75)) - 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.75d0)) - z)) / y
end function
public static double code(double x, double y, double z) {
return (4.0 * ((x + (y * 0.75)) - z)) / y;
}
def code(x, y, z): return (4.0 * ((x + (y * 0.75)) - z)) / y
function code(x, y, z) return Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.75)) - z)) / y) end
function tmp = code(x, y, z) tmp = (4.0 * ((x + (y * 0.75)) - z)) / y; end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{4 \cdot \left(\left(x + y \cdot 0.75\right) - z\right)}{y}
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites68.9%
(FPCore (x y z) :precision binary64 (/ (- (+ x (* y 0.75)) z) y))
double code(double x, double y, double z) {
return ((x + (y * 0.75)) - 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 = ((x + (y * 0.75d0)) - z) / y
end function
public static double code(double x, double y, double z) {
return ((x + (y * 0.75)) - z) / y;
}
def code(x, y, z): return ((x + (y * 0.75)) - z) / y
function code(x, y, z) return Float64(Float64(Float64(x + Float64(y * 0.75)) - z) / y) end
function tmp = code(x, y, z) tmp = ((x + (y * 0.75)) - z) / y; end
code[x_, y_, z_] := N[(N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x + y \cdot 0.75\right) - z}{y}
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites68.9%
Taylor expanded in x around inf
Applied rewrites22.7%
Taylor expanded in x around 0
Applied rewrites36.4%
(FPCore (x y z) :precision binary64 (/ (+ x (* y 0.75)) y))
double code(double x, double y, double z) {
return (x + (y * 0.75)) / 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 * 0.75d0)) / y
end function
public static double code(double x, double y, double z) {
return (x + (y * 0.75)) / y;
}
def code(x, y, z): return (x + (y * 0.75)) / y
function code(x, y, z) return Float64(Float64(x + Float64(y * 0.75)) / y) end
function tmp = code(x, y, z) tmp = (x + (y * 0.75)) / y; end
code[x_, y_, z_] := N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y \cdot 0.75}{y}
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites68.9%
Taylor expanded in x around inf
Applied rewrites22.7%
(FPCore (x y z) :precision binary64 (/ (* y 0.75) y))
double code(double x, double y, double z) {
return (y * 0.75) / 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.75d0) / y
end function
public static double code(double x, double y, double z) {
return (y * 0.75) / y;
}
def code(x, y, z): return (y * 0.75) / y
function code(x, y, z) return Float64(Float64(y * 0.75) / y) end
function tmp = code(x, y, z) tmp = (y * 0.75) / y; end
code[x_, y_, z_] := N[(N[(y * 0.75), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{y \cdot 0.75}{y}
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites68.9%
Taylor expanded in x around inf
Applied rewrites22.7%
Taylor expanded in x around 0
Applied rewrites7.9%
(FPCore (x y z) :precision binary64 (+ 1.0 (- (+ x (* y 0.75)) z)))
double code(double x, double y, double z) {
return 1.0 + ((x + (y * 0.75)) - 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 + ((x + (y * 0.75d0)) - z)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((x + (y * 0.75)) - z);
}
def code(x, y, z): return 1.0 + ((x + (y * 0.75)) - z)
function code(x, y, z) return Float64(1.0 + Float64(Float64(x + Float64(y * 0.75)) - z)) end
function tmp = code(x, y, z) tmp = 1.0 + ((x + (y * 0.75)) - z); end
code[x_, y_, z_] := N[(1.0 + N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \left(\left(x + y \cdot 0.75\right) - z\right)
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites4.5%
(FPCore (x y z) :precision binary64 (- (- (+ x (* y 0.75)) z) z))
double code(double x, double y, double z) {
return ((x + (y * 0.75)) - z) - 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 * 0.75d0)) - z) - z
end function
public static double code(double x, double y, double z) {
return ((x + (y * 0.75)) - z) - z;
}
def code(x, y, z): return ((x + (y * 0.75)) - z) - z
function code(x, y, z) return Float64(Float64(Float64(x + Float64(y * 0.75)) - z) - z) end
function tmp = code(x, y, z) tmp = ((x + (y * 0.75)) - z) - z; end
code[x_, y_, z_] := N[(N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x + y \cdot 0.75\right) - z\right) - z
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites68.9%
Taylor expanded in x around 0
Applied rewrites3.7%
Taylor expanded in x around 0
Applied rewrites3.7%
(FPCore (x y z) :precision binary64 (- (+ x (* y 0.75)) z))
double code(double x, double y, double z) {
return (x + (y * 0.75)) - 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 * 0.75d0)) - z
end function
public static double code(double x, double y, double z) {
return (x + (y * 0.75)) - z;
}
def code(x, y, z): return (x + (y * 0.75)) - z
function code(x, y, z) return Float64(Float64(x + Float64(y * 0.75)) - z) end
function tmp = code(x, y, z) tmp = (x + (y * 0.75)) - z; end
code[x_, y_, z_] := N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(x + y \cdot 0.75\right) - z
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites68.9%
Taylor expanded in x around 0
Applied rewrites3.7%
(FPCore (x y z) :precision binary64 (+ x (* y 0.75)))
double code(double x, double y, double z) {
return x + (y * 0.75);
}
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.75d0)
end function
public static double code(double x, double y, double z) {
return x + (y * 0.75);
}
def code(x, y, z): return x + (y * 0.75)
function code(x, y, z) return Float64(x + Float64(y * 0.75)) end
function tmp = code(x, y, z) tmp = x + (y * 0.75); end
code[x_, y_, z_] := N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot 0.75
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites68.9%
Taylor expanded in x around inf
Applied rewrites3.4%
(FPCore (x y z) :precision binary64 (* y 0.75))
double code(double x, double y, double z) {
return y * 0.75;
}
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.75d0
end function
public static double code(double x, double y, double z) {
return y * 0.75;
}
def code(x, y, z): return y * 0.75
function code(x, y, z) return Float64(y * 0.75) end
function tmp = code(x, y, z) tmp = y * 0.75; end
code[x_, y_, z_] := N[(y * 0.75), $MachinePrecision]
\begin{array}{l}
\\
y \cdot 0.75
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites68.9%
Taylor expanded in x around inf
Applied rewrites3.4%
Taylor expanded in x around 0
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, A"
:precision binary64
(+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))