
(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 10 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 (+ x (* z (* (- y x) 6.0))))
double code(double x, double y, double z) {
return x + (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 + (z * ((y - x) * 6.0d0))
end function
public static double code(double x, double y, double z) {
return x + (z * ((y - x) * 6.0));
}
def code(x, y, z): return x + (z * ((y - x) * 6.0))
function code(x, y, z) return Float64(x + Float64(z * Float64(Float64(y - x) * 6.0))) end
function tmp = code(x, y, z) tmp = x + (z * ((y - x) * 6.0)); end
code[x_, y_, z_] := N[(x + N[(z * N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + z \cdot \left(\left(y - x\right) \cdot 6\right)
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (* y 6.0))) (t_1 (* x (* z -6.0))))
(if (<= z -6.4e+44)
t_0
(if (<= z -7.8e-13)
t_1
(if (<= z 3.9e-17) x (if (<= z 1.8e+65) t_0 t_1))))))
double code(double x, double y, double z) {
double t_0 = z * (y * 6.0);
double t_1 = x * (z * -6.0);
double tmp;
if (z <= -6.4e+44) {
tmp = t_0;
} else if (z <= -7.8e-13) {
tmp = t_1;
} else if (z <= 3.9e-17) {
tmp = x;
} else if (z <= 1.8e+65) {
tmp = t_0;
} 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 = z * (y * 6.0d0)
t_1 = x * (z * (-6.0d0))
if (z <= (-6.4d+44)) then
tmp = t_0
else if (z <= (-7.8d-13)) then
tmp = t_1
else if (z <= 3.9d-17) then
tmp = x
else if (z <= 1.8d+65) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * (y * 6.0);
double t_1 = x * (z * -6.0);
double tmp;
if (z <= -6.4e+44) {
tmp = t_0;
} else if (z <= -7.8e-13) {
tmp = t_1;
} else if (z <= 3.9e-17) {
tmp = x;
} else if (z <= 1.8e+65) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = z * (y * 6.0) t_1 = x * (z * -6.0) tmp = 0 if z <= -6.4e+44: tmp = t_0 elif z <= -7.8e-13: tmp = t_1 elif z <= 3.9e-17: tmp = x elif z <= 1.8e+65: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(y * 6.0)) t_1 = Float64(x * Float64(z * -6.0)) tmp = 0.0 if (z <= -6.4e+44) tmp = t_0; elseif (z <= -7.8e-13) tmp = t_1; elseif (z <= 3.9e-17) tmp = x; elseif (z <= 1.8e+65) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (y * 6.0); t_1 = x * (z * -6.0); tmp = 0.0; if (z <= -6.4e+44) tmp = t_0; elseif (z <= -7.8e-13) tmp = t_1; elseif (z <= 3.9e-17) tmp = x; elseif (z <= 1.8e+65) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(y * 6.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(z * -6.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -6.4e+44], t$95$0, If[LessEqual[z, -7.8e-13], t$95$1, If[LessEqual[z, 3.9e-17], x, If[LessEqual[z, 1.8e+65], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(y \cdot 6\right)\\
t_1 := x \cdot \left(z \cdot -6\right)\\
\mathbf{if}\;z \leq -6.4 \cdot 10^{+44}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -7.8 \cdot 10^{-13}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 3.9 \cdot 10^{-17}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.8 \cdot 10^{+65}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if z < -6.40000000000000009e44 or 3.89999999999999989e-17 < z < 1.79999999999999989e65Initial program 99.8%
associate-*r*99.7%
flip3-+16.2%
clear-num16.2%
*-un-lft-identity16.2%
associate-/l*16.2%
flip3-+99.7%
+-commutative99.7%
fma-def99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 62.4%
*-commutative62.4%
Simplified62.4%
associate-/r/62.5%
*-commutative62.5%
associate-*r*62.7%
metadata-eval62.7%
Applied egg-rr62.7%
if -6.40000000000000009e44 < z < -7.80000000000000009e-13 or 1.79999999999999989e65 < z Initial program 99.7%
Taylor expanded in x around inf 75.6%
Taylor expanded in z around inf 74.7%
*-commutative74.7%
Simplified74.7%
if -7.80000000000000009e-13 < z < 3.89999999999999989e-17Initial program 99.9%
Taylor expanded in z around 0 80.9%
Final simplification74.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.7e-17) (not (<= z 4.5e-17))) (* 6.0 (* (- y x) z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.7e-17) || !(z <= 4.5e-17)) {
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.7d-17)) .or. (.not. (z <= 4.5d-17))) 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.7e-17) || !(z <= 4.5e-17)) {
tmp = 6.0 * ((y - x) * z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.7e-17) or not (z <= 4.5e-17): tmp = 6.0 * ((y - x) * z) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.7e-17) || !(z <= 4.5e-17)) 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.7e-17) || ~((z <= 4.5e-17))) tmp = 6.0 * ((y - x) * z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.7e-17], N[Not[LessEqual[z, 4.5e-17]], $MachinePrecision]], N[(6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.7 \cdot 10^{-17} \lor \neg \left(z \leq 4.5 \cdot 10^{-17}\right):\\
\;\;\;\;6 \cdot \left(\left(y - x\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.6999999999999999e-17 or 4.49999999999999978e-17 < z Initial program 99.8%
associate-*r*99.7%
flip3-+17.6%
clear-num17.6%
*-un-lft-identity17.6%
associate-/l*17.6%
flip3-+99.7%
+-commutative99.7%
fma-def99.7%
Applied egg-rr99.7%
Taylor expanded in z around inf 97.0%
*-commutative97.0%
associate-/r*97.0%
Simplified97.0%
Taylor expanded in z around 0 97.1%
if -1.6999999999999999e-17 < z < 4.49999999999999978e-17Initial program 99.9%
Taylor expanded in z around 0 81.4%
Final simplification89.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.3e-17) (not (<= z 1.4e-9))) (* 6.0 (* (- y x) z)) (* x (+ 1.0 (* z -6.0)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.3e-17) || !(z <= 1.4e-9)) {
tmp = 6.0 * ((y - x) * z);
} else {
tmp = x * (1.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 ((z <= (-2.3d-17)) .or. (.not. (z <= 1.4d-9))) then
tmp = 6.0d0 * ((y - x) * z)
else
tmp = x * (1.0d0 + (z * (-6.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.3e-17) || !(z <= 1.4e-9)) {
tmp = 6.0 * ((y - x) * z);
} else {
tmp = x * (1.0 + (z * -6.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.3e-17) or not (z <= 1.4e-9): tmp = 6.0 * ((y - x) * z) else: tmp = x * (1.0 + (z * -6.0)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.3e-17) || !(z <= 1.4e-9)) tmp = Float64(6.0 * Float64(Float64(y - x) * z)); else tmp = Float64(x * Float64(1.0 + Float64(z * -6.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.3e-17) || ~((z <= 1.4e-9))) tmp = 6.0 * ((y - x) * z); else tmp = x * (1.0 + (z * -6.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.3e-17], N[Not[LessEqual[z, 1.4e-9]], $MachinePrecision]], N[(6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(z * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.3 \cdot 10^{-17} \lor \neg \left(z \leq 1.4 \cdot 10^{-9}\right):\\
\;\;\;\;6 \cdot \left(\left(y - x\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + z \cdot -6\right)\\
\end{array}
\end{array}
if z < -2.30000000000000009e-17 or 1.39999999999999992e-9 < z Initial program 99.8%
associate-*r*99.7%
flip3-+17.9%
clear-num17.9%
*-un-lft-identity17.9%
associate-/l*17.9%
flip3-+99.7%
+-commutative99.7%
fma-def99.7%
Applied egg-rr99.7%
Taylor expanded in z around inf 97.7%
*-commutative97.7%
associate-/r*97.8%
Simplified97.8%
Taylor expanded in z around 0 97.9%
if -2.30000000000000009e-17 < z < 1.39999999999999992e-9Initial program 99.9%
Taylor expanded in x around inf 80.9%
Final simplification89.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.2e-17) (not (<= z 1.2e-9))) (* z (* (- y x) 6.0)) (* x (+ 1.0 (* z -6.0)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.2e-17) || !(z <= 1.2e-9)) {
tmp = z * ((y - x) * 6.0);
} else {
tmp = x * (1.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 ((z <= (-2.2d-17)) .or. (.not. (z <= 1.2d-9))) then
tmp = z * ((y - x) * 6.0d0)
else
tmp = x * (1.0d0 + (z * (-6.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.2e-17) || !(z <= 1.2e-9)) {
tmp = z * ((y - x) * 6.0);
} else {
tmp = x * (1.0 + (z * -6.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.2e-17) or not (z <= 1.2e-9): tmp = z * ((y - x) * 6.0) else: tmp = x * (1.0 + (z * -6.0)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.2e-17) || !(z <= 1.2e-9)) tmp = Float64(z * Float64(Float64(y - x) * 6.0)); else tmp = Float64(x * Float64(1.0 + Float64(z * -6.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.2e-17) || ~((z <= 1.2e-9))) tmp = z * ((y - x) * 6.0); else tmp = x * (1.0 + (z * -6.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.2e-17], N[Not[LessEqual[z, 1.2e-9]], $MachinePrecision]], N[(z * N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(z * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.2 \cdot 10^{-17} \lor \neg \left(z \leq 1.2 \cdot 10^{-9}\right):\\
\;\;\;\;z \cdot \left(\left(y - x\right) \cdot 6\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + z \cdot -6\right)\\
\end{array}
\end{array}
if z < -2.2e-17 or 1.2e-9 < z Initial program 99.8%
associate-*r*99.7%
flip3-+17.9%
clear-num17.9%
*-un-lft-identity17.9%
associate-/l*17.9%
flip3-+99.7%
+-commutative99.7%
fma-def99.7%
Applied egg-rr99.7%
Taylor expanded in z around inf 97.7%
*-commutative97.7%
associate-/r*97.8%
Simplified97.8%
associate-/r/97.8%
associate-/r/97.9%
metadata-eval97.9%
Applied egg-rr97.9%
if -2.2e-17 < z < 1.2e-9Initial program 99.9%
Taylor expanded in x around inf 80.9%
Final simplification89.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.5e-17) (not (<= z 1.45e-10))) (* z (* (- y x) 6.0)) (+ x (* -6.0 (* x z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.5e-17) || !(z <= 1.45e-10)) {
tmp = z * ((y - x) * 6.0);
} 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 <= (-1.5d-17)) .or. (.not. (z <= 1.45d-10))) then
tmp = z * ((y - x) * 6.0d0)
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 <= -1.5e-17) || !(z <= 1.45e-10)) {
tmp = z * ((y - x) * 6.0);
} else {
tmp = x + (-6.0 * (x * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.5e-17) or not (z <= 1.45e-10): tmp = z * ((y - x) * 6.0) else: tmp = x + (-6.0 * (x * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.5e-17) || !(z <= 1.45e-10)) tmp = Float64(z * Float64(Float64(y - x) * 6.0)); 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 <= -1.5e-17) || ~((z <= 1.45e-10))) tmp = z * ((y - x) * 6.0); else tmp = x + (-6.0 * (x * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.5e-17], N[Not[LessEqual[z, 1.45e-10]], $MachinePrecision]], N[(z * N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision], N[(x + N[(-6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.5 \cdot 10^{-17} \lor \neg \left(z \leq 1.45 \cdot 10^{-10}\right):\\
\;\;\;\;z \cdot \left(\left(y - x\right) \cdot 6\right)\\
\mathbf{else}:\\
\;\;\;\;x + -6 \cdot \left(x \cdot z\right)\\
\end{array}
\end{array}
if z < -1.50000000000000003e-17 or 1.4499999999999999e-10 < z Initial program 99.8%
associate-*r*99.7%
flip3-+17.9%
clear-num17.9%
*-un-lft-identity17.9%
associate-/l*17.9%
flip3-+99.7%
+-commutative99.7%
fma-def99.7%
Applied egg-rr99.7%
Taylor expanded in z around inf 97.7%
*-commutative97.7%
associate-/r*97.8%
Simplified97.8%
associate-/r/97.8%
associate-/r/97.9%
metadata-eval97.9%
Applied egg-rr97.9%
if -1.50000000000000003e-17 < z < 1.4499999999999999e-10Initial program 99.9%
Taylor expanded in y around 0 80.9%
Final simplification89.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.155) (not (<= z 0.17))) (* z (* (- y x) 6.0)) (+ x (* 6.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.155) || !(z <= 0.17)) {
tmp = z * ((y - x) * 6.0);
} 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 <= (-0.155d0)) .or. (.not. (z <= 0.17d0))) then
tmp = z * ((y - x) * 6.0d0)
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 <= -0.155) || !(z <= 0.17)) {
tmp = z * ((y - x) * 6.0);
} else {
tmp = x + (6.0 * (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.155) or not (z <= 0.17): tmp = z * ((y - x) * 6.0) else: tmp = x + (6.0 * (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.155) || !(z <= 0.17)) tmp = Float64(z * Float64(Float64(y - x) * 6.0)); 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 <= -0.155) || ~((z <= 0.17))) tmp = z * ((y - x) * 6.0); else tmp = x + (6.0 * (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.155], N[Not[LessEqual[z, 0.17]], $MachinePrecision]], N[(z * N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision], N[(x + N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.155 \lor \neg \left(z \leq 0.17\right):\\
\;\;\;\;z \cdot \left(\left(y - x\right) \cdot 6\right)\\
\mathbf{else}:\\
\;\;\;\;x + 6 \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if z < -0.154999999999999999 or 0.170000000000000012 < z Initial program 99.8%
associate-*r*99.7%
flip3-+17.2%
clear-num17.2%
*-un-lft-identity17.2%
associate-/l*17.2%
flip3-+99.7%
+-commutative99.7%
fma-def99.7%
Applied egg-rr99.7%
Taylor expanded in z around inf 99.1%
*-commutative99.1%
associate-/r*99.2%
Simplified99.2%
associate-/r/99.2%
associate-/r/99.4%
metadata-eval99.4%
Applied egg-rr99.4%
if -0.154999999999999999 < z < 0.170000000000000012Initial program 99.9%
Taylor expanded in y around inf 99.2%
Final simplification99.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -7.8e-13) (not (<= z 0.17))) (* -6.0 (* x z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -7.8e-13) || !(z <= 0.17)) {
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 <= (-7.8d-13)) .or. (.not. (z <= 0.17d0))) 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 <= -7.8e-13) || !(z <= 0.17)) {
tmp = -6.0 * (x * z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -7.8e-13) or not (z <= 0.17): tmp = -6.0 * (x * z) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -7.8e-13) || !(z <= 0.17)) 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 <= -7.8e-13) || ~((z <= 0.17))) tmp = -6.0 * (x * z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -7.8e-13], N[Not[LessEqual[z, 0.17]], $MachinePrecision]], N[(-6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.8 \cdot 10^{-13} \lor \neg \left(z \leq 0.17\right):\\
\;\;\;\;-6 \cdot \left(x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -7.80000000000000009e-13 or 0.170000000000000012 < z Initial program 99.8%
Taylor expanded in y around 0 55.1%
Taylor expanded in z around inf 54.8%
if -7.80000000000000009e-13 < z < 0.170000000000000012Initial program 99.9%
Taylor expanded in z around 0 78.7%
Final simplification67.0%
(FPCore (x y z) :precision binary64 (if (<= z -7.8e-13) (* -6.0 (* x z)) (if (<= z 0.17) x (* x (* z -6.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -7.8e-13) {
tmp = -6.0 * (x * z);
} else if (z <= 0.17) {
tmp = x;
} 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 <= (-7.8d-13)) then
tmp = (-6.0d0) * (x * z)
else if (z <= 0.17d0) then
tmp = x
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 <= -7.8e-13) {
tmp = -6.0 * (x * z);
} else if (z <= 0.17) {
tmp = x;
} else {
tmp = x * (z * -6.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -7.8e-13: tmp = -6.0 * (x * z) elif z <= 0.17: tmp = x else: tmp = x * (z * -6.0) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -7.8e-13) tmp = Float64(-6.0 * Float64(x * z)); elseif (z <= 0.17) tmp = x; else tmp = Float64(x * Float64(z * -6.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -7.8e-13) tmp = -6.0 * (x * z); elseif (z <= 0.17) tmp = x; else tmp = x * (z * -6.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -7.8e-13], N[(-6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 0.17], x, N[(x * N[(z * -6.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.8 \cdot 10^{-13}:\\
\;\;\;\;-6 \cdot \left(x \cdot z\right)\\
\mathbf{elif}\;z \leq 0.17:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(z \cdot -6\right)\\
\end{array}
\end{array}
if z < -7.80000000000000009e-13Initial program 99.8%
Taylor expanded in y around 0 46.2%
Taylor expanded in z around inf 45.4%
if -7.80000000000000009e-13 < z < 0.170000000000000012Initial program 99.9%
Taylor expanded in z around 0 78.7%
if 0.170000000000000012 < z Initial program 99.7%
Taylor expanded in x around inf 64.3%
Taylor expanded in z around inf 64.2%
*-commutative64.2%
Simplified64.2%
Final simplification67.0%
(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.8%
Taylor expanded in z around 0 41.6%
Final simplification41.6%
(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 2023301
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, E"
:precision binary64
:herbie-target
(- x (* (* 6.0 z) (- x y)))
(+ x (* (* (- y x) 6.0) z)))