
(FPCore (x y) :precision binary64 (* (* (- x (/ 16.0 116.0)) 3.0) y))
double code(double x, double y) {
return ((x - (16.0 / 116.0)) * 3.0) * y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x - (16.0d0 / 116.0d0)) * 3.0d0) * y
end function
public static double code(double x, double y) {
return ((x - (16.0 / 116.0)) * 3.0) * y;
}
def code(x, y): return ((x - (16.0 / 116.0)) * 3.0) * y
function code(x, y) return Float64(Float64(Float64(x - Float64(16.0 / 116.0)) * 3.0) * y) end
function tmp = code(x, y) tmp = ((x - (16.0 / 116.0)) * 3.0) * y; end
code[x_, y_] := N[(N[(N[(x - N[(16.0 / 116.0), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision] * y), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - \frac{16}{116}\right) \cdot 3\right) \cdot y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (* (* (- x (/ 16.0 116.0)) 3.0) y))
double code(double x, double y) {
return ((x - (16.0 / 116.0)) * 3.0) * y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x - (16.0d0 / 116.0d0)) * 3.0d0) * y
end function
public static double code(double x, double y) {
return ((x - (16.0 / 116.0)) * 3.0) * y;
}
def code(x, y): return ((x - (16.0 / 116.0)) * 3.0) * y
function code(x, y) return Float64(Float64(Float64(x - Float64(16.0 / 116.0)) * 3.0) * y) end
function tmp = code(x, y) tmp = ((x - (16.0 / 116.0)) * 3.0) * y; end
code[x_, y_] := N[(N[(N[(x - N[(16.0 / 116.0), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision] * y), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - \frac{16}{116}\right) \cdot 3\right) \cdot y
\end{array}
(FPCore (x y) :precision binary64 (* (* (- x 0.13793103448275862) 3.0) y))
double code(double x, double y) {
return ((x - 0.13793103448275862) * 3.0) * y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x - 0.13793103448275862d0) * 3.0d0) * y
end function
public static double code(double x, double y) {
return ((x - 0.13793103448275862) * 3.0) * y;
}
def code(x, y): return ((x - 0.13793103448275862) * 3.0) * y
function code(x, y) return Float64(Float64(Float64(x - 0.13793103448275862) * 3.0) * y) end
function tmp = code(x, y) tmp = ((x - 0.13793103448275862) * 3.0) * y; end
code[x_, y_] := N[(N[(N[(x - 0.13793103448275862), $MachinePrecision] * 3.0), $MachinePrecision] * y), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - 0.13793103448275862\right) \cdot 3\right) \cdot y
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (or (<= x -0.14) (not (<= x 0.135))) (* y (* x 3.0)) (* y -0.41379310344827586)))
double code(double x, double y) {
double tmp;
if ((x <= -0.14) || !(x <= 0.135)) {
tmp = y * (x * 3.0);
} else {
tmp = y * -0.41379310344827586;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-0.14d0)) .or. (.not. (x <= 0.135d0))) then
tmp = y * (x * 3.0d0)
else
tmp = y * (-0.41379310344827586d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -0.14) || !(x <= 0.135)) {
tmp = y * (x * 3.0);
} else {
tmp = y * -0.41379310344827586;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -0.14) or not (x <= 0.135): tmp = y * (x * 3.0) else: tmp = y * -0.41379310344827586 return tmp
function code(x, y) tmp = 0.0 if ((x <= -0.14) || !(x <= 0.135)) tmp = Float64(y * Float64(x * 3.0)); else tmp = Float64(y * -0.41379310344827586); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -0.14) || ~((x <= 0.135))) tmp = y * (x * 3.0); else tmp = y * -0.41379310344827586; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -0.14], N[Not[LessEqual[x, 0.135]], $MachinePrecision]], N[(y * N[(x * 3.0), $MachinePrecision]), $MachinePrecision], N[(y * -0.41379310344827586), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.14 \lor \neg \left(x \leq 0.135\right):\\
\;\;\;\;y \cdot \left(x \cdot 3\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot -0.41379310344827586\\
\end{array}
\end{array}
if x < -0.14000000000000001 or 0.13500000000000001 < x Initial program 99.8%
Taylor expanded in x around inf 98.3%
if -0.14000000000000001 < x < 0.13500000000000001Initial program 99.8%
Taylor expanded in x around 0 99.1%
Final simplification98.7%
(FPCore (x y) :precision binary64 (if (or (<= x -0.14) (not (<= x 0.135))) (* x (* 3.0 y)) (* y -0.41379310344827586)))
double code(double x, double y) {
double tmp;
if ((x <= -0.14) || !(x <= 0.135)) {
tmp = x * (3.0 * y);
} else {
tmp = y * -0.41379310344827586;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-0.14d0)) .or. (.not. (x <= 0.135d0))) then
tmp = x * (3.0d0 * y)
else
tmp = y * (-0.41379310344827586d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -0.14) || !(x <= 0.135)) {
tmp = x * (3.0 * y);
} else {
tmp = y * -0.41379310344827586;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -0.14) or not (x <= 0.135): tmp = x * (3.0 * y) else: tmp = y * -0.41379310344827586 return tmp
function code(x, y) tmp = 0.0 if ((x <= -0.14) || !(x <= 0.135)) tmp = Float64(x * Float64(3.0 * y)); else tmp = Float64(y * -0.41379310344827586); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -0.14) || ~((x <= 0.135))) tmp = x * (3.0 * y); else tmp = y * -0.41379310344827586; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -0.14], N[Not[LessEqual[x, 0.135]], $MachinePrecision]], N[(x * N[(3.0 * y), $MachinePrecision]), $MachinePrecision], N[(y * -0.41379310344827586), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.14 \lor \neg \left(x \leq 0.135\right):\\
\;\;\;\;x \cdot \left(3 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot -0.41379310344827586\\
\end{array}
\end{array}
if x < -0.14000000000000001 or 0.13500000000000001 < x Initial program 99.8%
Taylor expanded in x around inf 98.2%
*-commutative98.2%
associate-*r*98.3%
Simplified98.3%
if -0.14000000000000001 < x < 0.13500000000000001Initial program 99.8%
Taylor expanded in x around 0 99.1%
Final simplification98.7%
(FPCore (x y) :precision binary64 (if (or (<= x -0.14) (not (<= x 0.135))) (* 3.0 (* x y)) (* y -0.41379310344827586)))
double code(double x, double y) {
double tmp;
if ((x <= -0.14) || !(x <= 0.135)) {
tmp = 3.0 * (x * y);
} else {
tmp = y * -0.41379310344827586;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-0.14d0)) .or. (.not. (x <= 0.135d0))) then
tmp = 3.0d0 * (x * y)
else
tmp = y * (-0.41379310344827586d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -0.14) || !(x <= 0.135)) {
tmp = 3.0 * (x * y);
} else {
tmp = y * -0.41379310344827586;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -0.14) or not (x <= 0.135): tmp = 3.0 * (x * y) else: tmp = y * -0.41379310344827586 return tmp
function code(x, y) tmp = 0.0 if ((x <= -0.14) || !(x <= 0.135)) tmp = Float64(3.0 * Float64(x * y)); else tmp = Float64(y * -0.41379310344827586); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -0.14) || ~((x <= 0.135))) tmp = 3.0 * (x * y); else tmp = y * -0.41379310344827586; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -0.14], N[Not[LessEqual[x, 0.135]], $MachinePrecision]], N[(3.0 * N[(x * y), $MachinePrecision]), $MachinePrecision], N[(y * -0.41379310344827586), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.14 \lor \neg \left(x \leq 0.135\right):\\
\;\;\;\;3 \cdot \left(x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot -0.41379310344827586\\
\end{array}
\end{array}
if x < -0.14000000000000001 or 0.13500000000000001 < x Initial program 99.8%
Taylor expanded in x around inf 98.2%
if -0.14000000000000001 < x < 0.13500000000000001Initial program 99.8%
Taylor expanded in x around 0 99.1%
Final simplification98.6%
(FPCore (x y) :precision binary64 (* y (- (* x 3.0) 0.41379310344827586)))
double code(double x, double y) {
return y * ((x * 3.0) - 0.41379310344827586);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y * ((x * 3.0d0) - 0.41379310344827586d0)
end function
public static double code(double x, double y) {
return y * ((x * 3.0) - 0.41379310344827586);
}
def code(x, y): return y * ((x * 3.0) - 0.41379310344827586)
function code(x, y) return Float64(y * Float64(Float64(x * 3.0) - 0.41379310344827586)) end
function tmp = code(x, y) tmp = y * ((x * 3.0) - 0.41379310344827586); end
code[x_, y_] := N[(y * N[(N[(x * 3.0), $MachinePrecision] - 0.41379310344827586), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \left(x \cdot 3 - 0.41379310344827586\right)
\end{array}
Initial program 99.8%
Taylor expanded in x around 0 99.8%
Final simplification99.8%
(FPCore (x y) :precision binary64 (* (+ x -0.13793103448275862) (* 3.0 y)))
double code(double x, double y) {
return (x + -0.13793103448275862) * (3.0 * y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x + (-0.13793103448275862d0)) * (3.0d0 * y)
end function
public static double code(double x, double y) {
return (x + -0.13793103448275862) * (3.0 * y);
}
def code(x, y): return (x + -0.13793103448275862) * (3.0 * y)
function code(x, y) return Float64(Float64(x + -0.13793103448275862) * Float64(3.0 * y)) end
function tmp = code(x, y) tmp = (x + -0.13793103448275862) * (3.0 * y); end
code[x_, y_] := N[(N[(x + -0.13793103448275862), $MachinePrecision] * N[(3.0 * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + -0.13793103448275862\right) \cdot \left(3 \cdot y\right)
\end{array}
Initial program 99.8%
associate-*l*99.6%
sub-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
Simplified99.6%
(FPCore (x y) :precision binary64 (* 3.0 (* (- x 0.13793103448275862) y)))
double code(double x, double y) {
return 3.0 * ((x - 0.13793103448275862) * y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 3.0d0 * ((x - 0.13793103448275862d0) * y)
end function
public static double code(double x, double y) {
return 3.0 * ((x - 0.13793103448275862) * y);
}
def code(x, y): return 3.0 * ((x - 0.13793103448275862) * y)
function code(x, y) return Float64(3.0 * Float64(Float64(x - 0.13793103448275862) * y)) end
function tmp = code(x, y) tmp = 3.0 * ((x - 0.13793103448275862) * y); end
code[x_, y_] := N[(3.0 * N[(N[(x - 0.13793103448275862), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
3 \cdot \left(\left(x - 0.13793103448275862\right) \cdot y\right)
\end{array}
Initial program 99.8%
Taylor expanded in y around 0 99.6%
Final simplification99.6%
(FPCore (x y) :precision binary64 (* y -0.41379310344827586))
double code(double x, double y) {
return y * -0.41379310344827586;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y * (-0.41379310344827586d0)
end function
public static double code(double x, double y) {
return y * -0.41379310344827586;
}
def code(x, y): return y * -0.41379310344827586
function code(x, y) return Float64(y * -0.41379310344827586) end
function tmp = code(x, y) tmp = y * -0.41379310344827586; end
code[x_, y_] := N[(y * -0.41379310344827586), $MachinePrecision]
\begin{array}{l}
\\
y \cdot -0.41379310344827586
\end{array}
Initial program 99.8%
Taylor expanded in x around 0 48.9%
Final simplification48.9%
(FPCore (x y) :precision binary64 (* y (- (* x 3.0) 0.41379310344827586)))
double code(double x, double y) {
return y * ((x * 3.0) - 0.41379310344827586);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y * ((x * 3.0d0) - 0.41379310344827586d0)
end function
public static double code(double x, double y) {
return y * ((x * 3.0) - 0.41379310344827586);
}
def code(x, y): return y * ((x * 3.0) - 0.41379310344827586)
function code(x, y) return Float64(y * Float64(Float64(x * 3.0) - 0.41379310344827586)) end
function tmp = code(x, y) tmp = y * ((x * 3.0) - 0.41379310344827586); end
code[x_, y_] := N[(y * N[(N[(x * 3.0), $MachinePrecision] - 0.41379310344827586), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \left(x \cdot 3 - 0.41379310344827586\right)
\end{array}
herbie shell --seed 2024154
(FPCore (x y)
:name "Data.Colour.CIE:cieLAB from colour-2.3.3, A"
:precision binary64
:alt
(! :herbie-platform default (* y (- (* x 3) 20689655172413793/50000000000000000)))
(* (* (- x (/ 16.0 116.0)) 3.0) y))