
(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 12 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 (+ (* 4.0 (- y x)) (+ x (* -6.0 (* (- y x) z)))))
double code(double x, double y, double z) {
return (4.0 * (y - x)) + (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 = (4.0d0 * (y - x)) + (x + ((-6.0d0) * ((y - x) * z)))
end function
public static double code(double x, double y, double z) {
return (4.0 * (y - x)) + (x + (-6.0 * ((y - x) * z)));
}
def code(x, y, z): return (4.0 * (y - x)) + (x + (-6.0 * ((y - x) * z)))
function code(x, y, z) return Float64(Float64(4.0 * Float64(y - x)) + Float64(x + Float64(-6.0 * Float64(Float64(y - x) * z)))) end
function tmp = code(x, y, z) tmp = (4.0 * (y - x)) + (x + (-6.0 * ((y - x) * z))); end
code[x_, y_, z_] := N[(N[(4.0 * N[(y - x), $MachinePrecision]), $MachinePrecision] + N[(x + N[(-6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
4 \cdot \left(y - x\right) + \left(x + -6 \cdot \left(\left(y - x\right) \cdot z\right)\right)
\end{array}
Initial program 99.5%
Taylor expanded in z around 0 99.8%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 6.0 (* x z))))
(if (<= z -2650.0)
t_0
(if (<= z -6.5e-237)
(* 4.0 y)
(if (<= z 0.5) (* x -3.0) (if (<= z 7.5e+147) (* -6.0 (* y z)) t_0))))))
double code(double x, double y, double z) {
double t_0 = 6.0 * (x * z);
double tmp;
if (z <= -2650.0) {
tmp = t_0;
} else if (z <= -6.5e-237) {
tmp = 4.0 * y;
} else if (z <= 0.5) {
tmp = x * -3.0;
} else if (z <= 7.5e+147) {
tmp = -6.0 * (y * z);
} 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 <= (-2650.0d0)) then
tmp = t_0
else if (z <= (-6.5d-237)) then
tmp = 4.0d0 * y
else if (z <= 0.5d0) then
tmp = x * (-3.0d0)
else if (z <= 7.5d+147) then
tmp = (-6.0d0) * (y * z)
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 <= -2650.0) {
tmp = t_0;
} else if (z <= -6.5e-237) {
tmp = 4.0 * y;
} else if (z <= 0.5) {
tmp = x * -3.0;
} else if (z <= 7.5e+147) {
tmp = -6.0 * (y * z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 6.0 * (x * z) tmp = 0 if z <= -2650.0: tmp = t_0 elif z <= -6.5e-237: tmp = 4.0 * y elif z <= 0.5: tmp = x * -3.0 elif z <= 7.5e+147: tmp = -6.0 * (y * z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(6.0 * Float64(x * z)) tmp = 0.0 if (z <= -2650.0) tmp = t_0; elseif (z <= -6.5e-237) tmp = Float64(4.0 * y); elseif (z <= 0.5) tmp = Float64(x * -3.0); elseif (z <= 7.5e+147) tmp = Float64(-6.0 * Float64(y * z)); 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 <= -2650.0) tmp = t_0; elseif (z <= -6.5e-237) tmp = 4.0 * y; elseif (z <= 0.5) tmp = x * -3.0; elseif (z <= 7.5e+147) tmp = -6.0 * (y * z); 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, -2650.0], t$95$0, If[LessEqual[z, -6.5e-237], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, 0.5], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 7.5e+147], N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 6 \cdot \left(x \cdot z\right)\\
\mathbf{if}\;z \leq -2650:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -6.5 \cdot 10^{-237}:\\
\;\;\;\;4 \cdot y\\
\mathbf{elif}\;z \leq 0.5:\\
\;\;\;\;x \cdot -3\\
\mathbf{elif}\;z \leq 7.5 \cdot 10^{+147}:\\
\;\;\;\;-6 \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -2650 or 7.50000000000000037e147 < z Initial program 99.8%
Taylor expanded in z around 0 99.8%
Taylor expanded in x around inf 61.8%
Taylor expanded in z around inf 61.7%
if -2650 < z < -6.5000000000000001e-237Initial program 99.3%
Taylor expanded in z around 0 96.4%
Taylor expanded in y around inf 57.4%
*-commutative57.4%
Simplified57.4%
if -6.5000000000000001e-237 < z < 0.5Initial program 99.3%
Taylor expanded in z around 0 98.4%
Taylor expanded in y around 0 63.8%
distribute-lft1-in63.8%
metadata-eval63.8%
*-commutative63.8%
Simplified63.8%
if 0.5 < z < 7.50000000000000037e147Initial program 99.8%
Taylor expanded in z around 0 99.8%
Taylor expanded in y around inf 72.2%
Taylor expanded in z around inf 70.3%
*-commutative70.3%
Simplified70.3%
Final simplification62.4%
(FPCore (x y z)
:precision binary64
(if (<= z -2800.0)
(* x (* z 6.0))
(if (<= z -7.4e-234)
(* 4.0 y)
(if (<= z 0.65)
(* x -3.0)
(if (<= z 2.2e+150) (* -6.0 (* y z)) (* 6.0 (* x z)))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2800.0) {
tmp = x * (z * 6.0);
} else if (z <= -7.4e-234) {
tmp = 4.0 * y;
} else if (z <= 0.65) {
tmp = x * -3.0;
} else if (z <= 2.2e+150) {
tmp = -6.0 * (y * z);
} else {
tmp = 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 <= (-2800.0d0)) then
tmp = x * (z * 6.0d0)
else if (z <= (-7.4d-234)) then
tmp = 4.0d0 * y
else if (z <= 0.65d0) then
tmp = x * (-3.0d0)
else if (z <= 2.2d+150) then
tmp = (-6.0d0) * (y * z)
else
tmp = 6.0d0 * (x * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -2800.0) {
tmp = x * (z * 6.0);
} else if (z <= -7.4e-234) {
tmp = 4.0 * y;
} else if (z <= 0.65) {
tmp = x * -3.0;
} else if (z <= 2.2e+150) {
tmp = -6.0 * (y * z);
} else {
tmp = 6.0 * (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2800.0: tmp = x * (z * 6.0) elif z <= -7.4e-234: tmp = 4.0 * y elif z <= 0.65: tmp = x * -3.0 elif z <= 2.2e+150: tmp = -6.0 * (y * z) else: tmp = 6.0 * (x * z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2800.0) tmp = Float64(x * Float64(z * 6.0)); elseif (z <= -7.4e-234) tmp = Float64(4.0 * y); elseif (z <= 0.65) tmp = Float64(x * -3.0); elseif (z <= 2.2e+150) tmp = Float64(-6.0 * Float64(y * z)); else tmp = Float64(6.0 * Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2800.0) tmp = x * (z * 6.0); elseif (z <= -7.4e-234) tmp = 4.0 * y; elseif (z <= 0.65) tmp = x * -3.0; elseif (z <= 2.2e+150) tmp = -6.0 * (y * z); else tmp = 6.0 * (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2800.0], N[(x * N[(z * 6.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -7.4e-234], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, 0.65], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 2.2e+150], N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision], N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2800:\\
\;\;\;\;x \cdot \left(z \cdot 6\right)\\
\mathbf{elif}\;z \leq -7.4 \cdot 10^{-234}:\\
\;\;\;\;4 \cdot y\\
\mathbf{elif}\;z \leq 0.65:\\
\;\;\;\;x \cdot -3\\
\mathbf{elif}\;z \leq 2.2 \cdot 10^{+150}:\\
\;\;\;\;-6 \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;6 \cdot \left(x \cdot z\right)\\
\end{array}
\end{array}
if z < -2800Initial program 99.8%
Taylor expanded in z around 0 99.8%
Taylor expanded in x around inf 57.7%
Taylor expanded in z around inf 57.7%
*-commutative57.7%
Simplified57.7%
if -2800 < z < -7.40000000000000025e-234Initial program 99.3%
Taylor expanded in z around 0 96.4%
Taylor expanded in y around inf 57.4%
*-commutative57.4%
Simplified57.4%
if -7.40000000000000025e-234 < z < 0.650000000000000022Initial program 99.3%
Taylor expanded in z around 0 98.4%
Taylor expanded in y around 0 63.8%
distribute-lft1-in63.8%
metadata-eval63.8%
*-commutative63.8%
Simplified63.8%
if 0.650000000000000022 < z < 2.19999999999999999e150Initial program 99.8%
Taylor expanded in z around 0 99.8%
Taylor expanded in y around inf 72.2%
Taylor expanded in z around inf 70.3%
*-commutative70.3%
Simplified70.3%
if 2.19999999999999999e150 < z Initial program 99.9%
Taylor expanded in z around 0 99.9%
Taylor expanded in x around inf 70.9%
Taylor expanded in z around inf 70.9%
Final simplification62.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -6.0 (* (- y x) z))))
(if (<= z -0.00038)
t_0
(if (<= z -1e-237) (* 4.0 y) (if (<= z 0.5) (* x -3.0) t_0)))))
double code(double x, double y, double z) {
double t_0 = -6.0 * ((y - x) * z);
double tmp;
if (z <= -0.00038) {
tmp = t_0;
} else if (z <= -1e-237) {
tmp = 4.0 * y;
} 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 - x) * z)
if (z <= (-0.00038d0)) then
tmp = t_0
else if (z <= (-1d-237)) then
tmp = 4.0d0 * y
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 - x) * z);
double tmp;
if (z <= -0.00038) {
tmp = t_0;
} else if (z <= -1e-237) {
tmp = 4.0 * y;
} 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 - x) * z) tmp = 0 if z <= -0.00038: tmp = t_0 elif z <= -1e-237: tmp = 4.0 * y 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(Float64(y - x) * z)) tmp = 0.0 if (z <= -0.00038) tmp = t_0; elseif (z <= -1e-237) tmp = Float64(4.0 * y); 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 - x) * z); tmp = 0.0; if (z <= -0.00038) tmp = t_0; elseif (z <= -1e-237) tmp = 4.0 * y; 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[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -0.00038], t$95$0, If[LessEqual[z, -1e-237], N[(4.0 * y), $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(\left(y - x\right) \cdot z\right)\\
\mathbf{if}\;z \leq -0.00038:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -1 \cdot 10^{-237}:\\
\;\;\;\;4 \cdot y\\
\mathbf{elif}\;z \leq 0.5:\\
\;\;\;\;x \cdot -3\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -3.8000000000000002e-4 or 0.5 < z Initial program 99.8%
Taylor expanded in z around 0 99.8%
Taylor expanded in z around inf 97.6%
if -3.8000000000000002e-4 < z < -9.9999999999999999e-238Initial program 99.3%
Taylor expanded in z around 0 97.8%
Taylor expanded in y around inf 58.1%
*-commutative58.1%
Simplified58.1%
if -9.9999999999999999e-238 < z < 0.5Initial program 99.3%
Taylor expanded in z around 0 98.4%
Taylor expanded in y around 0 63.8%
distribute-lft1-in63.8%
metadata-eval63.8%
*-commutative63.8%
Simplified63.8%
Final simplification77.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -6.0 (* (- y x) z))))
(if (<= z -13.5)
t_0
(if (<= z -4.3e-237)
(* y (+ 4.0 (* -6.0 z)))
(if (<= z 0.5) (* x -3.0) t_0)))))
double code(double x, double y, double z) {
double t_0 = -6.0 * ((y - x) * z);
double tmp;
if (z <= -13.5) {
tmp = t_0;
} else if (z <= -4.3e-237) {
tmp = y * (4.0 + (-6.0 * z));
} 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 - x) * z)
if (z <= (-13.5d0)) then
tmp = t_0
else if (z <= (-4.3d-237)) then
tmp = y * (4.0d0 + ((-6.0d0) * z))
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 - x) * z);
double tmp;
if (z <= -13.5) {
tmp = t_0;
} else if (z <= -4.3e-237) {
tmp = y * (4.0 + (-6.0 * z));
} 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 - x) * z) tmp = 0 if z <= -13.5: tmp = t_0 elif z <= -4.3e-237: tmp = y * (4.0 + (-6.0 * z)) 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(Float64(y - x) * z)) tmp = 0.0 if (z <= -13.5) tmp = t_0; elseif (z <= -4.3e-237) tmp = Float64(y * Float64(4.0 + Float64(-6.0 * z))); 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 - x) * z); tmp = 0.0; if (z <= -13.5) tmp = t_0; elseif (z <= -4.3e-237) tmp = y * (4.0 + (-6.0 * z)); 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[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -13.5], t$95$0, If[LessEqual[z, -4.3e-237], N[(y * N[(4.0 + N[(-6.0 * z), $MachinePrecision]), $MachinePrecision]), $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(\left(y - x\right) \cdot z\right)\\
\mathbf{if}\;z \leq -13.5:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -4.3 \cdot 10^{-237}:\\
\;\;\;\;y \cdot \left(4 + -6 \cdot z\right)\\
\mathbf{elif}\;z \leq 0.5:\\
\;\;\;\;x \cdot -3\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -13.5 or 0.5 < z Initial program 99.8%
Taylor expanded in z around 0 99.8%
Taylor expanded in z around inf 97.6%
if -13.5 < z < -4.29999999999999982e-237Initial program 99.3%
Taylor expanded in z around 0 99.9%
Taylor expanded in y around inf 59.8%
if -4.29999999999999982e-237 < z < 0.5Initial program 99.3%
Taylor expanded in z around 0 98.4%
Taylor expanded in y around 0 63.8%
distribute-lft1-in63.8%
metadata-eval63.8%
*-commutative63.8%
Simplified63.8%
Final simplification78.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -6.0 (* (- y x) z))))
(if (<= z -480.0)
t_0
(if (<= z -4.7e-237)
(* y (+ 4.0 (* -6.0 z)))
(if (<= z 130000.0) (* x (- (* z 6.0) 3.0)) t_0)))))
double code(double x, double y, double z) {
double t_0 = -6.0 * ((y - x) * z);
double tmp;
if (z <= -480.0) {
tmp = t_0;
} else if (z <= -4.7e-237) {
tmp = y * (4.0 + (-6.0 * z));
} else if (z <= 130000.0) {
tmp = x * ((z * 6.0) - 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 - x) * z)
if (z <= (-480.0d0)) then
tmp = t_0
else if (z <= (-4.7d-237)) then
tmp = y * (4.0d0 + ((-6.0d0) * z))
else if (z <= 130000.0d0) then
tmp = x * ((z * 6.0d0) - 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 - x) * z);
double tmp;
if (z <= -480.0) {
tmp = t_0;
} else if (z <= -4.7e-237) {
tmp = y * (4.0 + (-6.0 * z));
} else if (z <= 130000.0) {
tmp = x * ((z * 6.0) - 3.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -6.0 * ((y - x) * z) tmp = 0 if z <= -480.0: tmp = t_0 elif z <= -4.7e-237: tmp = y * (4.0 + (-6.0 * z)) elif z <= 130000.0: tmp = x * ((z * 6.0) - 3.0) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-6.0 * Float64(Float64(y - x) * z)) tmp = 0.0 if (z <= -480.0) tmp = t_0; elseif (z <= -4.7e-237) tmp = Float64(y * Float64(4.0 + Float64(-6.0 * z))); elseif (z <= 130000.0) tmp = Float64(x * Float64(Float64(z * 6.0) - 3.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -6.0 * ((y - x) * z); tmp = 0.0; if (z <= -480.0) tmp = t_0; elseif (z <= -4.7e-237) tmp = y * (4.0 + (-6.0 * z)); elseif (z <= 130000.0) tmp = x * ((z * 6.0) - 3.0); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -480.0], t$95$0, If[LessEqual[z, -4.7e-237], N[(y * N[(4.0 + N[(-6.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 130000.0], N[(x * N[(N[(z * 6.0), $MachinePrecision] - 3.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -6 \cdot \left(\left(y - x\right) \cdot z\right)\\
\mathbf{if}\;z \leq -480:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -4.7 \cdot 10^{-237}:\\
\;\;\;\;y \cdot \left(4 + -6 \cdot z\right)\\
\mathbf{elif}\;z \leq 130000:\\
\;\;\;\;x \cdot \left(z \cdot 6 - 3\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -480 or 1.3e5 < z Initial program 99.8%
Taylor expanded in z around 0 99.8%
Taylor expanded in z around inf 98.2%
if -480 < z < -4.6999999999999998e-237Initial program 99.3%
Taylor expanded in z around 0 99.9%
Taylor expanded in y around inf 59.8%
if -4.6999999999999998e-237 < z < 1.3e5Initial program 99.3%
Taylor expanded in z around 0 99.8%
Taylor expanded in x around inf 65.2%
Final simplification78.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -6.0 (* y z))))
(if (<= z -0.68)
t_0
(if (<= z -1.05e-236) (* 4.0 y) (if (<= z 0.6) (* x -3.0) t_0)))))
double code(double x, double y, double z) {
double t_0 = -6.0 * (y * z);
double tmp;
if (z <= -0.68) {
tmp = t_0;
} else if (z <= -1.05e-236) {
tmp = 4.0 * y;
} else if (z <= 0.6) {
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 <= (-0.68d0)) then
tmp = t_0
else if (z <= (-1.05d-236)) then
tmp = 4.0d0 * y
else if (z <= 0.6d0) 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 <= -0.68) {
tmp = t_0;
} else if (z <= -1.05e-236) {
tmp = 4.0 * y;
} else if (z <= 0.6) {
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 <= -0.68: tmp = t_0 elif z <= -1.05e-236: tmp = 4.0 * y elif z <= 0.6: 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 <= -0.68) tmp = t_0; elseif (z <= -1.05e-236) tmp = Float64(4.0 * y); elseif (z <= 0.6) 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 <= -0.68) tmp = t_0; elseif (z <= -1.05e-236) tmp = 4.0 * y; elseif (z <= 0.6) 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, -0.68], t$95$0, If[LessEqual[z, -1.05e-236], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, 0.6], 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 -0.68:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -1.05 \cdot 10^{-236}:\\
\;\;\;\;4 \cdot y\\
\mathbf{elif}\;z \leq 0.6:\\
\;\;\;\;x \cdot -3\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -0.680000000000000049 or 0.599999999999999978 < z Initial program 99.8%
Taylor expanded in z around 0 99.8%
Taylor expanded in y around inf 53.4%
Taylor expanded in z around inf 52.8%
*-commutative52.8%
Simplified52.8%
if -0.680000000000000049 < z < -1.04999999999999989e-236Initial program 99.3%
Taylor expanded in z around 0 97.8%
Taylor expanded in y around inf 58.1%
*-commutative58.1%
Simplified58.1%
if -1.04999999999999989e-236 < z < 0.599999999999999978Initial program 99.3%
Taylor expanded in z around 0 98.4%
Taylor expanded in y around 0 63.8%
distribute-lft1-in63.8%
metadata-eval63.8%
*-commutative63.8%
Simplified63.8%
Final simplification57.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.55) (not (<= z 0.65))) (* -6.0 (* (- y x) z)) (+ (* x -3.0) (* 4.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.55) || !(z <= 0.65)) {
tmp = -6.0 * ((y - x) * z);
} else {
tmp = (x * -3.0) + (4.0 * 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.65d0))) then
tmp = (-6.0d0) * ((y - x) * z)
else
tmp = (x * (-3.0d0)) + (4.0d0 * 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.65)) {
tmp = -6.0 * ((y - x) * z);
} else {
tmp = (x * -3.0) + (4.0 * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.55) or not (z <= 0.65): tmp = -6.0 * ((y - x) * z) else: tmp = (x * -3.0) + (4.0 * y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.55) || !(z <= 0.65)) tmp = Float64(-6.0 * Float64(Float64(y - x) * z)); else tmp = Float64(Float64(x * -3.0) + Float64(4.0 * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.55) || ~((z <= 0.65))) tmp = -6.0 * ((y - x) * z); else tmp = (x * -3.0) + (4.0 * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.55], N[Not[LessEqual[z, 0.65]], $MachinePrecision]], N[(-6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(N[(x * -3.0), $MachinePrecision] + N[(4.0 * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.55 \lor \neg \left(z \leq 0.65\right):\\
\;\;\;\;-6 \cdot \left(\left(y - x\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot -3 + 4 \cdot y\\
\end{array}
\end{array}
if z < -0.55000000000000004 or 0.650000000000000022 < z Initial program 99.8%
Taylor expanded in z around 0 99.8%
Taylor expanded in z around inf 97.6%
if -0.55000000000000004 < z < 0.650000000000000022Initial program 99.3%
Taylor expanded in z around 0 98.1%
Taylor expanded in x around 0 98.1%
Final simplification97.9%
(FPCore (x y z) :precision binary64 (+ x (* (- 0.6666666666666666 z) (* (- y x) 6.0))))
double code(double x, double y, double z) {
return x + ((0.6666666666666666 - z) * ((y - x) * 6.0));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + ((0.6666666666666666d0 - z) * ((y - x) * 6.0d0))
end function
public static double code(double x, double y, double z) {
return x + ((0.6666666666666666 - z) * ((y - x) * 6.0));
}
def code(x, y, z): return x + ((0.6666666666666666 - z) * ((y - x) * 6.0))
function code(x, y, z) return Float64(x + Float64(Float64(0.6666666666666666 - z) * Float64(Float64(y - x) * 6.0))) end
function tmp = code(x, y, z) tmp = x + ((0.6666666666666666 - z) * ((y - x) * 6.0)); end
code[x_, y_, z_] := N[(x + N[(N[(0.6666666666666666 - z), $MachinePrecision] * N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(0.6666666666666666 - z\right) \cdot \left(\left(y - x\right) \cdot 6\right)
\end{array}
Initial program 99.5%
Taylor expanded in z around 0 99.5%
neg-mul-199.5%
+-commutative99.5%
sub-neg99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (+ x (* (- y x) (* 6.0 (- 0.6666666666666666 z)))))
double code(double x, double y, double z) {
return x + ((y - x) * (6.0 * (0.6666666666666666 - z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + ((y - x) * (6.0d0 * (0.6666666666666666d0 - z)))
end function
public static double code(double x, double y, double z) {
return x + ((y - x) * (6.0 * (0.6666666666666666 - z)));
}
def code(x, y, z): return x + ((y - x) * (6.0 * (0.6666666666666666 - z)))
function code(x, y, z) return Float64(x + Float64(Float64(y - x) * Float64(6.0 * Float64(0.6666666666666666 - z)))) end
function tmp = code(x, y, z) tmp = x + ((y - x) * (6.0 * (0.6666666666666666 - z))); end
code[x_, y_, z_] := N[(x + N[(N[(y - x), $MachinePrecision] * N[(6.0 * N[(0.6666666666666666 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)
\end{array}
Initial program 99.5%
associate-*l*99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (<= x -1.06e+58) (* x -3.0) (if (<= x 4.6e-82) (* 4.0 y) (* x -3.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.06e+58) {
tmp = x * -3.0;
} else if (x <= 4.6e-82) {
tmp = 4.0 * y;
} 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 (x <= (-1.06d+58)) then
tmp = x * (-3.0d0)
else if (x <= 4.6d-82) then
tmp = 4.0d0 * y
else
tmp = x * (-3.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.06e+58) {
tmp = x * -3.0;
} else if (x <= 4.6e-82) {
tmp = 4.0 * y;
} else {
tmp = x * -3.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.06e+58: tmp = x * -3.0 elif x <= 4.6e-82: tmp = 4.0 * y else: tmp = x * -3.0 return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.06e+58) tmp = Float64(x * -3.0); elseif (x <= 4.6e-82) tmp = Float64(4.0 * y); else tmp = Float64(x * -3.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.06e+58) tmp = x * -3.0; elseif (x <= 4.6e-82) tmp = 4.0 * y; else tmp = x * -3.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.06e+58], N[(x * -3.0), $MachinePrecision], If[LessEqual[x, 4.6e-82], N[(4.0 * y), $MachinePrecision], N[(x * -3.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.06 \cdot 10^{+58}:\\
\;\;\;\;x \cdot -3\\
\mathbf{elif}\;x \leq 4.6 \cdot 10^{-82}:\\
\;\;\;\;4 \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot -3\\
\end{array}
\end{array}
if x < -1.05999999999999997e58 or 4.59999999999999994e-82 < x Initial program 99.5%
Taylor expanded in z around 0 54.2%
Taylor expanded in y around 0 42.5%
distribute-lft1-in42.5%
metadata-eval42.5%
*-commutative42.5%
Simplified42.5%
if -1.05999999999999997e58 < x < 4.59999999999999994e-82Initial program 99.5%
Taylor expanded in z around 0 56.9%
Taylor expanded in y around inf 43.4%
*-commutative43.4%
Simplified43.4%
Final simplification42.9%
(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%
Taylor expanded in z around 0 55.4%
Taylor expanded in y around 0 30.8%
distribute-lft1-in30.8%
metadata-eval30.8%
*-commutative30.8%
Simplified30.8%
Final simplification30.8%
herbie shell --seed 2023240
(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))))