
(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 14 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) (fma z -6.0 4.0) x))
double code(double x, double y, double z) {
return fma((y - x), fma(z, -6.0, 4.0), x);
}
function code(x, y, z) return fma(Float64(y - x), fma(z, -6.0, 4.0), x) end
code[x_, y_, z_] := N[(N[(y - x), $MachinePrecision] * N[(z * -6.0 + 4.0), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y - x, \mathsf{fma}\left(z, -6, 4\right), x\right)
\end{array}
Initial program 99.5%
+-commutative99.5%
associate-*l*99.7%
fma-def99.7%
sub-neg99.7%
+-commutative99.7%
distribute-lft-in99.7%
distribute-rgt-neg-out99.7%
distribute-lft-neg-in99.7%
*-commutative99.7%
fma-def99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(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.7%
fma-def99.7%
sub-neg99.7%
distribute-rgt-in99.7%
metadata-eval99.7%
metadata-eval99.7%
distribute-lft-neg-out99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 6.0 (* x z))))
(if (<= z -8.4e+166)
t_0
(if (<= z -1.8e-5)
(* -6.0 (* y z))
(if (<= z 2.8e-258)
(* x -3.0)
(if (<= z 3.4e-168) (* y 4.0) (if (<= z 0.00082) (* x -3.0) t_0)))))))
double code(double x, double y, double z) {
double t_0 = 6.0 * (x * z);
double tmp;
if (z <= -8.4e+166) {
tmp = t_0;
} else if (z <= -1.8e-5) {
tmp = -6.0 * (y * z);
} else if (z <= 2.8e-258) {
tmp = x * -3.0;
} else if (z <= 3.4e-168) {
tmp = y * 4.0;
} else if (z <= 0.00082) {
tmp = x * -3.0;
} 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 = 6.0d0 * (x * z)
if (z <= (-8.4d+166)) then
tmp = t_0
else if (z <= (-1.8d-5)) then
tmp = (-6.0d0) * (y * z)
else if (z <= 2.8d-258) then
tmp = x * (-3.0d0)
else if (z <= 3.4d-168) then
tmp = y * 4.0d0
else if (z <= 0.00082d0) then
tmp = x * (-3.0d0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 6.0 * (x * z);
double tmp;
if (z <= -8.4e+166) {
tmp = t_0;
} else if (z <= -1.8e-5) {
tmp = -6.0 * (y * z);
} else if (z <= 2.8e-258) {
tmp = x * -3.0;
} else if (z <= 3.4e-168) {
tmp = y * 4.0;
} else if (z <= 0.00082) {
tmp = x * -3.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 6.0 * (x * z) tmp = 0 if z <= -8.4e+166: tmp = t_0 elif z <= -1.8e-5: tmp = -6.0 * (y * z) elif z <= 2.8e-258: tmp = x * -3.0 elif z <= 3.4e-168: tmp = y * 4.0 elif z <= 0.00082: tmp = x * -3.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(6.0 * Float64(x * z)) tmp = 0.0 if (z <= -8.4e+166) tmp = t_0; elseif (z <= -1.8e-5) tmp = Float64(-6.0 * Float64(y * z)); elseif (z <= 2.8e-258) tmp = Float64(x * -3.0); elseif (z <= 3.4e-168) tmp = Float64(y * 4.0); elseif (z <= 0.00082) tmp = Float64(x * -3.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 6.0 * (x * z); tmp = 0.0; if (z <= -8.4e+166) tmp = t_0; elseif (z <= -1.8e-5) tmp = -6.0 * (y * z); elseif (z <= 2.8e-258) tmp = x * -3.0; elseif (z <= 3.4e-168) tmp = y * 4.0; elseif (z <= 0.00082) tmp = x * -3.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -8.4e+166], t$95$0, If[LessEqual[z, -1.8e-5], N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.8e-258], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 3.4e-168], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 0.00082], N[(x * -3.0), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 6 \cdot \left(x \cdot z\right)\\
\mathbf{if}\;z \leq -8.4 \cdot 10^{+166}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -1.8 \cdot 10^{-5}:\\
\;\;\;\;-6 \cdot \left(y \cdot z\right)\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{-258}:\\
\;\;\;\;x \cdot -3\\
\mathbf{elif}\;z \leq 3.4 \cdot 10^{-168}:\\
\;\;\;\;y \cdot 4\\
\mathbf{elif}\;z \leq 0.00082:\\
\;\;\;\;x \cdot -3\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -8.4000000000000002e166 or 8.1999999999999998e-4 < z Initial program 99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around inf 62.1%
sub-neg62.1%
distribute-rgt-in62.1%
metadata-eval62.1%
metadata-eval62.1%
distribute-lft-neg-in62.1%
associate-+r+62.1%
metadata-eval62.1%
metadata-eval62.1%
distribute-rgt-neg-in62.1%
metadata-eval62.1%
Simplified62.1%
Taylor expanded in z around inf 60.7%
*-commutative60.7%
Simplified60.7%
if -8.4000000000000002e166 < z < -1.80000000000000005e-5Initial program 99.7%
+-commutative99.7%
associate-*l*99.4%
fma-def99.4%
sub-neg99.4%
distribute-rgt-in99.5%
metadata-eval99.5%
metadata-eval99.5%
distribute-lft-neg-out99.5%
distribute-rgt-neg-in99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in y around inf 60.9%
Taylor expanded in z around inf 57.5%
if -1.80000000000000005e-5 < z < 2.8000000000000002e-258 or 3.40000000000000022e-168 < z < 8.1999999999999998e-4Initial program 99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around inf 58.5%
sub-neg58.5%
distribute-rgt-in58.5%
metadata-eval58.5%
metadata-eval58.5%
distribute-lft-neg-in58.5%
associate-+r+58.5%
metadata-eval58.5%
metadata-eval58.5%
distribute-rgt-neg-in58.5%
metadata-eval58.5%
Simplified58.5%
Taylor expanded in z around 0 58.3%
*-commutative58.3%
Simplified58.3%
if 2.8000000000000002e-258 < z < 3.40000000000000022e-168Initial program 99.5%
+-commutative99.5%
associate-*l*100.0%
fma-def100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 82.0%
Taylor expanded in z around 0 82.0%
*-commutative82.0%
Simplified82.0%
Final simplification60.6%
(FPCore (x y z)
:precision binary64
(if (<= y -2.55e+95)
(* y 4.0)
(if (<= y 1.06e+26)
(* x (+ -3.0 (* z 6.0)))
(if (or (<= y 4e+125) (not (<= y 1.05e+231)))
(* y 4.0)
(* -6.0 (* y z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.55e+95) {
tmp = y * 4.0;
} else if (y <= 1.06e+26) {
tmp = x * (-3.0 + (z * 6.0));
} else if ((y <= 4e+125) || !(y <= 1.05e+231)) {
tmp = y * 4.0;
} else {
tmp = -6.0 * (y * 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 <= (-2.55d+95)) then
tmp = y * 4.0d0
else if (y <= 1.06d+26) then
tmp = x * ((-3.0d0) + (z * 6.0d0))
else if ((y <= 4d+125) .or. (.not. (y <= 1.05d+231))) then
tmp = y * 4.0d0
else
tmp = (-6.0d0) * (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.55e+95) {
tmp = y * 4.0;
} else if (y <= 1.06e+26) {
tmp = x * (-3.0 + (z * 6.0));
} else if ((y <= 4e+125) || !(y <= 1.05e+231)) {
tmp = y * 4.0;
} else {
tmp = -6.0 * (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.55e+95: tmp = y * 4.0 elif y <= 1.06e+26: tmp = x * (-3.0 + (z * 6.0)) elif (y <= 4e+125) or not (y <= 1.05e+231): tmp = y * 4.0 else: tmp = -6.0 * (y * z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.55e+95) tmp = Float64(y * 4.0); elseif (y <= 1.06e+26) tmp = Float64(x * Float64(-3.0 + Float64(z * 6.0))); elseif ((y <= 4e+125) || !(y <= 1.05e+231)) tmp = Float64(y * 4.0); else tmp = Float64(-6.0 * Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.55e+95) tmp = y * 4.0; elseif (y <= 1.06e+26) tmp = x * (-3.0 + (z * 6.0)); elseif ((y <= 4e+125) || ~((y <= 1.05e+231))) tmp = y * 4.0; else tmp = -6.0 * (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.55e+95], N[(y * 4.0), $MachinePrecision], If[LessEqual[y, 1.06e+26], N[(x * N[(-3.0 + N[(z * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 4e+125], N[Not[LessEqual[y, 1.05e+231]], $MachinePrecision]], N[(y * 4.0), $MachinePrecision], N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.55 \cdot 10^{+95}:\\
\;\;\;\;y \cdot 4\\
\mathbf{elif}\;y \leq 1.06 \cdot 10^{+26}:\\
\;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+125} \lor \neg \left(y \leq 1.05 \cdot 10^{+231}\right):\\
\;\;\;\;y \cdot 4\\
\mathbf{else}:\\
\;\;\;\;-6 \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if y < -2.55000000000000001e95 or 1.05999999999999997e26 < y < 3.9999999999999997e125 or 1.04999999999999992e231 < y Initial program 99.5%
+-commutative99.5%
associate-*l*99.8%
fma-def99.8%
sub-neg99.8%
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 85.9%
Taylor expanded in z around 0 55.6%
*-commutative55.6%
Simplified55.6%
if -2.55000000000000001e95 < y < 1.05999999999999997e26Initial program 99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in x around inf 74.4%
sub-neg74.4%
distribute-rgt-in74.5%
metadata-eval74.5%
metadata-eval74.5%
distribute-lft-neg-in74.5%
associate-+r+74.5%
metadata-eval74.5%
metadata-eval74.5%
distribute-rgt-neg-in74.5%
metadata-eval74.5%
Simplified74.5%
if 3.9999999999999997e125 < y < 1.04999999999999992e231Initial program 99.5%
+-commutative99.5%
associate-*l*99.8%
fma-def99.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%
Taylor expanded in y around inf 86.2%
Taylor expanded in z around inf 61.2%
Final simplification68.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -6.0 (* y z))))
(if (<= z -1.8e-5)
t_0
(if (<= z 7e-259)
(* x -3.0)
(if (<= z 6.1e-168) (* y 4.0) (if (<= z 0.5) (* x -3.0) t_0))))))
double code(double x, double y, double z) {
double t_0 = -6.0 * (y * z);
double tmp;
if (z <= -1.8e-5) {
tmp = t_0;
} else if (z <= 7e-259) {
tmp = x * -3.0;
} else if (z <= 6.1e-168) {
tmp = y * 4.0;
} else if (z <= 0.5) {
tmp = x * -3.0;
} 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 = (-6.0d0) * (y * z)
if (z <= (-1.8d-5)) then
tmp = t_0
else if (z <= 7d-259) then
tmp = x * (-3.0d0)
else if (z <= 6.1d-168) then
tmp = y * 4.0d0
else if (z <= 0.5d0) then
tmp = x * (-3.0d0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -6.0 * (y * z);
double tmp;
if (z <= -1.8e-5) {
tmp = t_0;
} else if (z <= 7e-259) {
tmp = x * -3.0;
} else if (z <= 6.1e-168) {
tmp = y * 4.0;
} else if (z <= 0.5) {
tmp = x * -3.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -6.0 * (y * z) tmp = 0 if z <= -1.8e-5: tmp = t_0 elif z <= 7e-259: tmp = x * -3.0 elif z <= 6.1e-168: tmp = y * 4.0 elif z <= 0.5: tmp = x * -3.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-6.0 * Float64(y * z)) tmp = 0.0 if (z <= -1.8e-5) tmp = t_0; elseif (z <= 7e-259) tmp = Float64(x * -3.0); elseif (z <= 6.1e-168) tmp = Float64(y * 4.0); elseif (z <= 0.5) tmp = Float64(x * -3.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -6.0 * (y * z); tmp = 0.0; if (z <= -1.8e-5) tmp = t_0; elseif (z <= 7e-259) tmp = x * -3.0; elseif (z <= 6.1e-168) tmp = y * 4.0; elseif (z <= 0.5) tmp = x * -3.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.8e-5], t$95$0, If[LessEqual[z, 7e-259], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 6.1e-168], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 0.5], N[(x * -3.0), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -6 \cdot \left(y \cdot z\right)\\
\mathbf{if}\;z \leq -1.8 \cdot 10^{-5}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 7 \cdot 10^{-259}:\\
\;\;\;\;x \cdot -3\\
\mathbf{elif}\;z \leq 6.1 \cdot 10^{-168}:\\
\;\;\;\;y \cdot 4\\
\mathbf{elif}\;z \leq 0.5:\\
\;\;\;\;x \cdot -3\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -1.80000000000000005e-5 or 0.5 < z Initial program 99.7%
+-commutative99.7%
associate-*l*99.6%
fma-def99.6%
sub-neg99.6%
distribute-rgt-in99.6%
metadata-eval99.6%
metadata-eval99.6%
distribute-lft-neg-out99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in y around inf 46.5%
Taylor expanded in z around inf 44.5%
if -1.80000000000000005e-5 < z < 7.0000000000000005e-259 or 6.10000000000000037e-168 < z < 0.5Initial program 99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around inf 58.1%
sub-neg58.1%
distribute-rgt-in58.1%
metadata-eval58.1%
metadata-eval58.1%
distribute-lft-neg-in58.1%
associate-+r+58.1%
metadata-eval58.1%
metadata-eval58.1%
distribute-rgt-neg-in58.1%
metadata-eval58.1%
Simplified58.1%
Taylor expanded in z around 0 57.9%
*-commutative57.9%
Simplified57.9%
if 7.0000000000000005e-259 < z < 6.10000000000000037e-168Initial program 99.5%
+-commutative99.5%
associate-*l*100.0%
fma-def100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 82.0%
Taylor expanded in z around 0 82.0%
*-commutative82.0%
Simplified82.0%
Final simplification53.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.68) (not (<= z 0.51))) (+ x (* z (* 6.0 (- x y)))) (+ (* y 4.0) (* x -3.0))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.68) || !(z <= 0.51)) {
tmp = x + (z * (6.0 * (x - y)));
} else {
tmp = (y * 4.0) + (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.68d0)) .or. (.not. (z <= 0.51d0))) then
tmp = x + (z * (6.0d0 * (x - y)))
else
tmp = (y * 4.0d0) + (x * (-3.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.68) || !(z <= 0.51)) {
tmp = x + (z * (6.0 * (x - y)));
} else {
tmp = (y * 4.0) + (x * -3.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.68) or not (z <= 0.51): tmp = x + (z * (6.0 * (x - y))) else: tmp = (y * 4.0) + (x * -3.0) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.68) || !(z <= 0.51)) tmp = Float64(x + Float64(z * Float64(6.0 * Float64(x - y)))); else tmp = Float64(Float64(y * 4.0) + Float64(x * -3.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.68) || ~((z <= 0.51))) tmp = x + (z * (6.0 * (x - y))); else tmp = (y * 4.0) + (x * -3.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.68], N[Not[LessEqual[z, 0.51]], $MachinePrecision]], N[(x + N[(z * N[(6.0 * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * 4.0), $MachinePrecision] + N[(x * -3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.68 \lor \neg \left(z \leq 0.51\right):\\
\;\;\;\;x + z \cdot \left(6 \cdot \left(x - y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot 4 + x \cdot -3\\
\end{array}
\end{array}
if z < -0.680000000000000049 or 0.51000000000000001 < z Initial program 99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 97.2%
neg-mul-197.2%
Simplified97.2%
if -0.680000000000000049 < z < 0.51000000000000001Initial program 99.4%
+-commutative99.4%
associate-*l*99.8%
fma-def99.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%
Taylor expanded in x around -inf 99.8%
Taylor expanded in z around 0 98.8%
Final simplification98.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -1350.0) (not (<= y 1.48e+20))) (* y (+ 4.0 (* z -6.0))) (* x (+ -3.0 (* z 6.0)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1350.0) || !(y <= 1.48e+20)) {
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 <= (-1350.0d0)) .or. (.not. (y <= 1.48d+20))) 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 <= -1350.0) || !(y <= 1.48e+20)) {
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 <= -1350.0) or not (y <= 1.48e+20): 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 <= -1350.0) || !(y <= 1.48e+20)) 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 <= -1350.0) || ~((y <= 1.48e+20))) 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, -1350.0], N[Not[LessEqual[y, 1.48e+20]], $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 -1350 \lor \neg \left(y \leq 1.48 \cdot 10^{+20}\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 < -1350 or 1.48e20 < y Initial program 99.5%
+-commutative99.5%
associate-*l*99.8%
fma-def99.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%
Taylor expanded in y around inf 82.0%
if -1350 < y < 1.48e20Initial program 99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in x around inf 78.6%
sub-neg78.6%
distribute-rgt-in78.7%
metadata-eval78.7%
metadata-eval78.7%
distribute-lft-neg-in78.7%
associate-+r+78.7%
metadata-eval78.7%
metadata-eval78.7%
distribute-rgt-neg-in78.7%
metadata-eval78.7%
Simplified78.7%
Final simplification80.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.55) (not (<= z 0.5))) (* (- y x) (* z -6.0)) (- x (* 4.0 (- x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.55) || !(z <= 0.5)) {
tmp = (y - x) * (z * -6.0);
} else {
tmp = x - (4.0 * (x - y));
}
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.55d0)) .or. (.not. (z <= 0.5d0))) then
tmp = (y - x) * (z * (-6.0d0))
else
tmp = x - (4.0d0 * (x - y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.55) || !(z <= 0.5)) {
tmp = (y - x) * (z * -6.0);
} else {
tmp = x - (4.0 * (x - y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.55) or not (z <= 0.5): tmp = (y - x) * (z * -6.0) else: tmp = x - (4.0 * (x - y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.55) || !(z <= 0.5)) tmp = Float64(Float64(y - x) * Float64(z * -6.0)); else tmp = Float64(x - Float64(4.0 * Float64(x - y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.55) || ~((z <= 0.5))) tmp = (y - x) * (z * -6.0); else tmp = x - (4.0 * (x - y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.55], N[Not[LessEqual[z, 0.5]], $MachinePrecision]], N[(N[(y - x), $MachinePrecision] * N[(z * -6.0), $MachinePrecision]), $MachinePrecision], N[(x - N[(4.0 * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.55 \lor \neg \left(z \leq 0.5\right):\\
\;\;\;\;\left(y - x\right) \cdot \left(z \cdot -6\right)\\
\mathbf{else}:\\
\;\;\;\;x - 4 \cdot \left(x - y\right)\\
\end{array}
\end{array}
if z < -0.55000000000000004 or 0.5 < z Initial program 99.7%
+-commutative99.7%
associate-*l*99.6%
fma-def99.6%
sub-neg99.6%
distribute-rgt-in99.6%
metadata-eval99.6%
metadata-eval99.6%
distribute-lft-neg-out99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in x around -inf 97.0%
Taylor expanded in z around inf 97.2%
distribute-rgt-in94.6%
associate-*r*94.5%
*-commutative94.5%
associate-*r*94.4%
metadata-eval94.4%
distribute-lft-neg-in94.4%
associate-*r*94.5%
*-commutative94.5%
associate-*r*94.5%
distribute-lft-neg-in94.5%
distribute-rgt-in97.1%
sub-neg97.1%
Simplified97.1%
if -0.55000000000000004 < z < 0.5Initial program 99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in z around 0 98.8%
Final simplification98.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.6) (not (<= z 0.51))) (* (- y x) (* z -6.0)) (+ (* y 4.0) (* x -3.0))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.6) || !(z <= 0.51)) {
tmp = (y - x) * (z * -6.0);
} else {
tmp = (y * 4.0) + (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.6d0)) .or. (.not. (z <= 0.51d0))) then
tmp = (y - x) * (z * (-6.0d0))
else
tmp = (y * 4.0d0) + (x * (-3.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.6) || !(z <= 0.51)) {
tmp = (y - x) * (z * -6.0);
} else {
tmp = (y * 4.0) + (x * -3.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.6) or not (z <= 0.51): tmp = (y - x) * (z * -6.0) else: tmp = (y * 4.0) + (x * -3.0) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.6) || !(z <= 0.51)) tmp = Float64(Float64(y - x) * Float64(z * -6.0)); else tmp = Float64(Float64(y * 4.0) + Float64(x * -3.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.6) || ~((z <= 0.51))) tmp = (y - x) * (z * -6.0); else tmp = (y * 4.0) + (x * -3.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.6], N[Not[LessEqual[z, 0.51]], $MachinePrecision]], N[(N[(y - x), $MachinePrecision] * N[(z * -6.0), $MachinePrecision]), $MachinePrecision], N[(N[(y * 4.0), $MachinePrecision] + N[(x * -3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.6 \lor \neg \left(z \leq 0.51\right):\\
\;\;\;\;\left(y - x\right) \cdot \left(z \cdot -6\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot 4 + x \cdot -3\\
\end{array}
\end{array}
if z < -0.599999999999999978 or 0.51000000000000001 < z Initial program 99.7%
+-commutative99.7%
associate-*l*99.6%
fma-def99.6%
sub-neg99.6%
distribute-rgt-in99.6%
metadata-eval99.6%
metadata-eval99.6%
distribute-lft-neg-out99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in x around -inf 97.0%
Taylor expanded in z around inf 97.2%
distribute-rgt-in94.6%
associate-*r*94.5%
*-commutative94.5%
associate-*r*94.4%
metadata-eval94.4%
distribute-lft-neg-in94.4%
associate-*r*94.5%
*-commutative94.5%
associate-*r*94.5%
distribute-lft-neg-in94.5%
distribute-rgt-in97.1%
sub-neg97.1%
Simplified97.1%
if -0.599999999999999978 < z < 0.51000000000000001Initial program 99.4%
+-commutative99.4%
associate-*l*99.8%
fma-def99.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%
Taylor expanded in x around -inf 99.8%
Taylor expanded in z around 0 98.8%
Final simplification98.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -140000000.0) (not (<= y 1.52e+22))) (* y 4.0) (* x -3.0)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -140000000.0) || !(y <= 1.52e+22)) {
tmp = y * 4.0;
} 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 ((y <= (-140000000.0d0)) .or. (.not. (y <= 1.52d+22))) then
tmp = y * 4.0d0
else
tmp = x * (-3.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -140000000.0) || !(y <= 1.52e+22)) {
tmp = y * 4.0;
} else {
tmp = x * -3.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -140000000.0) or not (y <= 1.52e+22): tmp = y * 4.0 else: tmp = x * -3.0 return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -140000000.0) || !(y <= 1.52e+22)) tmp = Float64(y * 4.0); else tmp = Float64(x * -3.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -140000000.0) || ~((y <= 1.52e+22))) tmp = y * 4.0; else tmp = x * -3.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -140000000.0], N[Not[LessEqual[y, 1.52e+22]], $MachinePrecision]], N[(y * 4.0), $MachinePrecision], N[(x * -3.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -140000000 \lor \neg \left(y \leq 1.52 \cdot 10^{+22}\right):\\
\;\;\;\;y \cdot 4\\
\mathbf{else}:\\
\;\;\;\;x \cdot -3\\
\end{array}
\end{array}
if y < -1.4e8 or 1.52e22 < y Initial program 99.5%
+-commutative99.5%
associate-*l*99.8%
fma-def99.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%
Taylor expanded in y around inf 82.0%
Taylor expanded in z around 0 46.8%
*-commutative46.8%
Simplified46.8%
if -1.4e8 < y < 1.52e22Initial program 99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in x around inf 78.6%
sub-neg78.6%
distribute-rgt-in78.7%
metadata-eval78.7%
metadata-eval78.7%
distribute-lft-neg-in78.7%
associate-+r+78.7%
metadata-eval78.7%
metadata-eval78.7%
distribute-rgt-neg-in78.7%
metadata-eval78.7%
Simplified78.7%
Taylor expanded in z around 0 40.0%
*-commutative40.0%
Simplified40.0%
Final simplification42.8%
(FPCore (x y z) :precision binary64 (- x (* (+ (* x -6.0) (* y 6.0)) (- z 0.6666666666666666))))
double code(double x, double y, double z) {
return x - (((x * -6.0) + (y * 6.0)) * (z - 0.6666666666666666));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x - (((x * (-6.0d0)) + (y * 6.0d0)) * (z - 0.6666666666666666d0))
end function
public static double code(double x, double y, double z) {
return x - (((x * -6.0) + (y * 6.0)) * (z - 0.6666666666666666));
}
def code(x, y, z): return x - (((x * -6.0) + (y * 6.0)) * (z - 0.6666666666666666))
function code(x, y, z) return Float64(x - Float64(Float64(Float64(x * -6.0) + Float64(y * 6.0)) * Float64(z - 0.6666666666666666))) end
function tmp = code(x, y, z) tmp = x - (((x * -6.0) + (y * 6.0)) * (z - 0.6666666666666666)); end
code[x_, y_, z_] := N[(x - N[(N[(N[(x * -6.0), $MachinePrecision] + N[(y * 6.0), $MachinePrecision]), $MachinePrecision] * N[(z - 0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(x \cdot -6 + y \cdot 6\right) \cdot \left(z - 0.6666666666666666\right)
\end{array}
Initial program 99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in y around 0 99.5%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (- x (* (- 0.6666666666666666 z) (* 6.0 (- x y)))))
double code(double x, double y, double z) {
return x - ((0.6666666666666666 - z) * (6.0 * (x - 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 - ((0.6666666666666666d0 - z) * (6.0d0 * (x - y)))
end function
public static double code(double x, double y, double z) {
return x - ((0.6666666666666666 - z) * (6.0 * (x - y)));
}
def code(x, y, z): return x - ((0.6666666666666666 - z) * (6.0 * (x - y)))
function code(x, y, z) return Float64(x - Float64(Float64(0.6666666666666666 - z) * Float64(6.0 * Float64(x - y)))) end
function tmp = code(x, y, z) tmp = x - ((0.6666666666666666 - z) * (6.0 * (x - y))); end
code[x_, y_, z_] := N[(x - N[(N[(0.6666666666666666 - z), $MachinePrecision] * N[(6.0 * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(0.6666666666666666 - z\right) \cdot \left(6 \cdot \left(x - y\right)\right)
\end{array}
Initial program 99.5%
metadata-eval99.5%
Simplified99.5%
Final simplification99.5%
(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%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in x around inf 55.0%
sub-neg55.0%
distribute-rgt-in55.1%
metadata-eval55.1%
metadata-eval55.1%
distribute-lft-neg-in55.1%
associate-+r+55.1%
metadata-eval55.1%
metadata-eval55.1%
distribute-rgt-neg-in55.1%
metadata-eval55.1%
Simplified55.1%
Taylor expanded in z around 0 30.3%
*-commutative30.3%
Simplified30.3%
Final simplification30.3%
(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 z around inf 45.2%
Taylor expanded in z around 0 2.9%
Final simplification2.9%
herbie shell --seed 2024019
(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))))