
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))
double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * ((2.0 / 3.0) - 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 - x) * 6.0d0) * ((2.0d0 / 3.0d0) - z))
end function
public static double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z));
}
def code(x, y, z): return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z))
function code(x, y, z) return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * Float64(Float64(2.0 / 3.0) - z))) end
function tmp = code(x, y, z) tmp = x + (((y - x) * 6.0) * ((2.0 / 3.0) - z)); end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))
double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * ((2.0 / 3.0) - 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 - x) * 6.0d0) * ((2.0d0 / 3.0d0) - z))
end function
public static double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z));
}
def code(x, y, z): return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z))
function code(x, y, z) return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * Float64(Float64(2.0 / 3.0) - z))) end
function tmp = code(x, y, z) tmp = x + (((y - x) * 6.0) * ((2.0 / 3.0) - z)); end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)
\end{array}
(FPCore (x y z) :precision binary64 (fma (- y x) (+ 4.0 (* z -6.0)) x))
double code(double x, double y, double z) {
return fma((y - x), (4.0 + (z * -6.0)), x);
}
function code(x, y, z) return fma(Float64(y - x), Float64(4.0 + Float64(z * -6.0)), x) end
code[x_, y_, z_] := N[(N[(y - x), $MachinePrecision] * N[(4.0 + N[(z * -6.0), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y - x, 4 + z \cdot -6, x\right)
\end{array}
Initial program 99.5%
+-commutative99.5%
associate-*l*99.8%
fma-define99.8%
sub-neg99.8%
distribute-rgt-in99.8%
metadata-eval99.8%
metadata-eval99.8%
distribute-lft-neg-out99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.66) (not (<= z 0.5))) (+ x (* (- y x) (* z -6.0))) (+ x (* (- y x) 4.0))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.66) || !(z <= 0.5)) {
tmp = x + ((y - x) * (z * -6.0));
} else {
tmp = x + ((y - x) * 4.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) :: tmp
if ((z <= (-0.66d0)) .or. (.not. (z <= 0.5d0))) then
tmp = x + ((y - x) * (z * (-6.0d0)))
else
tmp = x + ((y - x) * 4.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.66) || !(z <= 0.5)) {
tmp = x + ((y - x) * (z * -6.0));
} else {
tmp = x + ((y - x) * 4.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.66) or not (z <= 0.5): tmp = x + ((y - x) * (z * -6.0)) else: tmp = x + ((y - x) * 4.0) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.66) || !(z <= 0.5)) tmp = Float64(x + Float64(Float64(y - x) * Float64(z * -6.0))); else tmp = Float64(x + Float64(Float64(y - x) * 4.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.66) || ~((z <= 0.5))) tmp = x + ((y - x) * (z * -6.0)); else tmp = x + ((y - x) * 4.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.66], N[Not[LessEqual[z, 0.5]], $MachinePrecision]], N[(x + N[(N[(y - x), $MachinePrecision] * N[(z * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y - x), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.66 \lor \neg \left(z \leq 0.5\right):\\
\;\;\;\;x + \left(y - x\right) \cdot \left(z \cdot -6\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(y - x\right) \cdot 4\\
\end{array}
\end{array}
if z < -0.660000000000000031 or 0.5 < z Initial program 99.7%
+-commutative99.7%
associate-*l*99.8%
fma-define99.8%
metadata-eval99.8%
Simplified99.8%
fma-undefine99.8%
Applied egg-rr99.8%
Taylor expanded in z around inf 98.8%
if -0.660000000000000031 < z < 0.5Initial program 99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in z around 0 96.2%
Final simplification97.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.66) (not (<= z 0.52))) (+ x (* -6.0 (* (- y x) z))) (+ x (* (- y x) 4.0))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.66) || !(z <= 0.52)) {
tmp = x + (-6.0 * ((y - x) * z));
} else {
tmp = x + ((y - x) * 4.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) :: tmp
if ((z <= (-0.66d0)) .or. (.not. (z <= 0.52d0))) then
tmp = x + ((-6.0d0) * ((y - x) * z))
else
tmp = x + ((y - x) * 4.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.66) || !(z <= 0.52)) {
tmp = x + (-6.0 * ((y - x) * z));
} else {
tmp = x + ((y - x) * 4.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.66) or not (z <= 0.52): tmp = x + (-6.0 * ((y - x) * z)) else: tmp = x + ((y - x) * 4.0) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.66) || !(z <= 0.52)) tmp = Float64(x + Float64(-6.0 * Float64(Float64(y - x) * z))); else tmp = Float64(x + Float64(Float64(y - x) * 4.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.66) || ~((z <= 0.52))) tmp = x + (-6.0 * ((y - x) * z)); else tmp = x + ((y - x) * 4.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.66], N[Not[LessEqual[z, 0.52]], $MachinePrecision]], N[(x + N[(-6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y - x), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.66 \lor \neg \left(z \leq 0.52\right):\\
\;\;\;\;x + -6 \cdot \left(\left(y - x\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(y - x\right) \cdot 4\\
\end{array}
\end{array}
if z < -0.660000000000000031 or 0.52000000000000002 < z Initial program 99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 98.7%
if -0.660000000000000031 < z < 0.52000000000000002Initial program 99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in z around 0 96.2%
Final simplification97.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.2e-11) (not (<= y 2.46e+61))) (* y (+ 4.0 (* z -6.0))) (* x (+ -3.0 (* z 6.0)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.2e-11) || !(y <= 2.46e+61)) {
tmp = y * (4.0 + (z * -6.0));
} else {
tmp = x * (-3.0 + (z * 6.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) :: tmp
if ((y <= (-3.2d-11)) .or. (.not. (y <= 2.46d+61))) then
tmp = y * (4.0d0 + (z * (-6.0d0)))
else
tmp = x * ((-3.0d0) + (z * 6.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -3.2e-11) || !(y <= 2.46e+61)) {
tmp = y * (4.0 + (z * -6.0));
} else {
tmp = x * (-3.0 + (z * 6.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.2e-11) or not (y <= 2.46e+61): tmp = y * (4.0 + (z * -6.0)) else: tmp = x * (-3.0 + (z * 6.0)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.2e-11) || !(y <= 2.46e+61)) tmp = Float64(y * Float64(4.0 + Float64(z * -6.0))); else tmp = Float64(x * Float64(-3.0 + Float64(z * 6.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -3.2e-11) || ~((y <= 2.46e+61))) tmp = y * (4.0 + (z * -6.0)); else tmp = x * (-3.0 + (z * 6.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.2e-11], N[Not[LessEqual[y, 2.46e+61]], $MachinePrecision]], N[(y * N[(4.0 + N[(z * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(-3.0 + N[(z * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.2 \cdot 10^{-11} \lor \neg \left(y \leq 2.46 \cdot 10^{+61}\right):\\
\;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\
\end{array}
\end{array}
if y < -3.19999999999999994e-11 or 2.46e61 < y Initial program 99.6%
+-commutative99.6%
associate-*l*99.9%
fma-define99.9%
sub-neg99.9%
distribute-rgt-in99.9%
metadata-eval99.9%
metadata-eval99.9%
distribute-lft-neg-out99.9%
distribute-rgt-neg-in99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 83.1%
if -3.19999999999999994e-11 < y < 2.46e61Initial program 99.5%
+-commutative99.5%
associate-*l*99.7%
fma-define99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around 0 79.4%
*-lft-identity79.4%
*-commutative79.4%
associate-*r*79.7%
sub-neg79.7%
distribute-rgt-in79.6%
metadata-eval79.6%
neg-mul-179.6%
associate-*r*79.6%
*-commutative79.6%
metadata-eval79.6%
distribute-lft-in79.6%
distribute-rgt-in79.7%
distribute-lft-in79.7%
metadata-eval79.7%
associate-+r+79.7%
metadata-eval79.7%
associate-*r*79.7%
metadata-eval79.7%
Simplified79.7%
Final simplification81.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.5) (not (<= z 12800.0))) (* 6.0 (* x z)) (* x -3.0)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.5) || !(z <= 12800.0)) {
tmp = 6.0 * (x * z);
} else {
tmp = x * -3.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) :: tmp
if ((z <= (-0.5d0)) .or. (.not. (z <= 12800.0d0))) then
tmp = 6.0d0 * (x * z)
else
tmp = x * (-3.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.5) || !(z <= 12800.0)) {
tmp = 6.0 * (x * z);
} else {
tmp = x * -3.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.5) or not (z <= 12800.0): tmp = 6.0 * (x * z) else: tmp = x * -3.0 return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.5) || !(z <= 12800.0)) tmp = Float64(6.0 * Float64(x * z)); else tmp = Float64(x * -3.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.5) || ~((z <= 12800.0))) tmp = 6.0 * (x * z); else tmp = x * -3.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.5], N[Not[LessEqual[z, 12800.0]], $MachinePrecision]], N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision], N[(x * -3.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.5 \lor \neg \left(z \leq 12800\right):\\
\;\;\;\;6 \cdot \left(x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot -3\\
\end{array}
\end{array}
if z < -0.5 or 12800 < z Initial program 99.7%
+-commutative99.7%
associate-*l*99.8%
fma-define99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 61.2%
*-lft-identity61.2%
*-commutative61.2%
associate-*r*61.3%
sub-neg61.3%
distribute-rgt-in61.3%
metadata-eval61.3%
neg-mul-161.3%
associate-*r*61.3%
*-commutative61.3%
metadata-eval61.3%
distribute-lft-in61.3%
distribute-rgt-in61.3%
distribute-lft-in61.3%
metadata-eval61.3%
associate-+r+61.3%
metadata-eval61.3%
associate-*r*61.3%
metadata-eval61.3%
Simplified61.3%
Taylor expanded in z around inf 60.9%
if -0.5 < z < 12800Initial program 99.4%
+-commutative99.4%
associate-*l*99.7%
fma-define99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around 0 52.0%
*-lft-identity52.0%
*-commutative52.0%
associate-*r*52.2%
sub-neg52.2%
distribute-rgt-in52.2%
metadata-eval52.2%
neg-mul-152.2%
associate-*r*52.2%
*-commutative52.2%
metadata-eval52.2%
distribute-lft-in52.2%
distribute-rgt-in52.2%
distribute-lft-in52.2%
metadata-eval52.2%
associate-+r+52.3%
metadata-eval52.3%
associate-*r*52.3%
metadata-eval52.3%
Simplified52.3%
Taylor expanded in z around 0 50.2%
*-commutative50.2%
Simplified50.2%
Final simplification55.4%
(FPCore (x y z) :precision binary64 (if (<= z -0.5) (* 6.0 (* x z)) (if (<= z 12800.0) (* x -3.0) (* x (* z 6.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -0.5) {
tmp = 6.0 * (x * z);
} else if (z <= 12800.0) {
tmp = x * -3.0;
} else {
tmp = x * (z * 6.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) :: tmp
if (z <= (-0.5d0)) then
tmp = 6.0d0 * (x * z)
else if (z <= 12800.0d0) then
tmp = x * (-3.0d0)
else
tmp = x * (z * 6.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -0.5) {
tmp = 6.0 * (x * z);
} else if (z <= 12800.0) {
tmp = x * -3.0;
} else {
tmp = x * (z * 6.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -0.5: tmp = 6.0 * (x * z) elif z <= 12800.0: tmp = x * -3.0 else: tmp = x * (z * 6.0) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -0.5) tmp = Float64(6.0 * Float64(x * z)); elseif (z <= 12800.0) tmp = Float64(x * -3.0); else tmp = Float64(x * Float64(z * 6.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -0.5) tmp = 6.0 * (x * z); elseif (z <= 12800.0) tmp = x * -3.0; else tmp = x * (z * 6.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -0.5], N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 12800.0], N[(x * -3.0), $MachinePrecision], N[(x * N[(z * 6.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.5:\\
\;\;\;\;6 \cdot \left(x \cdot z\right)\\
\mathbf{elif}\;z \leq 12800:\\
\;\;\;\;x \cdot -3\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(z \cdot 6\right)\\
\end{array}
\end{array}
if z < -0.5Initial program 99.8%
+-commutative99.8%
associate-*l*99.8%
fma-define99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 59.8%
*-lft-identity59.8%
*-commutative59.8%
associate-*r*59.7%
sub-neg59.7%
distribute-rgt-in59.7%
metadata-eval59.7%
neg-mul-159.7%
associate-*r*59.7%
*-commutative59.7%
metadata-eval59.7%
distribute-lft-in59.7%
distribute-rgt-in59.7%
distribute-lft-in59.7%
metadata-eval59.7%
associate-+r+59.7%
metadata-eval59.7%
associate-*r*59.7%
metadata-eval59.7%
Simplified59.7%
Taylor expanded in z around inf 59.4%
if -0.5 < z < 12800Initial program 99.4%
+-commutative99.4%
associate-*l*99.7%
fma-define99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around 0 52.0%
*-lft-identity52.0%
*-commutative52.0%
associate-*r*52.2%
sub-neg52.2%
distribute-rgt-in52.2%
metadata-eval52.2%
neg-mul-152.2%
associate-*r*52.2%
*-commutative52.2%
metadata-eval52.2%
distribute-lft-in52.2%
distribute-rgt-in52.2%
distribute-lft-in52.2%
metadata-eval52.2%
associate-+r+52.3%
metadata-eval52.3%
associate-*r*52.3%
metadata-eval52.3%
Simplified52.3%
Taylor expanded in z around 0 50.2%
*-commutative50.2%
Simplified50.2%
if 12800 < z Initial program 99.7%
+-commutative99.7%
associate-*l*99.8%
fma-define99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 62.7%
*-lft-identity62.7%
*-commutative62.7%
associate-*r*62.8%
sub-neg62.8%
distribute-rgt-in62.8%
metadata-eval62.8%
neg-mul-162.8%
associate-*r*62.8%
*-commutative62.8%
metadata-eval62.8%
distribute-lft-in62.8%
distribute-rgt-in62.8%
distribute-lft-in62.8%
metadata-eval62.8%
associate-+r+62.8%
metadata-eval62.8%
associate-*r*62.8%
metadata-eval62.8%
Simplified62.8%
Taylor expanded in z around inf 62.2%
associate-*r*62.2%
*-commutative62.2%
associate-*r*62.4%
*-commutative62.4%
Simplified62.4%
(FPCore (x y z) :precision binary64 (+ x (* (- y x) (* 6.0 (- 0.6666666666666666 z)))))
double code(double x, double y, double z) {
return x + ((y - x) * (6.0 * (0.6666666666666666 - 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 - x) * (6.0d0 * (0.6666666666666666d0 - z)))
end function
public static double code(double x, double y, double z) {
return x + ((y - x) * (6.0 * (0.6666666666666666 - z)));
}
def code(x, y, z): return x + ((y - x) * (6.0 * (0.6666666666666666 - z)))
function code(x, y, z) return Float64(x + Float64(Float64(y - x) * Float64(6.0 * Float64(0.6666666666666666 - z)))) end
function tmp = code(x, y, z) tmp = x + ((y - x) * (6.0 * (0.6666666666666666 - z))); end
code[x_, y_, z_] := N[(x + N[(N[(y - x), $MachinePrecision] * N[(6.0 * N[(0.6666666666666666 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)
\end{array}
Initial program 99.5%
+-commutative99.5%
associate-*l*99.8%
fma-define99.8%
metadata-eval99.8%
Simplified99.8%
fma-undefine99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (+ x (* (- 0.6666666666666666 z) (* (- y x) 6.0))))
double code(double x, double y, double z) {
return x + ((0.6666666666666666 - z) * ((y - x) * 6.0));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + ((0.6666666666666666d0 - z) * ((y - x) * 6.0d0))
end function
public static double code(double x, double y, double z) {
return x + ((0.6666666666666666 - z) * ((y - x) * 6.0));
}
def code(x, y, z): return x + ((0.6666666666666666 - z) * ((y - x) * 6.0))
function code(x, y, z) return Float64(x + Float64(Float64(0.6666666666666666 - z) * Float64(Float64(y - x) * 6.0))) end
function tmp = code(x, y, z) tmp = x + ((0.6666666666666666 - z) * ((y - x) * 6.0)); end
code[x_, y_, z_] := N[(x + N[(N[(0.6666666666666666 - z), $MachinePrecision] * N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(0.6666666666666666 - z\right) \cdot \left(\left(y - x\right) \cdot 6\right)
\end{array}
Initial program 99.5%
metadata-eval99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (* x (+ -3.0 (* z 6.0))))
double code(double x, double y, double z) {
return x * (-3.0 + (z * 6.0));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * ((-3.0d0) + (z * 6.0d0))
end function
public static double code(double x, double y, double z) {
return x * (-3.0 + (z * 6.0));
}
def code(x, y, z): return x * (-3.0 + (z * 6.0))
function code(x, y, z) return Float64(x * Float64(-3.0 + Float64(z * 6.0))) end
function tmp = code(x, y, z) tmp = x * (-3.0 + (z * 6.0)); end
code[x_, y_, z_] := N[(x * N[(-3.0 + N[(z * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(-3 + z \cdot 6\right)
\end{array}
Initial program 99.5%
+-commutative99.5%
associate-*l*99.8%
fma-define99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 56.5%
*-lft-identity56.5%
*-commutative56.5%
associate-*r*56.7%
sub-neg56.7%
distribute-rgt-in56.7%
metadata-eval56.7%
neg-mul-156.7%
associate-*r*56.7%
*-commutative56.7%
metadata-eval56.7%
distribute-lft-in56.7%
distribute-rgt-in56.7%
distribute-lft-in56.7%
metadata-eval56.7%
associate-+r+56.7%
metadata-eval56.7%
associate-*r*56.7%
metadata-eval56.7%
Simplified56.7%
Final simplification56.7%
(FPCore (x y z) :precision binary64 (* x -3.0))
double code(double x, double y, double z) {
return x * -3.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * (-3.0d0)
end function
public static double code(double x, double y, double z) {
return x * -3.0;
}
def code(x, y, z): return x * -3.0
function code(x, y, z) return Float64(x * -3.0) end
function tmp = code(x, y, z) tmp = x * -3.0; end
code[x_, y_, z_] := N[(x * -3.0), $MachinePrecision]
\begin{array}{l}
\\
x \cdot -3
\end{array}
Initial program 99.5%
+-commutative99.5%
associate-*l*99.8%
fma-define99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 56.5%
*-lft-identity56.5%
*-commutative56.5%
associate-*r*56.7%
sub-neg56.7%
distribute-rgt-in56.7%
metadata-eval56.7%
neg-mul-156.7%
associate-*r*56.7%
*-commutative56.7%
metadata-eval56.7%
distribute-lft-in56.7%
distribute-rgt-in56.7%
distribute-lft-in56.7%
metadata-eval56.7%
associate-+r+56.7%
metadata-eval56.7%
associate-*r*56.7%
metadata-eval56.7%
Simplified56.7%
Taylor expanded in z around 0 26.8%
*-commutative26.8%
Simplified26.8%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return 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
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in y around 0 56.6%
Taylor expanded in z around inf 31.1%
neg-mul-131.1%
Simplified31.1%
Taylor expanded in z around 0 2.6%
herbie shell --seed 2024131
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, D"
:precision binary64
(+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))