
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) z)))
double code(double x, double y, double z) {
return x + (((y - x) * 6.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) * z)
end function
public static double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * z);
}
def code(x, y, z): return x + (((y - x) * 6.0) * z)
function code(x, y, z) return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * z)) end
function tmp = code(x, y, z) tmp = x + (((y - x) * 6.0) * z); end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) z)))
double code(double x, double y, double z) {
return x + (((y - x) * 6.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) * z)
end function
public static double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * z);
}
def code(x, y, z): return x + (((y - x) * 6.0) * z)
function code(x, y, z) return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * z)) end
function tmp = code(x, y, z) tmp = x + (((y - x) * 6.0) * z); end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
\end{array}
(FPCore (x y z) :precision binary64 (fma (- y x) (* 6.0 z) x))
double code(double x, double y, double z) {
return fma((y - x), (6.0 * z), x);
}
function code(x, y, z) return fma(Float64(y - x), Float64(6.0 * z), x) end
code[x_, y_, z_] := N[(N[(y - x), $MachinePrecision] * N[(6.0 * z), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y - x, 6 \cdot z, x\right)
\end{array}
Initial program 99.4%
+-commutative99.4%
associate-*l*99.8%
fma-define99.8%
Simplified99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -6.0 (* x z))))
(if (<= z -1.4e+57)
t_0
(if (<= z -1.16e-12) (* z (* y 6.0)) (if (<= z 9.6e-7) x t_0)))))
double code(double x, double y, double z) {
double t_0 = -6.0 * (x * z);
double tmp;
if (z <= -1.4e+57) {
tmp = t_0;
} else if (z <= -1.16e-12) {
tmp = z * (y * 6.0);
} else if (z <= 9.6e-7) {
tmp = x;
} 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 <= (-1.4d+57)) then
tmp = t_0
else if (z <= (-1.16d-12)) then
tmp = z * (y * 6.0d0)
else if (z <= 9.6d-7) then
tmp = x
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 <= -1.4e+57) {
tmp = t_0;
} else if (z <= -1.16e-12) {
tmp = z * (y * 6.0);
} else if (z <= 9.6e-7) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -6.0 * (x * z) tmp = 0 if z <= -1.4e+57: tmp = t_0 elif z <= -1.16e-12: tmp = z * (y * 6.0) elif z <= 9.6e-7: tmp = x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-6.0 * Float64(x * z)) tmp = 0.0 if (z <= -1.4e+57) tmp = t_0; elseif (z <= -1.16e-12) tmp = Float64(z * Float64(y * 6.0)); elseif (z <= 9.6e-7) tmp = x; 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 <= -1.4e+57) tmp = t_0; elseif (z <= -1.16e-12) tmp = z * (y * 6.0); elseif (z <= 9.6e-7) tmp = x; 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, -1.4e+57], t$95$0, If[LessEqual[z, -1.16e-12], N[(z * N[(y * 6.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 9.6e-7], x, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -6 \cdot \left(x \cdot z\right)\\
\mathbf{if}\;z \leq -1.4 \cdot 10^{+57}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1.16 \cdot 10^{-12}:\\
\;\;\;\;z \cdot \left(y \cdot 6\right)\\
\mathbf{elif}\;z \leq 9.6 \cdot 10^{-7}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.4e57 or 9.59999999999999914e-7 < z Initial program 99.7%
Taylor expanded in z around 0 99.6%
Taylor expanded in z around inf 98.6%
Taylor expanded in y around 0 54.9%
if -1.4e57 < z < -1.1599999999999999e-12Initial program 99.6%
Taylor expanded in z around 0 99.7%
Taylor expanded in z around inf 99.3%
Taylor expanded in y around inf 83.5%
*-commutative83.5%
*-commutative83.5%
associate-*r*83.6%
*-commutative83.6%
Simplified83.6%
if -1.1599999999999999e-12 < z < 9.59999999999999914e-7Initial program 99.1%
Taylor expanded in z around 0 76.5%
Final simplification66.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -6.0 (* x z))))
(if (<= z -1.26e+57)
t_0
(if (<= z -1.7e-9) (* 6.0 (* y z)) (if (<= z 9.6e-7) x t_0)))))
double code(double x, double y, double z) {
double t_0 = -6.0 * (x * z);
double tmp;
if (z <= -1.26e+57) {
tmp = t_0;
} else if (z <= -1.7e-9) {
tmp = 6.0 * (y * z);
} else if (z <= 9.6e-7) {
tmp = x;
} 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 <= (-1.26d+57)) then
tmp = t_0
else if (z <= (-1.7d-9)) then
tmp = 6.0d0 * (y * z)
else if (z <= 9.6d-7) then
tmp = x
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 <= -1.26e+57) {
tmp = t_0;
} else if (z <= -1.7e-9) {
tmp = 6.0 * (y * z);
} else if (z <= 9.6e-7) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -6.0 * (x * z) tmp = 0 if z <= -1.26e+57: tmp = t_0 elif z <= -1.7e-9: tmp = 6.0 * (y * z) elif z <= 9.6e-7: tmp = x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-6.0 * Float64(x * z)) tmp = 0.0 if (z <= -1.26e+57) tmp = t_0; elseif (z <= -1.7e-9) tmp = Float64(6.0 * Float64(y * z)); elseif (z <= 9.6e-7) tmp = x; 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 <= -1.26e+57) tmp = t_0; elseif (z <= -1.7e-9) tmp = 6.0 * (y * z); elseif (z <= 9.6e-7) tmp = x; 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, -1.26e+57], t$95$0, If[LessEqual[z, -1.7e-9], N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 9.6e-7], x, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -6 \cdot \left(x \cdot z\right)\\
\mathbf{if}\;z \leq -1.26 \cdot 10^{+57}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1.7 \cdot 10^{-9}:\\
\;\;\;\;6 \cdot \left(y \cdot z\right)\\
\mathbf{elif}\;z \leq 9.6 \cdot 10^{-7}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.26e57 or 9.59999999999999914e-7 < z Initial program 99.7%
Taylor expanded in z around 0 99.6%
Taylor expanded in z around inf 98.6%
Taylor expanded in y around 0 54.9%
if -1.26e57 < z < -1.6999999999999999e-9Initial program 99.6%
Taylor expanded in z around 0 99.7%
Taylor expanded in z around inf 99.3%
Taylor expanded in y around inf 83.5%
*-commutative83.5%
Simplified83.5%
if -1.6999999999999999e-9 < z < 9.59999999999999914e-7Initial program 99.1%
Taylor expanded in z around 0 76.5%
Final simplification66.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -15600000000.0) (not (<= z 0.17))) (* (- y x) (* 6.0 z)) (+ x (* y (* 6.0 z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -15600000000.0) || !(z <= 0.17)) {
tmp = (y - x) * (6.0 * z);
} else {
tmp = x + (y * (6.0 * 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 ((z <= (-15600000000.0d0)) .or. (.not. (z <= 0.17d0))) then
tmp = (y - x) * (6.0d0 * z)
else
tmp = x + (y * (6.0d0 * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -15600000000.0) || !(z <= 0.17)) {
tmp = (y - x) * (6.0 * z);
} else {
tmp = x + (y * (6.0 * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -15600000000.0) or not (z <= 0.17): tmp = (y - x) * (6.0 * z) else: tmp = x + (y * (6.0 * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -15600000000.0) || !(z <= 0.17)) tmp = Float64(Float64(y - x) * Float64(6.0 * z)); else tmp = Float64(x + Float64(y * Float64(6.0 * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -15600000000.0) || ~((z <= 0.17))) tmp = (y - x) * (6.0 * z); else tmp = x + (y * (6.0 * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -15600000000.0], N[Not[LessEqual[z, 0.17]], $MachinePrecision]], N[(N[(y - x), $MachinePrecision] * N[(6.0 * z), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(6.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -15600000000 \lor \neg \left(z \leq 0.17\right):\\
\;\;\;\;\left(y - x\right) \cdot \left(6 \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(6 \cdot z\right)\\
\end{array}
\end{array}
if z < -1.56e10 or 0.170000000000000012 < z Initial program 99.7%
Taylor expanded in z around 0 99.7%
Taylor expanded in z around inf 98.7%
Taylor expanded in y around 0 91.4%
associate-*r*91.4%
associate-*r*91.4%
distribute-rgt-in98.7%
metadata-eval98.7%
distribute-lft-neg-in98.7%
distribute-rgt-neg-out98.7%
+-commutative98.7%
distribute-lft-out98.7%
sub-neg98.7%
associate-*r*98.8%
Simplified98.8%
if -1.56e10 < z < 0.170000000000000012Initial program 99.1%
Taylor expanded in y around inf 99.1%
*-commutative99.1%
associate-*r*99.1%
Simplified99.1%
Final simplification99.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -5.0) (not (<= z 0.17))) (* (- y x) (* 6.0 z)) (+ x (* 6.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.0) || !(z <= 0.17)) {
tmp = (y - x) * (6.0 * z);
} else {
tmp = x + (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 ((z <= (-5.0d0)) .or. (.not. (z <= 0.17d0))) then
tmp = (y - x) * (6.0d0 * z)
else
tmp = x + (6.0d0 * (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -5.0) || !(z <= 0.17)) {
tmp = (y - x) * (6.0 * z);
} else {
tmp = x + (6.0 * (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5.0) or not (z <= 0.17): tmp = (y - x) * (6.0 * z) else: tmp = x + (6.0 * (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5.0) || !(z <= 0.17)) tmp = Float64(Float64(y - x) * Float64(6.0 * z)); else tmp = Float64(x + Float64(6.0 * Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -5.0) || ~((z <= 0.17))) tmp = (y - x) * (6.0 * z); else tmp = x + (6.0 * (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.0], N[Not[LessEqual[z, 0.17]], $MachinePrecision]], N[(N[(y - x), $MachinePrecision] * N[(6.0 * z), $MachinePrecision]), $MachinePrecision], N[(x + N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5 \lor \neg \left(z \leq 0.17\right):\\
\;\;\;\;\left(y - x\right) \cdot \left(6 \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + 6 \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if z < -5 or 0.170000000000000012 < z Initial program 99.7%
Taylor expanded in z around 0 99.6%
Taylor expanded in z around inf 98.7%
Taylor expanded in y around 0 91.6%
associate-*r*91.6%
associate-*r*91.6%
distribute-rgt-in98.8%
metadata-eval98.8%
distribute-lft-neg-in98.8%
distribute-rgt-neg-out98.8%
+-commutative98.8%
distribute-lft-out98.8%
sub-neg98.8%
associate-*r*98.8%
Simplified98.8%
if -5 < z < 0.170000000000000012Initial program 99.1%
Taylor expanded in y around inf 99.1%
*-commutative99.1%
Simplified99.1%
Final simplification99.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -7e-12) (not (<= z 3.2e-8))) (* (- y x) (* 6.0 z)) (+ x (* -6.0 (* x z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -7e-12) || !(z <= 3.2e-8)) {
tmp = (y - x) * (6.0 * z);
} else {
tmp = x + (-6.0 * (x * 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 ((z <= (-7d-12)) .or. (.not. (z <= 3.2d-8))) then
tmp = (y - x) * (6.0d0 * z)
else
tmp = x + ((-6.0d0) * (x * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -7e-12) || !(z <= 3.2e-8)) {
tmp = (y - x) * (6.0 * z);
} else {
tmp = x + (-6.0 * (x * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -7e-12) or not (z <= 3.2e-8): tmp = (y - x) * (6.0 * z) else: tmp = x + (-6.0 * (x * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -7e-12) || !(z <= 3.2e-8)) tmp = Float64(Float64(y - x) * Float64(6.0 * z)); else tmp = Float64(x + Float64(-6.0 * Float64(x * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -7e-12) || ~((z <= 3.2e-8))) tmp = (y - x) * (6.0 * z); else tmp = x + (-6.0 * (x * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -7e-12], N[Not[LessEqual[z, 3.2e-8]], $MachinePrecision]], N[(N[(y - x), $MachinePrecision] * N[(6.0 * z), $MachinePrecision]), $MachinePrecision], N[(x + N[(-6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7 \cdot 10^{-12} \lor \neg \left(z \leq 3.2 \cdot 10^{-8}\right):\\
\;\;\;\;\left(y - x\right) \cdot \left(6 \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + -6 \cdot \left(x \cdot z\right)\\
\end{array}
\end{array}
if z < -7.0000000000000001e-12 or 3.2000000000000002e-8 < z Initial program 99.7%
Taylor expanded in z around 0 99.6%
Taylor expanded in z around inf 98.6%
Taylor expanded in y around 0 91.7%
associate-*r*91.8%
associate-*r*91.8%
distribute-rgt-in98.7%
metadata-eval98.7%
distribute-lft-neg-in98.7%
distribute-rgt-neg-out98.7%
+-commutative98.7%
distribute-lft-out98.7%
sub-neg98.7%
associate-*r*98.7%
Simplified98.7%
if -7.0000000000000001e-12 < z < 3.2000000000000002e-8Initial program 99.1%
Taylor expanded in y around 0 77.2%
Final simplification88.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -3.7e-12) (not (<= z 1.8e-9))) (* (- y x) (* 6.0 z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3.7e-12) || !(z <= 1.8e-9)) {
tmp = (y - x) * (6.0 * z);
} else {
tmp = x;
}
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 <= (-3.7d-12)) .or. (.not. (z <= 1.8d-9))) then
tmp = (y - x) * (6.0d0 * z)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -3.7e-12) || !(z <= 1.8e-9)) {
tmp = (y - x) * (6.0 * z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3.7e-12) or not (z <= 1.8e-9): tmp = (y - x) * (6.0 * z) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3.7e-12) || !(z <= 1.8e-9)) tmp = Float64(Float64(y - x) * Float64(6.0 * z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -3.7e-12) || ~((z <= 1.8e-9))) tmp = (y - x) * (6.0 * z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.7e-12], N[Not[LessEqual[z, 1.8e-9]], $MachinePrecision]], N[(N[(y - x), $MachinePrecision] * N[(6.0 * z), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.7 \cdot 10^{-12} \lor \neg \left(z \leq 1.8 \cdot 10^{-9}\right):\\
\;\;\;\;\left(y - x\right) \cdot \left(6 \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -3.69999999999999999e-12 or 1.8e-9 < z Initial program 99.7%
Taylor expanded in z around 0 99.6%
Taylor expanded in z around inf 98.6%
Taylor expanded in y around 0 91.7%
associate-*r*91.8%
associate-*r*91.8%
distribute-rgt-in98.7%
metadata-eval98.7%
distribute-lft-neg-in98.7%
distribute-rgt-neg-out98.7%
+-commutative98.7%
distribute-lft-out98.7%
sub-neg98.7%
associate-*r*98.7%
Simplified98.7%
if -3.69999999999999999e-12 < z < 1.8e-9Initial program 99.1%
Taylor expanded in z around 0 76.5%
Final simplification87.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.05e-12) (not (<= z 4e-8))) (* 6.0 (* (- y x) z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.05e-12) || !(z <= 4e-8)) {
tmp = 6.0 * ((y - x) * z);
} else {
tmp = x;
}
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 <= (-1.05d-12)) .or. (.not. (z <= 4d-8))) then
tmp = 6.0d0 * ((y - x) * z)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.05e-12) || !(z <= 4e-8)) {
tmp = 6.0 * ((y - x) * z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.05e-12) or not (z <= 4e-8): tmp = 6.0 * ((y - x) * z) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.05e-12) || !(z <= 4e-8)) tmp = Float64(6.0 * Float64(Float64(y - x) * z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.05e-12) || ~((z <= 4e-8))) tmp = 6.0 * ((y - x) * z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.05e-12], N[Not[LessEqual[z, 4e-8]], $MachinePrecision]], N[(6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05 \cdot 10^{-12} \lor \neg \left(z \leq 4 \cdot 10^{-8}\right):\\
\;\;\;\;6 \cdot \left(\left(y - x\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.04999999999999997e-12 or 4.0000000000000001e-8 < z Initial program 99.7%
Taylor expanded in z around 0 99.6%
Taylor expanded in z around inf 98.6%
if -1.04999999999999997e-12 < z < 4.0000000000000001e-8Initial program 99.1%
Taylor expanded in z around 0 76.5%
Final simplification87.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.165) (not (<= z 9.6e-7))) (* -6.0 (* x z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.165) || !(z <= 9.6e-7)) {
tmp = -6.0 * (x * z);
} else {
tmp = x;
}
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.165d0)) .or. (.not. (z <= 9.6d-7))) then
tmp = (-6.0d0) * (x * z)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.165) || !(z <= 9.6e-7)) {
tmp = -6.0 * (x * z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.165) or not (z <= 9.6e-7): tmp = -6.0 * (x * z) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.165) || !(z <= 9.6e-7)) tmp = Float64(-6.0 * Float64(x * z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.165) || ~((z <= 9.6e-7))) tmp = -6.0 * (x * z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.165], N[Not[LessEqual[z, 9.6e-7]], $MachinePrecision]], N[(-6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.165 \lor \neg \left(z \leq 9.6 \cdot 10^{-7}\right):\\
\;\;\;\;-6 \cdot \left(x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -0.165000000000000008 or 9.59999999999999914e-7 < z Initial program 99.7%
Taylor expanded in z around 0 99.6%
Taylor expanded in z around inf 98.6%
Taylor expanded in y around 0 51.5%
if -0.165000000000000008 < z < 9.59999999999999914e-7Initial program 99.1%
Taylor expanded in z around 0 76.5%
Final simplification63.8%
(FPCore (x y z) :precision binary64 (+ x (* (- y x) (* 6.0 z))))
double code(double x, double y, double z) {
return x + ((y - x) * (6.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 * z))
end function
public static double code(double x, double y, double z) {
return x + ((y - x) * (6.0 * z));
}
def code(x, y, z): return x + ((y - x) * (6.0 * z))
function code(x, y, z) return Float64(x + Float64(Float64(y - x) * Float64(6.0 * z))) end
function tmp = code(x, y, z) tmp = x + ((y - x) * (6.0 * z)); end
code[x_, y_, z_] := N[(x + N[(N[(y - x), $MachinePrecision] * N[(6.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - x\right) \cdot \left(6 \cdot z\right)
\end{array}
Initial program 99.4%
associate-*l*99.8%
Simplified99.8%
(FPCore (x y z) :precision binary64 (+ x (* 6.0 (* (- y x) z))))
double code(double x, double y, double z) {
return x + (6.0 * ((y - x) * 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 + (6.0d0 * ((y - x) * z))
end function
public static double code(double x, double y, double z) {
return x + (6.0 * ((y - x) * z));
}
def code(x, y, z): return x + (6.0 * ((y - x) * z))
function code(x, y, z) return Float64(x + Float64(6.0 * Float64(Float64(y - x) * z))) end
function tmp = code(x, y, z) tmp = x + (6.0 * ((y - x) * z)); end
code[x_, y_, z_] := N[(x + N[(6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + 6 \cdot \left(\left(y - x\right) \cdot z\right)
\end{array}
Initial program 99.4%
Taylor expanded in z around 0 99.8%
Final simplification99.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.4%
Taylor expanded in z around 0 39.2%
(FPCore (x y z) :precision binary64 (- x (* (* 6.0 z) (- x y))))
double code(double x, double y, double z) {
return x - ((6.0 * z) * (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 - ((6.0d0 * z) * (x - y))
end function
public static double code(double x, double y, double z) {
return x - ((6.0 * z) * (x - y));
}
def code(x, y, z): return x - ((6.0 * z) * (x - y))
function code(x, y, z) return Float64(x - Float64(Float64(6.0 * z) * Float64(x - y))) end
function tmp = code(x, y, z) tmp = x - ((6.0 * z) * (x - y)); end
code[x_, y_, z_] := N[(x - N[(N[(6.0 * z), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(6 \cdot z\right) \cdot \left(x - y\right)
\end{array}
herbie shell --seed 2024186
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, E"
:precision binary64
:alt
(! :herbie-platform default (- x (* (* 6 z) (- x y))))
(+ x (* (* (- y x) 6.0) z)))