
(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 13 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) z) 6.0 x))
double code(double x, double y, double z) {
return fma(((y - x) * z), 6.0, x);
}
function code(x, y, z) return fma(Float64(Float64(y - x) * z), 6.0, x) end
code[x_, y_, z_] := N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] * 6.0 + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(y - x\right) \cdot z, 6, x\right)
\end{array}
Initial program 99.8%
associate-*r*99.8%
+-commutative99.8%
*-commutative99.8%
associate-*r*99.8%
fma-define99.8%
Applied egg-rr99.8%
(FPCore (x y z) :precision binary64 (fma z (* (- x y) -6.0) x))
double code(double x, double y, double z) {
return fma(z, ((x - y) * -6.0), x);
}
function code(x, y, z) return fma(z, Float64(Float64(x - y) * -6.0), x) end
code[x_, y_, z_] := N[(z * N[(N[(x - y), $MachinePrecision] * -6.0), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, \left(x - y\right) \cdot -6, x\right)
\end{array}
Initial program 99.8%
+-commutative99.8%
*-commutative99.8%
fma-define99.8%
remove-double-neg99.8%
distribute-lft-neg-in99.8%
distribute-rgt-neg-in99.8%
sub-neg99.8%
distribute-neg-in99.8%
remove-double-neg99.8%
+-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
(FPCore (x y z)
:precision binary64
(if (<= z -0.17)
(* z (* x -6.0))
(if (<= z 3e-126)
x
(if (<= z 1.35e-74)
(* 6.0 (* y z))
(if (<= z 0.17) x (* x (* z -6.0)))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -0.17) {
tmp = z * (x * -6.0);
} else if (z <= 3e-126) {
tmp = x;
} else if (z <= 1.35e-74) {
tmp = 6.0 * (y * 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 <= (-0.17d0)) then
tmp = z * (x * (-6.0d0))
else if (z <= 3d-126) then
tmp = x
else if (z <= 1.35d-74) then
tmp = 6.0d0 * (y * 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 <= -0.17) {
tmp = z * (x * -6.0);
} else if (z <= 3e-126) {
tmp = x;
} else if (z <= 1.35e-74) {
tmp = 6.0 * (y * 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 <= -0.17: tmp = z * (x * -6.0) elif z <= 3e-126: tmp = x elif z <= 1.35e-74: tmp = 6.0 * (y * 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 <= -0.17) tmp = Float64(z * Float64(x * -6.0)); elseif (z <= 3e-126) tmp = x; elseif (z <= 1.35e-74) tmp = Float64(6.0 * Float64(y * 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 <= -0.17) tmp = z * (x * -6.0); elseif (z <= 3e-126) tmp = x; elseif (z <= 1.35e-74) tmp = 6.0 * (y * 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, -0.17], N[(z * N[(x * -6.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3e-126], x, If[LessEqual[z, 1.35e-74], N[(6.0 * N[(y * 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 -0.17:\\
\;\;\;\;z \cdot \left(x \cdot -6\right)\\
\mathbf{elif}\;z \leq 3 \cdot 10^{-126}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.35 \cdot 10^{-74}:\\
\;\;\;\;6 \cdot \left(y \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 < -0.170000000000000012Initial program 99.9%
Taylor expanded in x around inf 63.2%
+-commutative63.2%
Simplified63.2%
Taylor expanded in z around inf 61.9%
*-commutative61.9%
*-commutative61.9%
associate-*r*62.0%
Simplified62.0%
if -0.170000000000000012 < z < 3.0000000000000002e-126 or 1.35000000000000009e-74 < z < 0.170000000000000012Initial program 99.9%
Taylor expanded in z around 0 70.9%
if 3.0000000000000002e-126 < z < 1.35000000000000009e-74Initial program 99.8%
associate-*r*99.7%
+-commutative99.7%
*-commutative99.7%
associate-*r*99.8%
fma-define99.5%
Applied egg-rr99.5%
Taylor expanded in y around inf 65.9%
if 0.170000000000000012 < z Initial program 99.6%
Taylor expanded in x around inf 65.4%
+-commutative65.4%
Simplified65.4%
Taylor expanded in z around inf 60.5%
*-commutative60.5%
associate-*r*62.0%
*-commutative62.0%
Simplified62.0%
Final simplification66.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (* z -6.0))))
(if (<= z -0.17)
t_0
(if (<= z 3e-126)
x
(if (<= z 4.8e-74) (* 6.0 (* y z)) (if (<= z 0.17) x t_0))))))
double code(double x, double y, double z) {
double t_0 = x * (z * -6.0);
double tmp;
if (z <= -0.17) {
tmp = t_0;
} else if (z <= 3e-126) {
tmp = x;
} else if (z <= 4.8e-74) {
tmp = 6.0 * (y * z);
} else if (z <= 0.17) {
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 = x * (z * (-6.0d0))
if (z <= (-0.17d0)) then
tmp = t_0
else if (z <= 3d-126) then
tmp = x
else if (z <= 4.8d-74) then
tmp = 6.0d0 * (y * z)
else if (z <= 0.17d0) 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 = x * (z * -6.0);
double tmp;
if (z <= -0.17) {
tmp = t_0;
} else if (z <= 3e-126) {
tmp = x;
} else if (z <= 4.8e-74) {
tmp = 6.0 * (y * z);
} else if (z <= 0.17) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (z * -6.0) tmp = 0 if z <= -0.17: tmp = t_0 elif z <= 3e-126: tmp = x elif z <= 4.8e-74: tmp = 6.0 * (y * z) elif z <= 0.17: tmp = x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(z * -6.0)) tmp = 0.0 if (z <= -0.17) tmp = t_0; elseif (z <= 3e-126) tmp = x; elseif (z <= 4.8e-74) tmp = Float64(6.0 * Float64(y * z)); elseif (z <= 0.17) tmp = x; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (z * -6.0); tmp = 0.0; if (z <= -0.17) tmp = t_0; elseif (z <= 3e-126) tmp = x; elseif (z <= 4.8e-74) tmp = 6.0 * (y * z); elseif (z <= 0.17) tmp = x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(z * -6.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -0.17], t$95$0, If[LessEqual[z, 3e-126], x, If[LessEqual[z, 4.8e-74], N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 0.17], x, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(z \cdot -6\right)\\
\mathbf{if}\;z \leq -0.17:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 3 \cdot 10^{-126}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 4.8 \cdot 10^{-74}:\\
\;\;\;\;6 \cdot \left(y \cdot z\right)\\
\mathbf{elif}\;z \leq 0.17:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -0.170000000000000012 or 0.170000000000000012 < z Initial program 99.7%
Taylor expanded in x around inf 64.3%
+-commutative64.3%
Simplified64.3%
Taylor expanded in z around inf 61.2%
*-commutative61.2%
associate-*r*62.0%
*-commutative62.0%
Simplified62.0%
if -0.170000000000000012 < z < 3.0000000000000002e-126 or 4.7999999999999998e-74 < z < 0.170000000000000012Initial program 99.9%
Taylor expanded in z around 0 70.9%
if 3.0000000000000002e-126 < z < 4.7999999999999998e-74Initial program 99.8%
associate-*r*99.7%
+-commutative99.7%
*-commutative99.7%
associate-*r*99.8%
fma-define99.5%
Applied egg-rr99.5%
Taylor expanded in y around inf 65.9%
Final simplification66.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -6.0 (* x z))))
(if (<= z -0.17)
t_0
(if (<= z 3e-126)
x
(if (<= z 1.35e-74) (* 6.0 (* y z)) (if (<= z 0.17) x t_0))))))
double code(double x, double y, double z) {
double t_0 = -6.0 * (x * z);
double tmp;
if (z <= -0.17) {
tmp = t_0;
} else if (z <= 3e-126) {
tmp = x;
} else if (z <= 1.35e-74) {
tmp = 6.0 * (y * z);
} else if (z <= 0.17) {
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 <= (-0.17d0)) then
tmp = t_0
else if (z <= 3d-126) then
tmp = x
else if (z <= 1.35d-74) then
tmp = 6.0d0 * (y * z)
else if (z <= 0.17d0) 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 <= -0.17) {
tmp = t_0;
} else if (z <= 3e-126) {
tmp = x;
} else if (z <= 1.35e-74) {
tmp = 6.0 * (y * z);
} else if (z <= 0.17) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -6.0 * (x * z) tmp = 0 if z <= -0.17: tmp = t_0 elif z <= 3e-126: tmp = x elif z <= 1.35e-74: tmp = 6.0 * (y * z) elif z <= 0.17: 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 <= -0.17) tmp = t_0; elseif (z <= 3e-126) tmp = x; elseif (z <= 1.35e-74) tmp = Float64(6.0 * Float64(y * z)); elseif (z <= 0.17) 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 <= -0.17) tmp = t_0; elseif (z <= 3e-126) tmp = x; elseif (z <= 1.35e-74) tmp = 6.0 * (y * z); elseif (z <= 0.17) 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, -0.17], t$95$0, If[LessEqual[z, 3e-126], x, If[LessEqual[z, 1.35e-74], N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 0.17], x, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -6 \cdot \left(x \cdot z\right)\\
\mathbf{if}\;z \leq -0.17:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 3 \cdot 10^{-126}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.35 \cdot 10^{-74}:\\
\;\;\;\;6 \cdot \left(y \cdot z\right)\\
\mathbf{elif}\;z \leq 0.17:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -0.170000000000000012 or 0.170000000000000012 < z Initial program 99.7%
Taylor expanded in x around inf 64.3%
+-commutative64.3%
Simplified64.3%
Taylor expanded in z around inf 61.2%
if -0.170000000000000012 < z < 3.0000000000000002e-126 or 1.35000000000000009e-74 < z < 0.170000000000000012Initial program 99.9%
Taylor expanded in z around 0 70.9%
if 3.0000000000000002e-126 < z < 1.35000000000000009e-74Initial program 99.8%
associate-*r*99.7%
+-commutative99.7%
*-commutative99.7%
associate-*r*99.8%
fma-define99.5%
Applied egg-rr99.5%
Taylor expanded in y around inf 65.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -1880000.0) (not (<= z 0.17))) (* -6.0 (* z (- x y))) (+ x (* y (* z 6.0)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1880000.0) || !(z <= 0.17)) {
tmp = -6.0 * (z * (x - y));
} else {
tmp = x + (y * (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 <= (-1880000.0d0)) .or. (.not. (z <= 0.17d0))) then
tmp = (-6.0d0) * (z * (x - y))
else
tmp = x + (y * (z * 6.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1880000.0) || !(z <= 0.17)) {
tmp = -6.0 * (z * (x - y));
} else {
tmp = x + (y * (z * 6.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1880000.0) or not (z <= 0.17): tmp = -6.0 * (z * (x - y)) else: tmp = x + (y * (z * 6.0)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1880000.0) || !(z <= 0.17)) tmp = Float64(-6.0 * Float64(z * Float64(x - y))); else tmp = Float64(x + Float64(y * Float64(z * 6.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1880000.0) || ~((z <= 0.17))) tmp = -6.0 * (z * (x - y)); else tmp = x + (y * (z * 6.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1880000.0], N[Not[LessEqual[z, 0.17]], $MachinePrecision]], N[(-6.0 * N[(z * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(z * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1880000 \lor \neg \left(z \leq 0.17\right):\\
\;\;\;\;-6 \cdot \left(z \cdot \left(x - y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(z \cdot 6\right)\\
\end{array}
\end{array}
if z < -1.88e6 or 0.170000000000000012 < z Initial program 99.7%
+-commutative99.7%
*-commutative99.7%
fma-define99.7%
remove-double-neg99.7%
distribute-lft-neg-in99.7%
distribute-rgt-neg-in99.7%
sub-neg99.7%
distribute-neg-in99.7%
remove-double-neg99.7%
+-commutative99.7%
sub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 97.4%
if -1.88e6 < z < 0.170000000000000012Initial program 99.8%
Taylor expanded in y around inf 98.8%
*-commutative98.8%
associate-*r*98.8%
Simplified98.8%
Final simplification98.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.7e+69) (not (<= y 5e+47))) (* (- y x) (* z 6.0)) (* x (+ (* z -6.0) 1.0))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.7e+69) || !(y <= 5e+47)) {
tmp = (y - x) * (z * 6.0);
} else {
tmp = x * ((z * -6.0) + 1.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 <= (-6.7d+69)) .or. (.not. (y <= 5d+47))) then
tmp = (y - x) * (z * 6.0d0)
else
tmp = x * ((z * (-6.0d0)) + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -6.7e+69) || !(y <= 5e+47)) {
tmp = (y - x) * (z * 6.0);
} else {
tmp = x * ((z * -6.0) + 1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.7e+69) or not (y <= 5e+47): tmp = (y - x) * (z * 6.0) else: tmp = x * ((z * -6.0) + 1.0) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.7e+69) || !(y <= 5e+47)) tmp = Float64(Float64(y - x) * Float64(z * 6.0)); else tmp = Float64(x * Float64(Float64(z * -6.0) + 1.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -6.7e+69) || ~((y <= 5e+47))) tmp = (y - x) * (z * 6.0); else tmp = x * ((z * -6.0) + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.7e+69], N[Not[LessEqual[y, 5e+47]], $MachinePrecision]], N[(N[(y - x), $MachinePrecision] * N[(z * 6.0), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(z * -6.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.7 \cdot 10^{+69} \lor \neg \left(y \leq 5 \cdot 10^{+47}\right):\\
\;\;\;\;\left(y - x\right) \cdot \left(z \cdot 6\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(z \cdot -6 + 1\right)\\
\end{array}
\end{array}
if y < -6.7000000000000001e69 or 5.00000000000000022e47 < y Initial program 99.7%
associate-*r*99.8%
+-commutative99.8%
*-commutative99.8%
associate-*r*99.7%
fma-define99.8%
Applied egg-rr99.8%
Taylor expanded in z around inf 85.3%
associate-*r*85.4%
*-commutative85.4%
Simplified85.4%
if -6.7000000000000001e69 < y < 5.00000000000000022e47Initial program 99.8%
Taylor expanded in x around inf 88.5%
+-commutative88.5%
Simplified88.5%
Final simplification87.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.9e+71) (not (<= y 5.6e+52))) (* -6.0 (* z (- x y))) (* x (+ (* z -6.0) 1.0))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.9e+71) || !(y <= 5.6e+52)) {
tmp = -6.0 * (z * (x - y));
} else {
tmp = x * ((z * -6.0) + 1.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 <= (-1.9d+71)) .or. (.not. (y <= 5.6d+52))) then
tmp = (-6.0d0) * (z * (x - y))
else
tmp = x * ((z * (-6.0d0)) + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.9e+71) || !(y <= 5.6e+52)) {
tmp = -6.0 * (z * (x - y));
} else {
tmp = x * ((z * -6.0) + 1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.9e+71) or not (y <= 5.6e+52): tmp = -6.0 * (z * (x - y)) else: tmp = x * ((z * -6.0) + 1.0) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.9e+71) || !(y <= 5.6e+52)) tmp = Float64(-6.0 * Float64(z * Float64(x - y))); else tmp = Float64(x * Float64(Float64(z * -6.0) + 1.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.9e+71) || ~((y <= 5.6e+52))) tmp = -6.0 * (z * (x - y)); else tmp = x * ((z * -6.0) + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.9e+71], N[Not[LessEqual[y, 5.6e+52]], $MachinePrecision]], N[(-6.0 * N[(z * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(z * -6.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.9 \cdot 10^{+71} \lor \neg \left(y \leq 5.6 \cdot 10^{+52}\right):\\
\;\;\;\;-6 \cdot \left(z \cdot \left(x - y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(z \cdot -6 + 1\right)\\
\end{array}
\end{array}
if y < -1.9e71 or 5.6e52 < y Initial program 99.7%
+-commutative99.7%
*-commutative99.7%
fma-define99.8%
remove-double-neg99.8%
distribute-lft-neg-in99.8%
distribute-rgt-neg-in99.8%
sub-neg99.8%
distribute-neg-in99.8%
remove-double-neg99.8%
+-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around inf 85.2%
if -1.9e71 < y < 5.6e52Initial program 99.8%
Taylor expanded in x around inf 88.6%
+-commutative88.6%
Simplified88.6%
Final simplification87.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -9e-28) (not (<= z 3e-126))) (* -6.0 (* z (- x y))) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -9e-28) || !(z <= 3e-126)) {
tmp = -6.0 * (z * (x - y));
} 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 <= (-9d-28)) .or. (.not. (z <= 3d-126))) then
tmp = (-6.0d0) * (z * (x - y))
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -9e-28) || !(z <= 3e-126)) {
tmp = -6.0 * (z * (x - y));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -9e-28) or not (z <= 3e-126): tmp = -6.0 * (z * (x - y)) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -9e-28) || !(z <= 3e-126)) tmp = Float64(-6.0 * Float64(z * Float64(x - y))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -9e-28) || ~((z <= 3e-126))) tmp = -6.0 * (z * (x - y)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -9e-28], N[Not[LessEqual[z, 3e-126]], $MachinePrecision]], N[(-6.0 * N[(z * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9 \cdot 10^{-28} \lor \neg \left(z \leq 3 \cdot 10^{-126}\right):\\
\;\;\;\;-6 \cdot \left(z \cdot \left(x - y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -8.9999999999999996e-28 or 3.0000000000000002e-126 < z Initial program 99.7%
+-commutative99.7%
*-commutative99.7%
fma-define99.7%
remove-double-neg99.7%
distribute-lft-neg-in99.7%
distribute-rgt-neg-in99.7%
sub-neg99.7%
distribute-neg-in99.7%
remove-double-neg99.7%
+-commutative99.7%
sub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 88.0%
if -8.9999999999999996e-28 < z < 3.0000000000000002e-126Initial program 99.9%
Taylor expanded in z around 0 74.7%
Final simplification83.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.17) (not (<= z 0.17))) (* -6.0 (* x z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.17) || !(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 <= (-0.17d0)) .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 <= -0.17) || !(z <= 0.17)) {
tmp = -6.0 * (x * z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.17) 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 <= -0.17) || !(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 <= -0.17) || ~((z <= 0.17))) tmp = -6.0 * (x * z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.17], 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 -0.17 \lor \neg \left(z \leq 0.17\right):\\
\;\;\;\;-6 \cdot \left(x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -0.170000000000000012 or 0.170000000000000012 < z Initial program 99.7%
Taylor expanded in x around inf 64.3%
+-commutative64.3%
Simplified64.3%
Taylor expanded in z around inf 61.2%
if -0.170000000000000012 < z < 0.170000000000000012Initial program 99.8%
Taylor expanded in z around 0 65.9%
Final simplification63.6%
(FPCore (x y z) :precision binary64 (+ x (* (- y x) (* z 6.0))))
double code(double x, double y, double z) {
return x + ((y - x) * (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 + ((y - x) * (z * 6.0d0))
end function
public static double code(double x, double y, double z) {
return x + ((y - x) * (z * 6.0));
}
def code(x, y, z): return x + ((y - x) * (z * 6.0))
function code(x, y, z) return Float64(x + Float64(Float64(y - x) * Float64(z * 6.0))) end
function tmp = code(x, y, z) tmp = x + ((y - x) * (z * 6.0)); end
code[x_, y_, z_] := N[(x + N[(N[(y - x), $MachinePrecision] * N[(z * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - x\right) \cdot \left(z \cdot 6\right)
\end{array}
Initial program 99.8%
associate-*l*99.8%
Simplified99.8%
Final simplification99.8%
(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 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 35.3%
(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 2024100
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, E"
:precision binary64
:alt
(- x (* (* 6.0 z) (- x y)))
(+ x (* (* (- y x) 6.0) z)))