
(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 9 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 (let* ((t_0 (* x (+ 1.0 (* z (+ y -1.0)))))) (if (<= t_0 1e+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 <= 1e+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 <= 1d+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 <= 1e+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 <= 1e+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 <= 1e+304) tmp = t_0; else tmp = Float64(Float64(z * 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 <= 1e+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, 1e+304], t$95$0, N[(N[(z * x), $MachinePrecision] * N[(y + -1.0), $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 10^{+304}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y + -1\right)\\
\end{array}
\end{array}
if (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z))) < 9.9999999999999994e303Initial program 98.6%
if 9.9999999999999994e303 < (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z))) Initial program 80.2%
Taylor expanded in z around inf 80.2%
associate-*r*99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification98.8%
(FPCore (x y z)
:precision binary64
(if (or (<= y -4.5e+149)
(and (not (<= y -7e+89)) (or (<= y -1.05e+43) (not (<= y 1.2e+69)))))
(* x (* z y))
(* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.5e+149) || (!(y <= -7e+89) && ((y <= -1.05e+43) || !(y <= 1.2e+69)))) {
tmp = x * (z * y);
} 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 <= (-4.5d+149)) .or. (.not. (y <= (-7d+89))) .and. (y <= (-1.05d+43)) .or. (.not. (y <= 1.2d+69))) then
tmp = x * (z * y)
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 <= -4.5e+149) || (!(y <= -7e+89) && ((y <= -1.05e+43) || !(y <= 1.2e+69)))) {
tmp = x * (z * y);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4.5e+149) or (not (y <= -7e+89) and ((y <= -1.05e+43) or not (y <= 1.2e+69))): tmp = x * (z * y) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4.5e+149) || (!(y <= -7e+89) && ((y <= -1.05e+43) || !(y <= 1.2e+69)))) tmp = Float64(x * Float64(z * y)); else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -4.5e+149) || (~((y <= -7e+89)) && ((y <= -1.05e+43) || ~((y <= 1.2e+69))))) tmp = x * (z * y); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4.5e+149], And[N[Not[LessEqual[y, -7e+89]], $MachinePrecision], Or[LessEqual[y, -1.05e+43], N[Not[LessEqual[y, 1.2e+69]], $MachinePrecision]]]], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.5 \cdot 10^{+149} \lor \neg \left(y \leq -7 \cdot 10^{+89}\right) \land \left(y \leq -1.05 \cdot 10^{+43} \lor \neg \left(y \leq 1.2 \cdot 10^{+69}\right)\right):\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -4.49999999999999982e149 or -7.0000000000000001e89 < y < -1.05000000000000001e43 or 1.2000000000000001e69 < y Initial program 92.1%
Taylor expanded in y around inf 81.3%
*-commutative81.3%
Simplified81.3%
if -4.49999999999999982e149 < y < -7.0000000000000001e89 or -1.05000000000000001e43 < y < 1.2000000000000001e69Initial program 99.3%
Taylor expanded in y around 0 93.1%
Final simplification88.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (* z y))))
(if (<= y -6.2e+149)
t_0
(if (<= y -8e+88)
(* x (- 1.0 z))
(if (or (<= y -2.15e+43) (not (<= y 3.5e+67))) t_0 (- x (* z x)))))))
double code(double x, double y, double z) {
double t_0 = x * (z * y);
double tmp;
if (y <= -6.2e+149) {
tmp = t_0;
} else if (y <= -8e+88) {
tmp = x * (1.0 - z);
} else if ((y <= -2.15e+43) || !(y <= 3.5e+67)) {
tmp = t_0;
} else {
tmp = x - (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) :: t_0
real(8) :: tmp
t_0 = x * (z * y)
if (y <= (-6.2d+149)) then
tmp = t_0
else if (y <= (-8d+88)) then
tmp = x * (1.0d0 - z)
else if ((y <= (-2.15d+43)) .or. (.not. (y <= 3.5d+67))) then
tmp = t_0
else
tmp = x - (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (z * y);
double tmp;
if (y <= -6.2e+149) {
tmp = t_0;
} else if (y <= -8e+88) {
tmp = x * (1.0 - z);
} else if ((y <= -2.15e+43) || !(y <= 3.5e+67)) {
tmp = t_0;
} else {
tmp = x - (z * x);
}
return tmp;
}
def code(x, y, z): t_0 = x * (z * y) tmp = 0 if y <= -6.2e+149: tmp = t_0 elif y <= -8e+88: tmp = x * (1.0 - z) elif (y <= -2.15e+43) or not (y <= 3.5e+67): tmp = t_0 else: tmp = x - (z * x) return tmp
function code(x, y, z) t_0 = Float64(x * Float64(z * y)) tmp = 0.0 if (y <= -6.2e+149) tmp = t_0; elseif (y <= -8e+88) tmp = Float64(x * Float64(1.0 - z)); elseif ((y <= -2.15e+43) || !(y <= 3.5e+67)) tmp = t_0; else tmp = Float64(x - Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (z * y); tmp = 0.0; if (y <= -6.2e+149) tmp = t_0; elseif (y <= -8e+88) tmp = x * (1.0 - z); elseif ((y <= -2.15e+43) || ~((y <= 3.5e+67))) tmp = t_0; else tmp = x - (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -6.2e+149], t$95$0, If[LessEqual[y, -8e+88], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, -2.15e+43], N[Not[LessEqual[y, 3.5e+67]], $MachinePrecision]], t$95$0, N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(z \cdot y\right)\\
\mathbf{if}\;y \leq -6.2 \cdot 10^{+149}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -8 \cdot 10^{+88}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{elif}\;y \leq -2.15 \cdot 10^{+43} \lor \neg \left(y \leq 3.5 \cdot 10^{+67}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot x\\
\end{array}
\end{array}
if y < -6.19999999999999974e149 or -7.99999999999999968e88 < y < -2.15e43 or 3.5e67 < y Initial program 92.1%
Taylor expanded in y around inf 81.3%
*-commutative81.3%
Simplified81.3%
if -6.19999999999999974e149 < y < -7.99999999999999968e88Initial program 90.5%
Taylor expanded in y around 0 80.7%
if -2.15e43 < y < 3.5e67Initial program 99.9%
Taylor expanded in y around 0 94.0%
sub-neg94.0%
distribute-rgt-in94.0%
*-lft-identity94.0%
distribute-lft-neg-in94.0%
*-commutative94.0%
unsub-neg94.0%
*-commutative94.0%
Applied egg-rr94.0%
Final simplification88.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.95e-13) (not (<= z 23500.0))) (* (* z x) (+ y -1.0)) (- x (* z x))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.95e-13) || !(z <= 23500.0)) {
tmp = (z * x) * (y + -1.0);
} else {
tmp = x - (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 <= (-1.95d-13)) .or. (.not. (z <= 23500.0d0))) then
tmp = (z * x) * (y + (-1.0d0))
else
tmp = x - (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.95e-13) || !(z <= 23500.0)) {
tmp = (z * x) * (y + -1.0);
} else {
tmp = x - (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.95e-13) or not (z <= 23500.0): tmp = (z * x) * (y + -1.0) else: tmp = x - (z * x) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.95e-13) || !(z <= 23500.0)) tmp = Float64(Float64(z * x) * Float64(y + -1.0)); else tmp = Float64(x - Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.95e-13) || ~((z <= 23500.0))) tmp = (z * x) * (y + -1.0); else tmp = x - (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.95e-13], N[Not[LessEqual[z, 23500.0]], $MachinePrecision]], N[(N[(z * x), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.95 \cdot 10^{-13} \lor \neg \left(z \leq 23500\right):\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y + -1\right)\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot x\\
\end{array}
\end{array}
if z < -1.95000000000000002e-13 or 23500 < z Initial program 93.5%
Taylor expanded in z around inf 92.1%
associate-*r*98.5%
sub-neg98.5%
metadata-eval98.5%
Simplified98.5%
if -1.95000000000000002e-13 < z < 23500Initial program 99.9%
Taylor expanded in y around 0 76.5%
sub-neg76.5%
distribute-rgt-in76.5%
*-lft-identity76.5%
distribute-lft-neg-in76.5%
*-commutative76.5%
unsub-neg76.5%
*-commutative76.5%
Applied egg-rr76.5%
Final simplification87.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -4.6e+20) (not (<= z 1.0))) (* (* z x) (+ y -1.0)) (+ x (* x (* z y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.6e+20) || !(z <= 1.0)) {
tmp = (z * x) * (y + -1.0);
} else {
tmp = x + (x * (z * 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 <= (-4.6d+20)) .or. (.not. (z <= 1.0d0))) then
tmp = (z * x) * (y + (-1.0d0))
else
tmp = x + (x * (z * y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -4.6e+20) || !(z <= 1.0)) {
tmp = (z * x) * (y + -1.0);
} else {
tmp = x + (x * (z * y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4.6e+20) or not (z <= 1.0): tmp = (z * x) * (y + -1.0) else: tmp = x + (x * (z * y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4.6e+20) || !(z <= 1.0)) tmp = Float64(Float64(z * x) * Float64(y + -1.0)); else tmp = Float64(x + Float64(x * Float64(z * y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -4.6e+20) || ~((z <= 1.0))) tmp = (z * x) * (y + -1.0); else tmp = x + (x * (z * y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.6e+20], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(N[(z * x), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision], N[(x + N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.6 \cdot 10^{+20} \lor \neg \left(z \leq 1\right):\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y + -1\right)\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if z < -4.6e20 or 1 < z Initial program 93.2%
Taylor expanded in z around inf 92.2%
associate-*r*98.9%
sub-neg98.9%
metadata-eval98.9%
Simplified98.9%
if -4.6e20 < z < 1Initial program 99.9%
sub-neg99.9%
+-commutative99.9%
distribute-rgt-in99.9%
distribute-lft-neg-in99.9%
*-commutative99.9%
associate-*l*91.4%
sub-neg91.4%
distribute-neg-in91.4%
metadata-eval91.4%
+-commutative91.4%
remove-double-neg91.4%
*-lft-identity91.4%
Applied egg-rr91.4%
Taylor expanded in y around inf 98.0%
*-commutative98.0%
Simplified98.0%
Final simplification98.4%
(FPCore (x y z) :precision binary64 (+ x (/ (* z x) (/ 1.0 (+ y -1.0)))))
double code(double x, double y, double z) {
return x + ((z * x) / (1.0 / (y + -1.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 * x) / (1.0d0 / (y + (-1.0d0))))
end function
public static double code(double x, double y, double z) {
return x + ((z * x) / (1.0 / (y + -1.0)));
}
def code(x, y, z): return x + ((z * x) / (1.0 / (y + -1.0)))
function code(x, y, z) return Float64(x + Float64(Float64(z * x) / Float64(1.0 / Float64(y + -1.0)))) end
function tmp = code(x, y, z) tmp = x + ((z * x) / (1.0 / (y + -1.0))); end
code[x_, y_, z_] := N[(x + N[(N[(z * x), $MachinePrecision] / N[(1.0 / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{z \cdot x}{\frac{1}{y + -1}}
\end{array}
Initial program 96.6%
sub-neg96.6%
+-commutative96.6%
distribute-rgt-in96.6%
distribute-lft-neg-in96.6%
*-commutative96.6%
associate-*l*95.5%
sub-neg95.5%
distribute-neg-in95.5%
metadata-eval95.5%
+-commutative95.5%
remove-double-neg95.5%
*-lft-identity95.5%
Applied egg-rr95.5%
associate-*r*96.6%
*-commutative96.6%
associate-*l*97.6%
flip-+85.7%
clear-num85.7%
un-div-inv85.7%
*-commutative85.7%
clear-num85.7%
flip-+97.6%
Applied egg-rr97.6%
Final simplification97.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -9000000.0) (not (<= z 1.0))) (* z (- x)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -9000000.0) || !(z <= 1.0)) {
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 <= (-9000000.0d0)) .or. (.not. (z <= 1.0d0))) 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 <= -9000000.0) || !(z <= 1.0)) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -9000000.0) or not (z <= 1.0): tmp = z * -x else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -9000000.0) || !(z <= 1.0)) tmp = Float64(z * Float64(-x)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -9000000.0) || ~((z <= 1.0))) tmp = z * -x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -9000000.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(z * (-x)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9000000 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -9e6 or 1 < z Initial program 93.3%
Taylor expanded in z around inf 92.3%
*-commutative92.3%
sub-neg92.3%
metadata-eval92.3%
*-commutative92.3%
distribute-rgt-in92.4%
neg-mul-192.4%
unsub-neg92.4%
*-commutative92.4%
Simplified92.4%
Taylor expanded in y around 0 59.5%
mul-1-neg59.5%
Simplified59.5%
if -9e6 < z < 1Initial program 99.9%
Taylor expanded in z around 0 72.8%
Final simplification66.2%
(FPCore (x y z) :precision binary64 (if (<= z -8.2e-13) (* x (* z y)) (if (<= z 1.0) x (* z (- x)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -8.2e-13) {
tmp = x * (z * y);
} else if (z <= 1.0) {
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 <= (-8.2d-13)) then
tmp = x * (z * y)
else if (z <= 1.0d0) 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 <= -8.2e-13) {
tmp = x * (z * y);
} else if (z <= 1.0) {
tmp = x;
} else {
tmp = z * -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -8.2e-13: tmp = x * (z * y) elif z <= 1.0: tmp = x else: tmp = z * -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -8.2e-13) tmp = Float64(x * Float64(z * y)); elseif (z <= 1.0) tmp = x; else tmp = Float64(z * Float64(-x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -8.2e-13) tmp = x * (z * y); elseif (z <= 1.0) tmp = x; else tmp = z * -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -8.2e-13], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.0], x, N[(z * (-x)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.2 \cdot 10^{-13}:\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(-x\right)\\
\end{array}
\end{array}
if z < -8.2000000000000004e-13Initial program 91.6%
Taylor expanded in y around inf 51.9%
*-commutative51.9%
Simplified51.9%
if -8.2000000000000004e-13 < z < 1Initial program 99.9%
Taylor expanded in z around 0 74.8%
if 1 < z Initial program 95.6%
Taylor expanded in z around inf 93.6%
*-commutative93.6%
sub-neg93.6%
metadata-eval93.6%
*-commutative93.6%
distribute-rgt-in93.6%
neg-mul-193.6%
unsub-neg93.6%
*-commutative93.6%
Simplified93.6%
Taylor expanded in y around 0 68.5%
mul-1-neg68.5%
Simplified68.5%
Final simplification67.1%
(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 96.6%
Taylor expanded in z around 0 37.8%
Final simplification37.8%
(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 2023297
(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))))