
(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 11 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 (or (<= z -5200000.0) (not (<= z 0.0025))) (* z (* x (+ -1.0 y))) (* x (+ 1.0 (* z y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5200000.0) || !(z <= 0.0025)) {
tmp = z * (x * (-1.0 + y));
} else {
tmp = x * (1.0 + (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 <= (-5200000.0d0)) .or. (.not. (z <= 0.0025d0))) then
tmp = z * (x * ((-1.0d0) + y))
else
tmp = x * (1.0d0 + (z * y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -5200000.0) || !(z <= 0.0025)) {
tmp = z * (x * (-1.0 + y));
} else {
tmp = x * (1.0 + (z * y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5200000.0) or not (z <= 0.0025): tmp = z * (x * (-1.0 + y)) else: tmp = x * (1.0 + (z * y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5200000.0) || !(z <= 0.0025)) tmp = Float64(z * Float64(x * Float64(-1.0 + y))); else tmp = Float64(x * Float64(1.0 + Float64(z * y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -5200000.0) || ~((z <= 0.0025))) tmp = z * (x * (-1.0 + y)); else tmp = x * (1.0 + (z * y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5200000.0], N[Not[LessEqual[z, 0.0025]], $MachinePrecision]], N[(z * N[(x * N[(-1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5200000 \lor \neg \left(z \leq 0.0025\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(-1 + y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + z \cdot y\right)\\
\end{array}
\end{array}
if z < -5.2e6 or 0.00250000000000000005 < z Initial program 94.3%
Taylor expanded in z around inf 93.3%
*-commutative93.3%
associate-*r*98.9%
*-commutative98.9%
sub-neg98.9%
metadata-eval98.9%
Simplified98.9%
if -5.2e6 < z < 0.00250000000000000005Initial program 99.9%
Taylor expanded in z around 0 99.9%
Taylor expanded in y around inf 98.9%
*-commutative98.9%
Simplified98.9%
*-commutative98.9%
distribute-rgt1-in98.9%
Applied egg-rr98.9%
Final simplification98.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- x))) (t_1 (* x (* z y))))
(if (<= z -1.22e+232)
t_0
(if (<= z -2.1e+204)
t_1
(if (<= z -1.25e+184)
t_0
(if (<= z -5.6e+138)
t_1
(if (<= z -5200000.0)
t_0
(if (<= z 5.8e-61)
x
(if (or (<= z 11500.0) (not (<= z 7.1e+152))) t_1 t_0)))))))))
double code(double x, double y, double z) {
double t_0 = z * -x;
double t_1 = x * (z * y);
double tmp;
if (z <= -1.22e+232) {
tmp = t_0;
} else if (z <= -2.1e+204) {
tmp = t_1;
} else if (z <= -1.25e+184) {
tmp = t_0;
} else if (z <= -5.6e+138) {
tmp = t_1;
} else if (z <= -5200000.0) {
tmp = t_0;
} else if (z <= 5.8e-61) {
tmp = x;
} else if ((z <= 11500.0) || !(z <= 7.1e+152)) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = z * -x
t_1 = x * (z * y)
if (z <= (-1.22d+232)) then
tmp = t_0
else if (z <= (-2.1d+204)) then
tmp = t_1
else if (z <= (-1.25d+184)) then
tmp = t_0
else if (z <= (-5.6d+138)) then
tmp = t_1
else if (z <= (-5200000.0d0)) then
tmp = t_0
else if (z <= 5.8d-61) then
tmp = x
else if ((z <= 11500.0d0) .or. (.not. (z <= 7.1d+152))) then
tmp = t_1
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 t_1 = x * (z * y);
double tmp;
if (z <= -1.22e+232) {
tmp = t_0;
} else if (z <= -2.1e+204) {
tmp = t_1;
} else if (z <= -1.25e+184) {
tmp = t_0;
} else if (z <= -5.6e+138) {
tmp = t_1;
} else if (z <= -5200000.0) {
tmp = t_0;
} else if (z <= 5.8e-61) {
tmp = x;
} else if ((z <= 11500.0) || !(z <= 7.1e+152)) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * -x t_1 = x * (z * y) tmp = 0 if z <= -1.22e+232: tmp = t_0 elif z <= -2.1e+204: tmp = t_1 elif z <= -1.25e+184: tmp = t_0 elif z <= -5.6e+138: tmp = t_1 elif z <= -5200000.0: tmp = t_0 elif z <= 5.8e-61: tmp = x elif (z <= 11500.0) or not (z <= 7.1e+152): tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-x)) t_1 = Float64(x * Float64(z * y)) tmp = 0.0 if (z <= -1.22e+232) tmp = t_0; elseif (z <= -2.1e+204) tmp = t_1; elseif (z <= -1.25e+184) tmp = t_0; elseif (z <= -5.6e+138) tmp = t_1; elseif (z <= -5200000.0) tmp = t_0; elseif (z <= 5.8e-61) tmp = x; elseif ((z <= 11500.0) || !(z <= 7.1e+152)) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * -x; t_1 = x * (z * y); tmp = 0.0; if (z <= -1.22e+232) tmp = t_0; elseif (z <= -2.1e+204) tmp = t_1; elseif (z <= -1.25e+184) tmp = t_0; elseif (z <= -5.6e+138) tmp = t_1; elseif (z <= -5200000.0) tmp = t_0; elseif (z <= 5.8e-61) tmp = x; elseif ((z <= 11500.0) || ~((z <= 7.1e+152))) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * (-x)), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.22e+232], t$95$0, If[LessEqual[z, -2.1e+204], t$95$1, If[LessEqual[z, -1.25e+184], t$95$0, If[LessEqual[z, -5.6e+138], t$95$1, If[LessEqual[z, -5200000.0], t$95$0, If[LessEqual[z, 5.8e-61], x, If[Or[LessEqual[z, 11500.0], N[Not[LessEqual[z, 7.1e+152]], $MachinePrecision]], t$95$1, t$95$0]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(-x\right)\\
t_1 := x \cdot \left(z \cdot y\right)\\
\mathbf{if}\;z \leq -1.22 \cdot 10^{+232}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -2.1 \cdot 10^{+204}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -1.25 \cdot 10^{+184}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -5.6 \cdot 10^{+138}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -5200000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 5.8 \cdot 10^{-61}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 11500 \lor \neg \left(z \leq 7.1 \cdot 10^{+152}\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -1.21999999999999994e232 or -2.1e204 < z < -1.25e184 or -5.6000000000000002e138 < z < -5.2e6 or 11500 < z < 7.10000000000000017e152Initial program 95.5%
Taylor expanded in z around inf 93.9%
Taylor expanded in y around 0 76.9%
mul-1-neg76.9%
distribute-lft-neg-out76.9%
*-commutative76.9%
Simplified76.9%
if -1.21999999999999994e232 < z < -2.1e204 or -1.25e184 < z < -5.6000000000000002e138 or 5.7999999999999999e-61 < z < 11500 or 7.10000000000000017e152 < z Initial program 93.2%
Taylor expanded in y around inf 77.5%
*-commutative77.5%
Simplified77.5%
if -5.2e6 < z < 5.7999999999999999e-61Initial program 99.9%
Taylor expanded in z around 0 73.9%
Final simplification75.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.3e-15) (not (<= z 5.8e-61))) (* z (* x (+ -1.0 y))) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.3e-15) || !(z <= 5.8e-61)) {
tmp = z * (x * (-1.0 + y));
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.3d-15)) .or. (.not. (z <= 5.8d-61))) then
tmp = z * (x * ((-1.0d0) + y))
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.3e-15) || !(z <= 5.8e-61)) {
tmp = z * (x * (-1.0 + y));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.3e-15) or not (z <= 5.8e-61): tmp = z * (x * (-1.0 + y)) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.3e-15) || !(z <= 5.8e-61)) tmp = Float64(z * Float64(x * Float64(-1.0 + y))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.3e-15) || ~((z <= 5.8e-61))) tmp = z * (x * (-1.0 + y)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.3e-15], N[Not[LessEqual[z, 5.8e-61]], $MachinePrecision]], N[(z * N[(x * N[(-1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.3 \cdot 10^{-15} \lor \neg \left(z \leq 5.8 \cdot 10^{-61}\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(-1 + y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.30000000000000002e-15 or 5.7999999999999999e-61 < z Initial program 94.8%
Taylor expanded in z around inf 91.9%
*-commutative91.9%
associate-*r*96.4%
*-commutative96.4%
sub-neg96.4%
metadata-eval96.4%
Simplified96.4%
if -1.30000000000000002e-15 < z < 5.7999999999999999e-61Initial program 99.9%
Taylor expanded in z around 0 76.9%
Final simplification88.0%
(FPCore (x y z) :precision binary64 (if (<= y -8.8e+140) (* z (* x y)) (if (<= y 1.6e-8) (* x (- 1.0 z)) (* x (* z (+ -1.0 y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -8.8e+140) {
tmp = z * (x * y);
} else if (y <= 1.6e-8) {
tmp = x * (1.0 - z);
} else {
tmp = x * (z * (-1.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 (y <= (-8.8d+140)) then
tmp = z * (x * y)
else if (y <= 1.6d-8) then
tmp = x * (1.0d0 - z)
else
tmp = x * (z * ((-1.0d0) + y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -8.8e+140) {
tmp = z * (x * y);
} else if (y <= 1.6e-8) {
tmp = x * (1.0 - z);
} else {
tmp = x * (z * (-1.0 + y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -8.8e+140: tmp = z * (x * y) elif y <= 1.6e-8: tmp = x * (1.0 - z) else: tmp = x * (z * (-1.0 + y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -8.8e+140) tmp = Float64(z * Float64(x * y)); elseif (y <= 1.6e-8) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(x * Float64(z * Float64(-1.0 + y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -8.8e+140) tmp = z * (x * y); elseif (y <= 1.6e-8) tmp = x * (1.0 - z); else tmp = x * (z * (-1.0 + y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -8.8e+140], N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.6e-8], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(x * N[(z * N[(-1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.8 \cdot 10^{+140}:\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\mathbf{elif}\;y \leq 1.6 \cdot 10^{-8}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(z \cdot \left(-1 + y\right)\right)\\
\end{array}
\end{array}
if y < -8.7999999999999993e140Initial program 93.2%
Taylor expanded in y around inf 88.0%
associate-*r*91.5%
*-commutative91.5%
Simplified91.5%
if -8.7999999999999993e140 < y < 1.6000000000000001e-8Initial program 99.4%
Taylor expanded in y around 0 93.5%
if 1.6000000000000001e-8 < y Initial program 92.9%
Taylor expanded in z around inf 72.9%
Final simplification87.9%
(FPCore (x y z) :precision binary64 (if (<= y -1.8e+139) (* z (* x y)) (if (<= y 1.6e-8) (* x (- 1.0 z)) (* (* x z) (+ -1.0 y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.8e+139) {
tmp = z * (x * y);
} else if (y <= 1.6e-8) {
tmp = x * (1.0 - z);
} else {
tmp = (x * z) * (-1.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 (y <= (-1.8d+139)) then
tmp = z * (x * y)
else if (y <= 1.6d-8) then
tmp = x * (1.0d0 - z)
else
tmp = (x * z) * ((-1.0d0) + y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.8e+139) {
tmp = z * (x * y);
} else if (y <= 1.6e-8) {
tmp = x * (1.0 - z);
} else {
tmp = (x * z) * (-1.0 + y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.8e+139: tmp = z * (x * y) elif y <= 1.6e-8: tmp = x * (1.0 - z) else: tmp = (x * z) * (-1.0 + y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.8e+139) tmp = Float64(z * Float64(x * y)); elseif (y <= 1.6e-8) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(Float64(x * z) * Float64(-1.0 + y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.8e+139) tmp = z * (x * y); elseif (y <= 1.6e-8) tmp = x * (1.0 - z); else tmp = (x * z) * (-1.0 + y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.8e+139], N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.6e-8], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(N[(x * z), $MachinePrecision] * N[(-1.0 + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.8 \cdot 10^{+139}:\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\mathbf{elif}\;y \leq 1.6 \cdot 10^{-8}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot z\right) \cdot \left(-1 + y\right)\\
\end{array}
\end{array}
if y < -1.79999999999999993e139Initial program 93.2%
Taylor expanded in y around inf 88.0%
associate-*r*91.5%
*-commutative91.5%
Simplified91.5%
if -1.79999999999999993e139 < y < 1.6000000000000001e-8Initial program 99.4%
Taylor expanded in y around 0 93.5%
if 1.6000000000000001e-8 < y Initial program 92.9%
Taylor expanded in z around inf 72.9%
Taylor expanded in y around 0 56.5%
associate-*r*56.5%
*-commutative56.5%
associate-*l*60.7%
distribute-rgt-in77.1%
Simplified77.1%
Final simplification89.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -5e+139) (not (<= y 420.0))) (* x (* z y)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5e+139) || !(y <= 420.0)) {
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 <= (-5d+139)) .or. (.not. (y <= 420.0d0))) 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 <= -5e+139) || !(y <= 420.0)) {
tmp = x * (z * y);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5e+139) or not (y <= 420.0): tmp = x * (z * y) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5e+139) || !(y <= 420.0)) 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 <= -5e+139) || ~((y <= 420.0))) tmp = x * (z * y); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5e+139], N[Not[LessEqual[y, 420.0]], $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 -5 \cdot 10^{+139} \lor \neg \left(y \leq 420\right):\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -5.0000000000000003e139 or 420 < y Initial program 92.9%
Taylor expanded in y around inf 76.7%
*-commutative76.7%
Simplified76.7%
if -5.0000000000000003e139 < y < 420Initial program 99.4%
Taylor expanded in y around 0 93.3%
Final simplification87.2%
(FPCore (x y z) :precision binary64 (if (<= y -2.2e+139) (* z (* x y)) (if (<= y 92000.0) (* x (- 1.0 z)) (* x (* z y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.2e+139) {
tmp = z * (x * y);
} else if (y <= 92000.0) {
tmp = x * (1.0 - z);
} else {
tmp = 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 (y <= (-2.2d+139)) then
tmp = z * (x * y)
else if (y <= 92000.0d0) then
tmp = x * (1.0d0 - z)
else
tmp = x * (z * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.2e+139) {
tmp = z * (x * y);
} else if (y <= 92000.0) {
tmp = x * (1.0 - z);
} else {
tmp = x * (z * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.2e+139: tmp = z * (x * y) elif y <= 92000.0: tmp = x * (1.0 - z) else: tmp = x * (z * y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.2e+139) tmp = Float64(z * Float64(x * y)); elseif (y <= 92000.0) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(x * Float64(z * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.2e+139) tmp = z * (x * y); elseif (y <= 92000.0) tmp = x * (1.0 - z); else tmp = x * (z * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.2e+139], N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 92000.0], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.2 \cdot 10^{+139}:\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\mathbf{elif}\;y \leq 92000:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if y < -2.1999999999999999e139Initial program 93.2%
Taylor expanded in y around inf 88.0%
associate-*r*91.5%
*-commutative91.5%
Simplified91.5%
if -2.1999999999999999e139 < y < 92000Initial program 99.4%
Taylor expanded in y around 0 93.3%
if 92000 < y Initial program 92.8%
Taylor expanded in y around inf 71.9%
*-commutative71.9%
Simplified71.9%
Final simplification87.6%
(FPCore (x y z) :precision binary64 (- x (* (* x z) (- 1.0 y))))
double code(double x, double y, double z) {
return x - ((x * z) * (1.0 - y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x - ((x * z) * (1.0d0 - y))
end function
public static double code(double x, double y, double z) {
return x - ((x * z) * (1.0 - y));
}
def code(x, y, z): return x - ((x * z) * (1.0 - y))
function code(x, y, z) return Float64(x - Float64(Float64(x * z) * Float64(1.0 - y))) end
function tmp = code(x, y, z) tmp = x - ((x * z) * (1.0 - y)); end
code[x_, y_, z_] := N[(x - N[(N[(x * z), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(x \cdot z\right) \cdot \left(1 - y\right)
\end{array}
Initial program 97.0%
Taylor expanded in z around 0 97.0%
Taylor expanded in y around 0 92.3%
associate-*r*58.6%
*-commutative58.6%
associate-*l*55.8%
distribute-rgt-in63.3%
Simplified97.4%
Final simplification97.4%
(FPCore (x y z) :precision binary64 (* x (+ 1.0 (* z (+ -1.0 y)))))
double code(double x, double y, double z) {
return x * (1.0 + (z * (-1.0 + y)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * (1.0d0 + (z * ((-1.0d0) + y)))
end function
public static double code(double x, double y, double z) {
return x * (1.0 + (z * (-1.0 + y)));
}
def code(x, y, z): return x * (1.0 + (z * (-1.0 + y)))
function code(x, y, z) return Float64(x * Float64(1.0 + Float64(z * Float64(-1.0 + y)))) end
function tmp = code(x, y, z) tmp = x * (1.0 + (z * (-1.0 + y))); end
code[x_, y_, z_] := N[(x * N[(1.0 + N[(z * N[(-1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 + z \cdot \left(-1 + y\right)\right)
\end{array}
Initial program 97.0%
Final simplification97.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -5200000.0) (not (<= z 0.0025))) (* z (- x)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5200000.0) || !(z <= 0.0025)) {
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 <= (-5200000.0d0)) .or. (.not. (z <= 0.0025d0))) 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 <= -5200000.0) || !(z <= 0.0025)) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5200000.0) or not (z <= 0.0025): tmp = z * -x else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5200000.0) || !(z <= 0.0025)) tmp = Float64(z * Float64(-x)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -5200000.0) || ~((z <= 0.0025))) tmp = z * -x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5200000.0], N[Not[LessEqual[z, 0.0025]], $MachinePrecision]], N[(z * (-x)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5200000 \lor \neg \left(z \leq 0.0025\right):\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -5.2e6 or 0.00250000000000000005 < z Initial program 94.3%
Taylor expanded in z around inf 93.3%
Taylor expanded in y around 0 61.9%
mul-1-neg61.9%
distribute-lft-neg-out61.9%
*-commutative61.9%
Simplified61.9%
if -5.2e6 < z < 0.00250000000000000005Initial program 99.9%
Taylor expanded in z around 0 71.0%
Final simplification66.3%
(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 97.0%
Taylor expanded in z around 0 35.9%
Final simplification35.9%
(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 2023308
(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))))