
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * 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 * (1.0d0 - ((1.0d0 - y) * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
def code(x, y, z): return x * (1.0 - ((1.0 - y) * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - ((1.0 - y) * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * 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 * (1.0d0 - ((1.0d0 - y) * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
def code(x, y, z): return x * (1.0 - ((1.0 - y) * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - ((1.0 - y) * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\end{array}
(FPCore (x y z) :precision binary64 (if (<= (* (- 1.0 y) z) 2e+305) (* x (+ 1.0 (* z (+ y -1.0)))) (* y (* z x))))
double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= 2e+305) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = y * (z * 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 (((1.0d0 - y) * z) <= 2d+305) then
tmp = x * (1.0d0 + (z * (y + (-1.0d0))))
else
tmp = y * (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= 2e+305) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = y * (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((1.0 - y) * z) <= 2e+305: tmp = x * (1.0 + (z * (y + -1.0))) else: tmp = y * (z * x) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(Float64(1.0 - y) * z) <= 2e+305) tmp = Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0)))); else tmp = Float64(y * Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((1.0 - y) * z) <= 2e+305) tmp = x * (1.0 + (z * (y + -1.0))); else tmp = y * (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision], 2e+305], N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 - y\right) \cdot z \leq 2 \cdot 10^{+305}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 #s(literal 1 binary64) y) z) < 1.9999999999999999e305Initial program 98.4%
if 1.9999999999999999e305 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) Initial program 55.8%
Taylor expanded in y around inf 88.1%
+-commutative88.1%
associate-/l*99.9%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in y around inf 99.9%
Final simplification98.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- x))))
(if (<= z -1.0)
t_0
(if (<= z 3.6e-50) x (if (<= z 5.1e+16) (* x (* y z)) t_0)))))
double code(double x, double y, double z) {
double t_0 = z * -x;
double tmp;
if (z <= -1.0) {
tmp = t_0;
} else if (z <= 3.6e-50) {
tmp = x;
} else if (z <= 5.1e+16) {
tmp = x * (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 = z * -x
if (z <= (-1.0d0)) then
tmp = t_0
else if (z <= 3.6d-50) then
tmp = x
else if (z <= 5.1d+16) then
tmp = x * (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 = z * -x;
double tmp;
if (z <= -1.0) {
tmp = t_0;
} else if (z <= 3.6e-50) {
tmp = x;
} else if (z <= 5.1e+16) {
tmp = x * (y * z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * -x tmp = 0 if z <= -1.0: tmp = t_0 elif z <= 3.6e-50: tmp = x elif z <= 5.1e+16: tmp = x * (y * z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-x)) tmp = 0.0 if (z <= -1.0) tmp = t_0; elseif (z <= 3.6e-50) tmp = x; elseif (z <= 5.1e+16) tmp = Float64(x * Float64(y * z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * -x; tmp = 0.0; if (z <= -1.0) tmp = t_0; elseif (z <= 3.6e-50) tmp = x; elseif (z <= 5.1e+16) tmp = x * (y * z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * (-x)), $MachinePrecision]}, If[LessEqual[z, -1.0], t$95$0, If[LessEqual[z, 3.6e-50], x, If[LessEqual[z, 5.1e+16], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(-x\right)\\
\mathbf{if}\;z \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 3.6 \cdot 10^{-50}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 5.1 \cdot 10^{+16}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1 or 5.1e16 < z Initial program 90.9%
Taylor expanded in z around inf 90.4%
Taylor expanded in y around 0 56.9%
mul-1-neg56.9%
distribute-rgt-neg-out56.9%
Simplified56.9%
if -1 < z < 3.59999999999999979e-50Initial program 99.9%
Taylor expanded in z around 0 81.1%
if 3.59999999999999979e-50 < z < 5.1e16Initial program 99.9%
Taylor expanded in y around inf 62.9%
*-commutative62.9%
Simplified62.9%
Final simplification68.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.0))) (* x (* z (+ y -1.0))) (* x (+ 1.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = x * (z * (y + -1.0));
} else {
tmp = x * (1.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 <= (-1.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = x * (z * (y + (-1.0d0)))
else
tmp = x * (1.0d0 + (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = x * (z * (y + -1.0));
} else {
tmp = x * (1.0 + (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = x * (z * (y + -1.0)) else: tmp = x * (1.0 + (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) tmp = Float64(x * Float64(z * Float64(y + -1.0))); else tmp = Float64(x * Float64(1.0 + Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 1.0))) tmp = x * (z * (y + -1.0)); else tmp = x * (1.0 + (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(x * N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x \cdot \left(z \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + y \cdot z\right)\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 91.1%
Taylor expanded in z around inf 90.1%
if -1 < z < 1Initial program 99.9%
Taylor expanded in y around inf 98.9%
neg-mul-198.9%
Simplified98.9%
cancel-sign-sub98.9%
+-commutative98.9%
Applied egg-rr98.9%
Final simplification94.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.45e+90) (not (<= y 5.6e+35))) (* y (* z x)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.45e+90) || !(y <= 5.6e+35)) {
tmp = y * (z * x);
} else {
tmp = x * (1.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 ((y <= (-2.45d+90)) .or. (.not. (y <= 5.6d+35))) then
tmp = y * (z * x)
else
tmp = x * (1.0d0 - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -2.45e+90) || !(y <= 5.6e+35)) {
tmp = y * (z * x);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.45e+90) or not (y <= 5.6e+35): tmp = y * (z * x) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.45e+90) || !(y <= 5.6e+35)) tmp = Float64(y * Float64(z * x)); else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.45e+90) || ~((y <= 5.6e+35))) tmp = y * (z * x); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.45e+90], N[Not[LessEqual[y, 5.6e+35]], $MachinePrecision]], N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.45 \cdot 10^{+90} \lor \neg \left(y \leq 5.6 \cdot 10^{+35}\right):\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -2.4500000000000001e90 or 5.59999999999999997e35 < y Initial program 88.9%
Taylor expanded in y around inf 80.1%
+-commutative80.1%
associate-/l*87.5%
distribute-lft-out92.8%
Simplified92.8%
Taylor expanded in y around inf 80.1%
if -2.4500000000000001e90 < y < 5.59999999999999997e35Initial program 99.4%
Taylor expanded in y around 0 93.5%
Final simplification88.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.1e+90) (not (<= y 1.05e+38))) (* x (* y z)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.1e+90) || !(y <= 1.05e+38)) {
tmp = x * (y * z);
} else {
tmp = x * (1.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 ((y <= (-1.1d+90)) .or. (.not. (y <= 1.05d+38))) then
tmp = x * (y * z)
else
tmp = x * (1.0d0 - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.1e+90) || !(y <= 1.05e+38)) {
tmp = x * (y * z);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.1e+90) or not (y <= 1.05e+38): tmp = x * (y * z) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.1e+90) || !(y <= 1.05e+38)) tmp = Float64(x * Float64(y * z)); else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.1e+90) || ~((y <= 1.05e+38))) tmp = x * (y * z); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.1e+90], N[Not[LessEqual[y, 1.05e+38]], $MachinePrecision]], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.1 \cdot 10^{+90} \lor \neg \left(y \leq 1.05 \cdot 10^{+38}\right):\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -1.09999999999999995e90 or 1.05e38 < y Initial program 88.9%
Taylor expanded in y around inf 72.9%
*-commutative72.9%
Simplified72.9%
if -1.09999999999999995e90 < y < 1.05e38Initial program 99.4%
Taylor expanded in y around 0 93.5%
Final simplification85.9%
(FPCore (x y z) :precision binary64 (if (<= y -1.15e+91) (* z (* y x)) (if (<= y 3.3e+35) (- x (* z x)) (* y (* z x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.15e+91) {
tmp = z * (y * x);
} else if (y <= 3.3e+35) {
tmp = x - (z * x);
} else {
tmp = y * (z * 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 (y <= (-1.15d+91)) then
tmp = z * (y * x)
else if (y <= 3.3d+35) then
tmp = x - (z * x)
else
tmp = y * (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.15e+91) {
tmp = z * (y * x);
} else if (y <= 3.3e+35) {
tmp = x - (z * x);
} else {
tmp = y * (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.15e+91: tmp = z * (y * x) elif y <= 3.3e+35: tmp = x - (z * x) else: tmp = y * (z * x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.15e+91) tmp = Float64(z * Float64(y * x)); elseif (y <= 3.3e+35) tmp = Float64(x - Float64(z * x)); else tmp = Float64(y * Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.15e+91) tmp = z * (y * x); elseif (y <= 3.3e+35) tmp = x - (z * x); else tmp = y * (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.15e+91], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.3e+35], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision], N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.15 \cdot 10^{+91}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;y \leq 3.3 \cdot 10^{+35}:\\
\;\;\;\;x - z \cdot x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\end{array}
\end{array}
if y < -1.14999999999999996e91Initial program 84.0%
Taylor expanded in y around inf 70.7%
associate-*r*84.2%
Simplified84.2%
if -1.14999999999999996e91 < y < 3.3000000000000002e35Initial program 99.4%
Taylor expanded in y around 0 93.5%
sub-neg93.5%
distribute-rgt-in93.5%
*-un-lft-identity93.5%
Applied egg-rr93.5%
*-commutative93.5%
distribute-rgt-neg-out93.5%
unsub-neg93.5%
Applied egg-rr93.5%
if 3.3000000000000002e35 < y Initial program 92.8%
Taylor expanded in y around inf 70.2%
+-commutative70.2%
associate-/l*83.4%
distribute-lft-out92.8%
Simplified92.8%
Taylor expanded in y around inf 78.8%
Final simplification89.0%
(FPCore (x y z) :precision binary64 (if (<= y -8.8e+89) (* z (* y x)) (if (<= y 2.7e+36) (* x (- 1.0 z)) (* y (* z x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -8.8e+89) {
tmp = z * (y * x);
} else if (y <= 2.7e+36) {
tmp = x * (1.0 - z);
} else {
tmp = y * (z * 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 (y <= (-8.8d+89)) then
tmp = z * (y * x)
else if (y <= 2.7d+36) then
tmp = x * (1.0d0 - z)
else
tmp = y * (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -8.8e+89) {
tmp = z * (y * x);
} else if (y <= 2.7e+36) {
tmp = x * (1.0 - z);
} else {
tmp = y * (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -8.8e+89: tmp = z * (y * x) elif y <= 2.7e+36: tmp = x * (1.0 - z) else: tmp = y * (z * x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -8.8e+89) tmp = Float64(z * Float64(y * x)); elseif (y <= 2.7e+36) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(y * Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -8.8e+89) tmp = z * (y * x); elseif (y <= 2.7e+36) tmp = x * (1.0 - z); else tmp = y * (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -8.8e+89], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.7e+36], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.8 \cdot 10^{+89}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{+36}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\end{array}
\end{array}
if y < -8.8000000000000001e89Initial program 84.0%
Taylor expanded in y around inf 70.7%
associate-*r*84.2%
Simplified84.2%
if -8.8000000000000001e89 < y < 2.7000000000000001e36Initial program 99.4%
Taylor expanded in y around 0 93.5%
if 2.7000000000000001e36 < y Initial program 92.8%
Taylor expanded in y around inf 70.2%
+-commutative70.2%
associate-/l*83.4%
distribute-lft-out92.8%
Simplified92.8%
Taylor expanded in y around inf 78.8%
Final simplification89.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 0.0165))) (* z (- x)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 0.0165)) {
tmp = z * -x;
} 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.0d0)) .or. (.not. (z <= 0.0165d0))) then
tmp = z * -x
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 0.0165)) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 0.0165): tmp = z * -x else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 0.0165)) tmp = Float64(z * Float64(-x)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 0.0165))) tmp = z * -x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 0.0165]], $MachinePrecision]], N[(z * (-x)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 0.0165\right):\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1 or 0.016500000000000001 < z Initial program 91.2%
Taylor expanded in z around inf 89.5%
Taylor expanded in y around 0 55.5%
mul-1-neg55.5%
distribute-rgt-neg-out55.5%
Simplified55.5%
if -1 < z < 0.016500000000000001Initial program 99.9%
Taylor expanded in z around 0 77.4%
Final simplification66.4%
(FPCore (x y z) :precision binary64 (if (<= z 6.6e+41) x (* z x)))
double code(double x, double y, double z) {
double tmp;
if (z <= 6.6e+41) {
tmp = x;
} else {
tmp = z * 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 <= 6.6d+41) then
tmp = x
else
tmp = z * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 6.6e+41) {
tmp = x;
} else {
tmp = z * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 6.6e+41: tmp = x else: tmp = z * x return tmp
function code(x, y, z) tmp = 0.0 if (z <= 6.6e+41) tmp = x; else tmp = Float64(z * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 6.6e+41) tmp = x; else tmp = z * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 6.6e+41], x, N[(z * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 6.6 \cdot 10^{+41}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if z < 6.6000000000000001e41Initial program 98.1%
Taylor expanded in z around 0 51.0%
if 6.6000000000000001e41 < z Initial program 86.6%
Taylor expanded in z around inf 86.6%
Taylor expanded in y around 0 51.4%
mul-1-neg51.4%
distribute-rgt-neg-out51.4%
Simplified51.4%
add-sqr-sqrt0.0%
sqrt-unprod18.5%
sqr-neg18.5%
sqrt-unprod17.2%
add-sqr-sqrt17.2%
pow117.2%
Applied egg-rr17.2%
unpow117.2%
Simplified17.2%
Final simplification43.6%
(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 95.5%
Taylor expanded in z around 0 40.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- 1.0 (* (- 1.0 y) z))))
(t_1 (+ x (* (- 1.0 y) (* (- z) x)))))
(if (< t_0 -1.618195973607049e+50)
t_1
(if (< t_0 3.892237649663903e+134) (- (* (* x y) z) (- (* x z) x)) t_1))))
double code(double x, double y, double z) {
double t_0 = x * (1.0 - ((1.0 - y) * z));
double t_1 = x + ((1.0 - y) * (-z * x));
double tmp;
if (t_0 < -1.618195973607049e+50) {
tmp = t_1;
} else if (t_0 < 3.892237649663903e+134) {
tmp = ((x * y) * z) - ((x * z) - x);
} 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 = x * (1.0d0 - ((1.0d0 - y) * z))
t_1 = x + ((1.0d0 - y) * (-z * x))
if (t_0 < (-1.618195973607049d+50)) then
tmp = t_1
else if (t_0 < 3.892237649663903d+134) then
tmp = ((x * y) * z) - ((x * z) - x)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (1.0 - ((1.0 - y) * z));
double t_1 = x + ((1.0 - y) * (-z * x));
double tmp;
if (t_0 < -1.618195973607049e+50) {
tmp = t_1;
} else if (t_0 < 3.892237649663903e+134) {
tmp = ((x * y) * z) - ((x * z) - x);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = x * (1.0 - ((1.0 - y) * z)) t_1 = x + ((1.0 - y) * (-z * x)) tmp = 0 if t_0 < -1.618195973607049e+50: tmp = t_1 elif t_0 < 3.892237649663903e+134: tmp = ((x * y) * z) - ((x * z) - x) else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) t_1 = Float64(x + Float64(Float64(1.0 - y) * Float64(Float64(-z) * x))) tmp = 0.0 if (t_0 < -1.618195973607049e+50) tmp = t_1; elseif (t_0 < 3.892237649663903e+134) tmp = Float64(Float64(Float64(x * y) * z) - Float64(Float64(x * z) - x)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (1.0 - ((1.0 - y) * z)); t_1 = x + ((1.0 - y) * (-z * x)); tmp = 0.0; if (t_0 < -1.618195973607049e+50) tmp = t_1; elseif (t_0 < 3.892237649663903e+134) tmp = ((x * y) * z) - ((x * z) - x); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x + N[(N[(1.0 - y), $MachinePrecision] * N[((-z) * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[t$95$0, -1.618195973607049e+50], t$95$1, If[Less[t$95$0, 3.892237649663903e+134], N[(N[(N[(x * y), $MachinePrecision] * z), $MachinePrecision] - N[(N[(x * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\
t_1 := x + \left(1 - y\right) \cdot \left(\left(-z\right) \cdot x\right)\\
\mathbf{if}\;t\_0 < -1.618195973607049 \cdot 10^{+50}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 < 3.892237649663903 \cdot 10^{+134}:\\
\;\;\;\;\left(x \cdot y\right) \cdot z - \left(x \cdot z - x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2024110
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"
:precision binary64
:alt
(if (< (* x (- 1.0 (* (- 1.0 y) z))) -1.618195973607049e+50) (+ x (* (- 1.0 y) (* (- z) x))) (if (< (* x (- 1.0 (* (- 1.0 y) z))) 3.892237649663903e+134) (- (* (* x y) z) (- (* x z) x)) (+ x (* (- 1.0 y) (* (- z) x)))))
(* x (- 1.0 (* (- 1.0 y) z))))