
(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 (<= z -1.05) (* z (* x (+ y -1.0))) (if (<= z 0.0045) (+ x (* x (* y z))) (* z (- (* y x) x)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.05) {
tmp = z * (x * (y + -1.0));
} else if (z <= 0.0045) {
tmp = x + (x * (y * z));
} else {
tmp = z * ((y * x) - 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.05d0)) then
tmp = z * (x * (y + (-1.0d0)))
else if (z <= 0.0045d0) then
tmp = x + (x * (y * z))
else
tmp = z * ((y * x) - x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.05) {
tmp = z * (x * (y + -1.0));
} else if (z <= 0.0045) {
tmp = x + (x * (y * z));
} else {
tmp = z * ((y * x) - x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.05: tmp = z * (x * (y + -1.0)) elif z <= 0.0045: tmp = x + (x * (y * z)) else: tmp = z * ((y * x) - x) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.05) tmp = Float64(z * Float64(x * Float64(y + -1.0))); elseif (z <= 0.0045) tmp = Float64(x + Float64(x * Float64(y * z))); else tmp = Float64(z * Float64(Float64(y * x) - x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.05) tmp = z * (x * (y + -1.0)); elseif (z <= 0.0045) tmp = x + (x * (y * z)); else tmp = z * ((y * x) - x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.05], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 0.0045], N[(x + N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(N[(y * x), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05:\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{elif}\;z \leq 0.0045:\\
\;\;\;\;x + x \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot x - x\right)\\
\end{array}
\end{array}
if z < -1.05000000000000004Initial program 88.6%
Taylor expanded in z around inf 97.1%
if -1.05000000000000004 < z < 0.00449999999999999966Initial program 99.9%
Taylor expanded in y around inf 99.5%
mul-1-neg99.5%
distribute-lft-neg-out99.5%
*-commutative99.5%
Simplified99.5%
sub-neg99.5%
distribute-rgt-neg-out99.5%
remove-double-neg99.5%
distribute-lft-in99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
Applied egg-rr99.5%
if 0.00449999999999999966 < z Initial program 94.5%
Taylor expanded in z around inf 99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
distribute-rgt-in99.9%
neg-mul-199.9%
unsub-neg99.9%
Simplified99.9%
Final simplification99.1%
(FPCore (x y z) :precision binary64 (fma (+ y -1.0) (* x z) x))
double code(double x, double y, double z) {
return fma((y + -1.0), (x * z), x);
}
function code(x, y, z) return fma(Float64(y + -1.0), Float64(x * z), x) end
code[x_, y_, z_] := N[(N[(y + -1.0), $MachinePrecision] * N[(x * z), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y + -1, x \cdot z, x\right)
\end{array}
Initial program 95.8%
distribute-rgt-out--95.8%
*-lft-identity95.8%
cancel-sign-sub-inv95.8%
+-commutative95.8%
distribute-lft-neg-in95.8%
associate-*l*98.3%
fma-def98.3%
neg-sub098.3%
associate--r-98.3%
metadata-eval98.3%
+-commutative98.3%
*-commutative98.3%
Simplified98.3%
Final simplification98.3%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (+ 1.0 (* z (+ y -1.0)))))) (if (<= t_0 2e+304) t_0 (* z (* x (+ y -1.0))))))
double code(double x, double y, double z) {
double t_0 = x * (1.0 + (z * (y + -1.0)));
double tmp;
if (t_0 <= 2e+304) {
tmp = t_0;
} else {
tmp = z * (x * (y + -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) :: t_0
real(8) :: tmp
t_0 = x * (1.0d0 + (z * (y + (-1.0d0))))
if (t_0 <= 2d+304) then
tmp = t_0
else
tmp = z * (x * (y + (-1.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (1.0 + (z * (y + -1.0)));
double tmp;
if (t_0 <= 2e+304) {
tmp = t_0;
} else {
tmp = z * (x * (y + -1.0));
}
return tmp;
}
def code(x, y, z): t_0 = x * (1.0 + (z * (y + -1.0))) tmp = 0 if t_0 <= 2e+304: tmp = t_0 else: tmp = z * (x * (y + -1.0)) return tmp
function code(x, y, z) t_0 = Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0)))) tmp = 0.0 if (t_0 <= 2e+304) tmp = t_0; else tmp = Float64(z * Float64(x * Float64(y + -1.0))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (1.0 + (z * (y + -1.0))); tmp = 0.0; if (t_0 <= 2e+304) tmp = t_0; else tmp = z * (x * (y + -1.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 2e+304], t$95$0, N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\mathbf{if}\;t_0 \leq 2 \cdot 10^{+304}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z))) < 1.9999999999999999e304Initial program 98.6%
if 1.9999999999999999e304 < (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z))) Initial program 77.2%
Taylor expanded in z around inf 99.9%
Final simplification98.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (* x z))))
(if (<= z -2.35e-60)
t_0
(if (<= z 9e-74)
x
(if (or (<= z 2.1e+60) (and (not (<= z 1.6e+171)) (<= z 1.12e+219)))
t_0
(* x (- z)))))))
double code(double x, double y, double z) {
double t_0 = y * (x * z);
double tmp;
if (z <= -2.35e-60) {
tmp = t_0;
} else if (z <= 9e-74) {
tmp = x;
} else if ((z <= 2.1e+60) || (!(z <= 1.6e+171) && (z <= 1.12e+219))) {
tmp = t_0;
} else {
tmp = 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) :: t_0
real(8) :: tmp
t_0 = y * (x * z)
if (z <= (-2.35d-60)) then
tmp = t_0
else if (z <= 9d-74) then
tmp = x
else if ((z <= 2.1d+60) .or. (.not. (z <= 1.6d+171)) .and. (z <= 1.12d+219)) then
tmp = t_0
else
tmp = x * -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * (x * z);
double tmp;
if (z <= -2.35e-60) {
tmp = t_0;
} else if (z <= 9e-74) {
tmp = x;
} else if ((z <= 2.1e+60) || (!(z <= 1.6e+171) && (z <= 1.12e+219))) {
tmp = t_0;
} else {
tmp = x * -z;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x * z) tmp = 0 if z <= -2.35e-60: tmp = t_0 elif z <= 9e-74: tmp = x elif (z <= 2.1e+60) or (not (z <= 1.6e+171) and (z <= 1.12e+219)): tmp = t_0 else: tmp = x * -z return tmp
function code(x, y, z) t_0 = Float64(y * Float64(x * z)) tmp = 0.0 if (z <= -2.35e-60) tmp = t_0; elseif (z <= 9e-74) tmp = x; elseif ((z <= 2.1e+60) || (!(z <= 1.6e+171) && (z <= 1.12e+219))) tmp = t_0; else tmp = Float64(x * Float64(-z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (x * z); tmp = 0.0; if (z <= -2.35e-60) tmp = t_0; elseif (z <= 9e-74) tmp = x; elseif ((z <= 2.1e+60) || (~((z <= 1.6e+171)) && (z <= 1.12e+219))) tmp = t_0; else tmp = x * -z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.35e-60], t$95$0, If[LessEqual[z, 9e-74], x, If[Or[LessEqual[z, 2.1e+60], And[N[Not[LessEqual[z, 1.6e+171]], $MachinePrecision], LessEqual[z, 1.12e+219]]], t$95$0, N[(x * (-z)), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(x \cdot z\right)\\
\mathbf{if}\;z \leq -2.35 \cdot 10^{-60}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 9 \cdot 10^{-74}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 2.1 \cdot 10^{+60} \lor \neg \left(z \leq 1.6 \cdot 10^{+171}\right) \land z \leq 1.12 \cdot 10^{+219}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(-z\right)\\
\end{array}
\end{array}
if z < -2.35e-60 or 8.9999999999999998e-74 < z < 2.1000000000000001e60 or 1.60000000000000006e171 < z < 1.1199999999999999e219Initial program 91.3%
Taylor expanded in y around inf 64.0%
if -2.35e-60 < z < 8.9999999999999998e-74Initial program 100.0%
Taylor expanded in z around 0 81.8%
if 2.1000000000000001e60 < z < 1.60000000000000006e171 or 1.1199999999999999e219 < z Initial program 97.8%
Taylor expanded in z around inf 99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
distribute-rgt-in99.9%
neg-mul-199.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in y around 0 67.8%
mul-1-neg67.8%
distribute-rgt-neg-out67.8%
Simplified67.8%
Final simplification71.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (* x z))))
(if (<= z -2.05e-60)
t_0
(if (<= z 1.35e-76)
x
(if (<= z 3.15e+60)
t_0
(if (or (<= z 1.15e+171) (not (<= z 6e+221)))
(* x (- z))
(* z (* y x))))))))
double code(double x, double y, double z) {
double t_0 = y * (x * z);
double tmp;
if (z <= -2.05e-60) {
tmp = t_0;
} else if (z <= 1.35e-76) {
tmp = x;
} else if (z <= 3.15e+60) {
tmp = t_0;
} else if ((z <= 1.15e+171) || !(z <= 6e+221)) {
tmp = x * -z;
} else {
tmp = z * (y * 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) :: t_0
real(8) :: tmp
t_0 = y * (x * z)
if (z <= (-2.05d-60)) then
tmp = t_0
else if (z <= 1.35d-76) then
tmp = x
else if (z <= 3.15d+60) then
tmp = t_0
else if ((z <= 1.15d+171) .or. (.not. (z <= 6d+221))) then
tmp = x * -z
else
tmp = z * (y * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * (x * z);
double tmp;
if (z <= -2.05e-60) {
tmp = t_0;
} else if (z <= 1.35e-76) {
tmp = x;
} else if (z <= 3.15e+60) {
tmp = t_0;
} else if ((z <= 1.15e+171) || !(z <= 6e+221)) {
tmp = x * -z;
} else {
tmp = z * (y * x);
}
return tmp;
}
def code(x, y, z): t_0 = y * (x * z) tmp = 0 if z <= -2.05e-60: tmp = t_0 elif z <= 1.35e-76: tmp = x elif z <= 3.15e+60: tmp = t_0 elif (z <= 1.15e+171) or not (z <= 6e+221): tmp = x * -z else: tmp = z * (y * x) return tmp
function code(x, y, z) t_0 = Float64(y * Float64(x * z)) tmp = 0.0 if (z <= -2.05e-60) tmp = t_0; elseif (z <= 1.35e-76) tmp = x; elseif (z <= 3.15e+60) tmp = t_0; elseif ((z <= 1.15e+171) || !(z <= 6e+221)) tmp = Float64(x * Float64(-z)); else tmp = Float64(z * Float64(y * x)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (x * z); tmp = 0.0; if (z <= -2.05e-60) tmp = t_0; elseif (z <= 1.35e-76) tmp = x; elseif (z <= 3.15e+60) tmp = t_0; elseif ((z <= 1.15e+171) || ~((z <= 6e+221))) tmp = x * -z; else tmp = z * (y * x); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.05e-60], t$95$0, If[LessEqual[z, 1.35e-76], x, If[LessEqual[z, 3.15e+60], t$95$0, If[Or[LessEqual[z, 1.15e+171], N[Not[LessEqual[z, 6e+221]], $MachinePrecision]], N[(x * (-z)), $MachinePrecision], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(x \cdot z\right)\\
\mathbf{if}\;z \leq -2.05 \cdot 10^{-60}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.35 \cdot 10^{-76}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 3.15 \cdot 10^{+60}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{+171} \lor \neg \left(z \leq 6 \cdot 10^{+221}\right):\\
\;\;\;\;x \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\end{array}
\end{array}
if z < -2.05000000000000006e-60 or 1.35e-76 < z < 3.1500000000000002e60Initial program 93.2%
Taylor expanded in y around inf 61.6%
if -2.05000000000000006e-60 < z < 1.35e-76Initial program 100.0%
Taylor expanded in z around 0 81.8%
if 3.1500000000000002e60 < z < 1.15000000000000009e171 or 6.0000000000000003e221 < z Initial program 97.8%
Taylor expanded in z around inf 99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
distribute-rgt-in99.9%
neg-mul-199.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in y around 0 67.8%
mul-1-neg67.8%
distribute-rgt-neg-out67.8%
Simplified67.8%
if 1.15000000000000009e171 < z < 6.0000000000000003e221Initial program 73.9%
Taylor expanded in y around inf 85.4%
associate-*r*59.6%
*-commutative59.6%
associate-*l*85.5%
Simplified85.5%
Final simplification71.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -105000.0) (not (<= y 1.02e+33))) (* y (* x z)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -105000.0) || !(y <= 1.02e+33)) {
tmp = y * (x * 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 <= (-105000.0d0)) .or. (.not. (y <= 1.02d+33))) then
tmp = y * (x * 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 <= -105000.0) || !(y <= 1.02e+33)) {
tmp = y * (x * z);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -105000.0) or not (y <= 1.02e+33): tmp = y * (x * z) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -105000.0) || !(y <= 1.02e+33)) tmp = Float64(y * Float64(x * 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 <= -105000.0) || ~((y <= 1.02e+33))) tmp = y * (x * z); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -105000.0], N[Not[LessEqual[y, 1.02e+33]], $MachinePrecision]], N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -105000 \lor \neg \left(y \leq 1.02 \cdot 10^{+33}\right):\\
\;\;\;\;y \cdot \left(x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -105000 or 1.02000000000000001e33 < y Initial program 90.7%
Taylor expanded in y around inf 75.2%
if -105000 < y < 1.02000000000000001e33Initial program 99.9%
Taylor expanded in y around 0 95.1%
Final simplification86.2%
(FPCore (x y z) :precision binary64 (if (<= y -1.4e-9) (* z (* x (+ y -1.0))) (if (<= y 2.7e+34) (* x (- 1.0 z)) (* y (* x z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.4e-9) {
tmp = z * (x * (y + -1.0));
} else if (y <= 2.7e+34) {
tmp = x * (1.0 - z);
} else {
tmp = y * (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 (y <= (-1.4d-9)) then
tmp = z * (x * (y + (-1.0d0)))
else if (y <= 2.7d+34) then
tmp = x * (1.0d0 - z)
else
tmp = y * (x * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.4e-9) {
tmp = z * (x * (y + -1.0));
} else if (y <= 2.7e+34) {
tmp = x * (1.0 - z);
} else {
tmp = y * (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.4e-9: tmp = z * (x * (y + -1.0)) elif y <= 2.7e+34: tmp = x * (1.0 - z) else: tmp = y * (x * z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.4e-9) tmp = Float64(z * Float64(x * Float64(y + -1.0))); elseif (y <= 2.7e+34) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(y * Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.4e-9) tmp = z * (x * (y + -1.0)); elseif (y <= 2.7e+34) tmp = x * (1.0 - z); else tmp = y * (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.4e-9], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.7e+34], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{-9}:\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{+34}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot z\right)\\
\end{array}
\end{array}
if y < -1.39999999999999992e-9Initial program 94.0%
Taylor expanded in z around inf 70.0%
if -1.39999999999999992e-9 < y < 2.7e34Initial program 100.0%
Taylor expanded in y around 0 95.3%
if 2.7e34 < y Initial program 86.8%
Taylor expanded in y around inf 82.7%
Final simplification86.3%
(FPCore (x y z) :precision binary64 (if (<= y -1.4e-9) (* z (- (* y x) x)) (if (<= y 5.6e+34) (* x (- 1.0 z)) (* y (* x z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.4e-9) {
tmp = z * ((y * x) - x);
} else if (y <= 5.6e+34) {
tmp = x * (1.0 - z);
} else {
tmp = y * (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 (y <= (-1.4d-9)) then
tmp = z * ((y * x) - x)
else if (y <= 5.6d+34) then
tmp = x * (1.0d0 - z)
else
tmp = y * (x * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.4e-9) {
tmp = z * ((y * x) - x);
} else if (y <= 5.6e+34) {
tmp = x * (1.0 - z);
} else {
tmp = y * (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.4e-9: tmp = z * ((y * x) - x) elif y <= 5.6e+34: tmp = x * (1.0 - z) else: tmp = y * (x * z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.4e-9) tmp = Float64(z * Float64(Float64(y * x) - x)); elseif (y <= 5.6e+34) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(y * Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.4e-9) tmp = z * ((y * x) - x); elseif (y <= 5.6e+34) tmp = x * (1.0 - z); else tmp = y * (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.4e-9], N[(z * N[(N[(y * x), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.6e+34], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{-9}:\\
\;\;\;\;z \cdot \left(y \cdot x - x\right)\\
\mathbf{elif}\;y \leq 5.6 \cdot 10^{+34}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot z\right)\\
\end{array}
\end{array}
if y < -1.39999999999999992e-9Initial program 94.0%
Taylor expanded in z around inf 70.0%
*-commutative70.0%
sub-neg70.0%
metadata-eval70.0%
distribute-rgt-in70.0%
neg-mul-170.0%
unsub-neg70.0%
Simplified70.0%
if -1.39999999999999992e-9 < y < 5.60000000000000016e34Initial program 100.0%
Taylor expanded in y around 0 95.3%
if 5.60000000000000016e34 < y Initial program 86.8%
Taylor expanded in y around inf 82.7%
Final simplification86.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 0.0045))) (* x (- z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 0.0045)) {
tmp = 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.0d0)) .or. (.not. (z <= 0.0045d0))) then
tmp = 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.0) || !(z <= 0.0045)) {
tmp = x * -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 0.0045): tmp = x * -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 0.0045)) tmp = Float64(x * Float64(-z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 0.0045))) tmp = x * -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 0.0045]], $MachinePrecision]], N[(x * (-z)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 0.0045\right):\\
\;\;\;\;x \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1 or 0.00449999999999999966 < z Initial program 91.8%
Taylor expanded in z around inf 98.6%
*-commutative98.6%
sub-neg98.6%
metadata-eval98.6%
distribute-rgt-in98.6%
neg-mul-198.6%
unsub-neg98.6%
Simplified98.6%
Taylor expanded in y around 0 53.0%
mul-1-neg53.0%
distribute-rgt-neg-out53.0%
Simplified53.0%
if -1 < z < 0.00449999999999999966Initial program 99.9%
Taylor expanded in z around 0 72.6%
Final simplification62.7%
(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.8%
Taylor expanded in z around 0 37.3%
Final simplification37.3%
(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 2023195
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"
:precision binary64
:herbie-target
(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))))