
(FPCore (x y z) :precision binary64 (+ (* x y) (* (- 1.0 x) z)))
double code(double x, double y, double z) {
return (x * y) + ((1.0 - x) * z);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * y) + ((1.0d0 - x) * z)
end function
public static double code(double x, double y, double z) {
return (x * y) + ((1.0 - x) * z);
}
def code(x, y, z): return (x * y) + ((1.0 - x) * z)
function code(x, y, z) return Float64(Float64(x * y) + Float64(Float64(1.0 - x) * z)) end
function tmp = code(x, y, z) tmp = (x * y) + ((1.0 - x) * z); end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot y + \left(1 - x\right) \cdot z
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (* x y) (* (- 1.0 x) z)))
double code(double x, double y, double z) {
return (x * y) + ((1.0 - x) * z);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * y) + ((1.0d0 - x) * z)
end function
public static double code(double x, double y, double z) {
return (x * y) + ((1.0 - x) * z);
}
def code(x, y, z): return (x * y) + ((1.0 - x) * z)
function code(x, y, z) return Float64(Float64(x * y) + Float64(Float64(1.0 - x) * z)) end
function tmp = code(x, y, z) tmp = (x * y) + ((1.0 - x) * z); end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot y + \left(1 - x\right) \cdot z
\end{array}
(FPCore (x y z) :precision binary64 (fma x (- y z) z))
double code(double x, double y, double z) {
return fma(x, (y - z), z);
}
function code(x, y, z) return fma(x, Float64(y - z), z) end
code[x_, y_, z_] := N[(x * N[(y - z), $MachinePrecision] + z), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, y - z, z\right)
\end{array}
Initial program 98.0%
*-commutative98.0%
distribute-lft-out--98.0%
*-rgt-identity98.0%
cancel-sign-sub-inv98.0%
+-commutative98.0%
associate-+r+98.0%
+-commutative98.0%
*-commutative98.0%
distribute-rgt-out100.0%
fma-define100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- z))))
(if (<= x -2.6e+231)
(* x y)
(if (<= x -1.05e+40)
t_0
(if (<= x -3e-109)
(* x y)
(if (<= x 6.2e-34)
z
(if (or (<= x 1.65e+41)
(not
(or (<= x 1.95e+76)
(and (not (<= x 7.5e+140))
(or (<= x 1.3e+215)
(and (not (<= x 1.2e+278))
(<= x 2.5e+297)))))))
(* x y)
t_0)))))))
double code(double x, double y, double z) {
double t_0 = x * -z;
double tmp;
if (x <= -2.6e+231) {
tmp = x * y;
} else if (x <= -1.05e+40) {
tmp = t_0;
} else if (x <= -3e-109) {
tmp = x * y;
} else if (x <= 6.2e-34) {
tmp = z;
} else if ((x <= 1.65e+41) || !((x <= 1.95e+76) || (!(x <= 7.5e+140) && ((x <= 1.3e+215) || (!(x <= 1.2e+278) && (x <= 2.5e+297)))))) {
tmp = x * y;
} 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 = x * -z
if (x <= (-2.6d+231)) then
tmp = x * y
else if (x <= (-1.05d+40)) then
tmp = t_0
else if (x <= (-3d-109)) then
tmp = x * y
else if (x <= 6.2d-34) then
tmp = z
else if ((x <= 1.65d+41) .or. (.not. (x <= 1.95d+76) .or. (.not. (x <= 7.5d+140)) .and. (x <= 1.3d+215) .or. (.not. (x <= 1.2d+278)) .and. (x <= 2.5d+297))) then
tmp = x * y
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * -z;
double tmp;
if (x <= -2.6e+231) {
tmp = x * y;
} else if (x <= -1.05e+40) {
tmp = t_0;
} else if (x <= -3e-109) {
tmp = x * y;
} else if (x <= 6.2e-34) {
tmp = z;
} else if ((x <= 1.65e+41) || !((x <= 1.95e+76) || (!(x <= 7.5e+140) && ((x <= 1.3e+215) || (!(x <= 1.2e+278) && (x <= 2.5e+297)))))) {
tmp = x * y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * -z tmp = 0 if x <= -2.6e+231: tmp = x * y elif x <= -1.05e+40: tmp = t_0 elif x <= -3e-109: tmp = x * y elif x <= 6.2e-34: tmp = z elif (x <= 1.65e+41) or not ((x <= 1.95e+76) or (not (x <= 7.5e+140) and ((x <= 1.3e+215) or (not (x <= 1.2e+278) and (x <= 2.5e+297))))): tmp = x * y else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(-z)) tmp = 0.0 if (x <= -2.6e+231) tmp = Float64(x * y); elseif (x <= -1.05e+40) tmp = t_0; elseif (x <= -3e-109) tmp = Float64(x * y); elseif (x <= 6.2e-34) tmp = z; elseif ((x <= 1.65e+41) || !((x <= 1.95e+76) || (!(x <= 7.5e+140) && ((x <= 1.3e+215) || (!(x <= 1.2e+278) && (x <= 2.5e+297)))))) tmp = Float64(x * y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * -z; tmp = 0.0; if (x <= -2.6e+231) tmp = x * y; elseif (x <= -1.05e+40) tmp = t_0; elseif (x <= -3e-109) tmp = x * y; elseif (x <= 6.2e-34) tmp = z; elseif ((x <= 1.65e+41) || ~(((x <= 1.95e+76) || (~((x <= 7.5e+140)) && ((x <= 1.3e+215) || (~((x <= 1.2e+278)) && (x <= 2.5e+297))))))) tmp = x * y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * (-z)), $MachinePrecision]}, If[LessEqual[x, -2.6e+231], N[(x * y), $MachinePrecision], If[LessEqual[x, -1.05e+40], t$95$0, If[LessEqual[x, -3e-109], N[(x * y), $MachinePrecision], If[LessEqual[x, 6.2e-34], z, If[Or[LessEqual[x, 1.65e+41], N[Not[Or[LessEqual[x, 1.95e+76], And[N[Not[LessEqual[x, 7.5e+140]], $MachinePrecision], Or[LessEqual[x, 1.3e+215], And[N[Not[LessEqual[x, 1.2e+278]], $MachinePrecision], LessEqual[x, 2.5e+297]]]]]], $MachinePrecision]], N[(x * y), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(-z\right)\\
\mathbf{if}\;x \leq -2.6 \cdot 10^{+231}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq -1.05 \cdot 10^{+40}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -3 \cdot 10^{-109}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq 6.2 \cdot 10^{-34}:\\
\;\;\;\;z\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{+41} \lor \neg \left(x \leq 1.95 \cdot 10^{+76} \lor \neg \left(x \leq 7.5 \cdot 10^{+140}\right) \land \left(x \leq 1.3 \cdot 10^{+215} \lor \neg \left(x \leq 1.2 \cdot 10^{+278}\right) \land x \leq 2.5 \cdot 10^{+297}\right)\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -2.5999999999999999e231 or -1.05000000000000005e40 < x < -3.00000000000000021e-109 or 6.1999999999999996e-34 < x < 1.65e41 or 1.94999999999999995e76 < x < 7.4999999999999997e140 or 1.3e215 < x < 1.19999999999999992e278 or 2.4999999999999999e297 < x Initial program 95.6%
Taylor expanded in y around inf 69.2%
if -2.5999999999999999e231 < x < -1.05000000000000005e40 or 1.65e41 < x < 1.94999999999999995e76 or 7.4999999999999997e140 < x < 1.3e215 or 1.19999999999999992e278 < x < 2.4999999999999999e297Initial program 98.7%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 69.1%
associate-*r*69.1%
mul-1-neg69.1%
Simplified69.1%
if -3.00000000000000021e-109 < x < 6.1999999999999996e-34Initial program 100.0%
Taylor expanded in x around 0 78.0%
Final simplification72.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- z))))
(if (<= x -5.2e+230)
(* x y)
(if (<= x -1.1e+40)
t_0
(if (<= x -3e-109)
(* x y)
(if (<= x 7.2e-41)
z
(if (<= x 7.2e+36)
(* x (+ y z))
(if (or (<= x 8.8e+76)
(and (not (<= x 3.1e+140))
(or (<= x 1.5e+218)
(and (not (<= x 3.2e+281)) (<= x 3.8e+297)))))
t_0
(* x y)))))))))
double code(double x, double y, double z) {
double t_0 = x * -z;
double tmp;
if (x <= -5.2e+230) {
tmp = x * y;
} else if (x <= -1.1e+40) {
tmp = t_0;
} else if (x <= -3e-109) {
tmp = x * y;
} else if (x <= 7.2e-41) {
tmp = z;
} else if (x <= 7.2e+36) {
tmp = x * (y + z);
} else if ((x <= 8.8e+76) || (!(x <= 3.1e+140) && ((x <= 1.5e+218) || (!(x <= 3.2e+281) && (x <= 3.8e+297))))) {
tmp = t_0;
} else {
tmp = x * 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) :: t_0
real(8) :: tmp
t_0 = x * -z
if (x <= (-5.2d+230)) then
tmp = x * y
else if (x <= (-1.1d+40)) then
tmp = t_0
else if (x <= (-3d-109)) then
tmp = x * y
else if (x <= 7.2d-41) then
tmp = z
else if (x <= 7.2d+36) then
tmp = x * (y + z)
else if ((x <= 8.8d+76) .or. (.not. (x <= 3.1d+140)) .and. (x <= 1.5d+218) .or. (.not. (x <= 3.2d+281)) .and. (x <= 3.8d+297)) then
tmp = t_0
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * -z;
double tmp;
if (x <= -5.2e+230) {
tmp = x * y;
} else if (x <= -1.1e+40) {
tmp = t_0;
} else if (x <= -3e-109) {
tmp = x * y;
} else if (x <= 7.2e-41) {
tmp = z;
} else if (x <= 7.2e+36) {
tmp = x * (y + z);
} else if ((x <= 8.8e+76) || (!(x <= 3.1e+140) && ((x <= 1.5e+218) || (!(x <= 3.2e+281) && (x <= 3.8e+297))))) {
tmp = t_0;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z): t_0 = x * -z tmp = 0 if x <= -5.2e+230: tmp = x * y elif x <= -1.1e+40: tmp = t_0 elif x <= -3e-109: tmp = x * y elif x <= 7.2e-41: tmp = z elif x <= 7.2e+36: tmp = x * (y + z) elif (x <= 8.8e+76) or (not (x <= 3.1e+140) and ((x <= 1.5e+218) or (not (x <= 3.2e+281) and (x <= 3.8e+297)))): tmp = t_0 else: tmp = x * y return tmp
function code(x, y, z) t_0 = Float64(x * Float64(-z)) tmp = 0.0 if (x <= -5.2e+230) tmp = Float64(x * y); elseif (x <= -1.1e+40) tmp = t_0; elseif (x <= -3e-109) tmp = Float64(x * y); elseif (x <= 7.2e-41) tmp = z; elseif (x <= 7.2e+36) tmp = Float64(x * Float64(y + z)); elseif ((x <= 8.8e+76) || (!(x <= 3.1e+140) && ((x <= 1.5e+218) || (!(x <= 3.2e+281) && (x <= 3.8e+297))))) tmp = t_0; else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * -z; tmp = 0.0; if (x <= -5.2e+230) tmp = x * y; elseif (x <= -1.1e+40) tmp = t_0; elseif (x <= -3e-109) tmp = x * y; elseif (x <= 7.2e-41) tmp = z; elseif (x <= 7.2e+36) tmp = x * (y + z); elseif ((x <= 8.8e+76) || (~((x <= 3.1e+140)) && ((x <= 1.5e+218) || (~((x <= 3.2e+281)) && (x <= 3.8e+297))))) tmp = t_0; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * (-z)), $MachinePrecision]}, If[LessEqual[x, -5.2e+230], N[(x * y), $MachinePrecision], If[LessEqual[x, -1.1e+40], t$95$0, If[LessEqual[x, -3e-109], N[(x * y), $MachinePrecision], If[LessEqual[x, 7.2e-41], z, If[LessEqual[x, 7.2e+36], N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, 8.8e+76], And[N[Not[LessEqual[x, 3.1e+140]], $MachinePrecision], Or[LessEqual[x, 1.5e+218], And[N[Not[LessEqual[x, 3.2e+281]], $MachinePrecision], LessEqual[x, 3.8e+297]]]]], t$95$0, N[(x * y), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(-z\right)\\
\mathbf{if}\;x \leq -5.2 \cdot 10^{+230}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq -1.1 \cdot 10^{+40}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -3 \cdot 10^{-109}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{-41}:\\
\;\;\;\;z\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{+36}:\\
\;\;\;\;x \cdot \left(y + z\right)\\
\mathbf{elif}\;x \leq 8.8 \cdot 10^{+76} \lor \neg \left(x \leq 3.1 \cdot 10^{+140}\right) \land \left(x \leq 1.5 \cdot 10^{+218} \lor \neg \left(x \leq 3.2 \cdot 10^{+281}\right) \land x \leq 3.8 \cdot 10^{+297}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if x < -5.1999999999999997e230 or -1.0999999999999999e40 < x < -3.00000000000000021e-109 or 8.8000000000000002e76 < x < 3.1e140 or 1.5e218 < x < 3.2000000000000001e281 or 3.7999999999999999e297 < x Initial program 94.3%
Taylor expanded in y around inf 72.9%
if -5.1999999999999997e230 < x < -1.0999999999999999e40 or 7.1999999999999995e36 < x < 8.8000000000000002e76 or 3.1e140 < x < 1.5e218 or 3.2000000000000001e281 < x < 3.7999999999999999e297Initial program 98.7%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 69.1%
associate-*r*69.1%
mul-1-neg69.1%
Simplified69.1%
if -3.00000000000000021e-109 < x < 7.2e-41Initial program 100.0%
Taylor expanded in x around 0 78.0%
if 7.2e-41 < x < 7.1999999999999995e36Initial program 99.9%
Taylor expanded in x around inf 66.1%
mul-1-neg66.1%
sub-neg66.1%
Simplified66.1%
sub-neg66.1%
distribute-rgt-in66.1%
*-commutative66.1%
add-sqr-sqrt66.1%
sqrt-unprod66.1%
sqr-neg66.1%
sqrt-unprod0.0%
add-sqr-sqrt57.6%
cancel-sign-sub-inv57.6%
*-commutative57.6%
cancel-sign-sub57.6%
Applied egg-rr57.6%
+-commutative57.6%
distribute-lft-out57.6%
Simplified57.6%
Final simplification72.1%
(FPCore (x y z) :precision binary64 (if (or (<= x -3.25e-112) (not (<= x 8.5e-33))) (* x (- y z)) z))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.25e-112) || !(x <= 8.5e-33)) {
tmp = x * (y - z);
} else {
tmp = 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 ((x <= (-3.25d-112)) .or. (.not. (x <= 8.5d-33))) then
tmp = x * (y - z)
else
tmp = z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -3.25e-112) || !(x <= 8.5e-33)) {
tmp = x * (y - z);
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3.25e-112) or not (x <= 8.5e-33): tmp = x * (y - z) else: tmp = z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3.25e-112) || !(x <= 8.5e-33)) tmp = Float64(x * Float64(y - z)); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -3.25e-112) || ~((x <= 8.5e-33))) tmp = x * (y - z); else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.25e-112], N[Not[LessEqual[x, 8.5e-33]], $MachinePrecision]], N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision], z]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.25 \cdot 10^{-112} \lor \neg \left(x \leq 8.5 \cdot 10^{-33}\right):\\
\;\;\;\;x \cdot \left(y - z\right)\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if x < -3.24999999999999978e-112 or 8.49999999999999945e-33 < x Initial program 97.1%
Taylor expanded in x around inf 91.2%
mul-1-neg91.2%
sub-neg91.2%
Simplified91.2%
if -3.24999999999999978e-112 < x < 8.49999999999999945e-33Initial program 100.0%
Taylor expanded in x around 0 78.0%
Final simplification87.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -3e-109) (not (<= x 280.0))) (* x (- y z)) (* z (- 1.0 x))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3e-109) || !(x <= 280.0)) {
tmp = x * (y - z);
} else {
tmp = z * (1.0 - 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 ((x <= (-3d-109)) .or. (.not. (x <= 280.0d0))) then
tmp = x * (y - z)
else
tmp = z * (1.0d0 - x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -3e-109) || !(x <= 280.0)) {
tmp = x * (y - z);
} else {
tmp = z * (1.0 - x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3e-109) or not (x <= 280.0): tmp = x * (y - z) else: tmp = z * (1.0 - x) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3e-109) || !(x <= 280.0)) tmp = Float64(x * Float64(y - z)); else tmp = Float64(z * Float64(1.0 - x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -3e-109) || ~((x <= 280.0))) tmp = x * (y - z); else tmp = z * (1.0 - x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3e-109], N[Not[LessEqual[x, 280.0]], $MachinePrecision]], N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision], N[(z * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3 \cdot 10^{-109} \lor \neg \left(x \leq 280\right):\\
\;\;\;\;x \cdot \left(y - z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(1 - x\right)\\
\end{array}
\end{array}
if x < -3.00000000000000021e-109 or 280 < x Initial program 96.9%
Taylor expanded in x around inf 94.9%
mul-1-neg94.9%
sub-neg94.9%
Simplified94.9%
if -3.00000000000000021e-109 < x < 280Initial program 100.0%
Taylor expanded in y around 0 74.4%
Final simplification87.4%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (* x (- y z)) (+ z (* x y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = x * (y - z);
} else {
tmp = z + (x * 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 ((x <= (-1.0d0)) .or. (.not. (x <= 1.0d0))) then
tmp = x * (y - z)
else
tmp = z + (x * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = x * (y - z);
} else {
tmp = z + (x * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = x * (y - z) else: tmp = z + (x * y) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(x * Float64(y - z)); else tmp = Float64(z + Float64(x * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.0))) tmp = x * (y - z); else tmp = z + (x * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision], N[(z + N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;x \cdot \left(y - z\right)\\
\mathbf{else}:\\
\;\;\;\;z + x \cdot y\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 96.4%
Taylor expanded in x around inf 99.1%
mul-1-neg99.1%
sub-neg99.1%
Simplified99.1%
if -1 < x < 1Initial program 99.9%
+-commutative99.9%
remove-double-neg99.9%
distribute-rgt-neg-out99.9%
neg-sub099.9%
neg-sub099.9%
*-commutative99.9%
distribute-lft-neg-in99.9%
remove-double-neg99.9%
distribute-rgt-out--100.0%
*-lft-identity100.0%
associate-+l-100.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in z around 0 98.1%
mul-1-neg98.1%
distribute-rgt-neg-out98.1%
Simplified98.1%
sub-neg98.1%
+-commutative98.1%
distribute-rgt-neg-out98.1%
remove-double-neg98.1%
Applied egg-rr98.1%
Final simplification98.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -3e-109) (not (<= x 2.75e-33))) (* x y) z))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3e-109) || !(x <= 2.75e-33)) {
tmp = x * y;
} else {
tmp = 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 ((x <= (-3d-109)) .or. (.not. (x <= 2.75d-33))) then
tmp = x * y
else
tmp = z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -3e-109) || !(x <= 2.75e-33)) {
tmp = x * y;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3e-109) or not (x <= 2.75e-33): tmp = x * y else: tmp = z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3e-109) || !(x <= 2.75e-33)) tmp = Float64(x * y); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -3e-109) || ~((x <= 2.75e-33))) tmp = x * y; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3e-109], N[Not[LessEqual[x, 2.75e-33]], $MachinePrecision]], N[(x * y), $MachinePrecision], z]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3 \cdot 10^{-109} \lor \neg \left(x \leq 2.75 \cdot 10^{-33}\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if x < -3.00000000000000021e-109 or 2.75e-33 < x Initial program 97.1%
Taylor expanded in y around inf 51.9%
if -3.00000000000000021e-109 < x < 2.75e-33Initial program 100.0%
Taylor expanded in x around 0 78.0%
Final simplification60.3%
(FPCore (x y z) :precision binary64 (+ z (* x (- y z))))
double code(double x, double y, double z) {
return z + (x * (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 = z + (x * (y - z))
end function
public static double code(double x, double y, double z) {
return z + (x * (y - z));
}
def code(x, y, z): return z + (x * (y - z))
function code(x, y, z) return Float64(z + Float64(x * Float64(y - z))) end
function tmp = code(x, y, z) tmp = z + (x * (y - z)); end
code[x_, y_, z_] := N[(z + N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z + x \cdot \left(y - z\right)
\end{array}
Initial program 98.0%
+-commutative98.0%
remove-double-neg98.0%
distribute-rgt-neg-out98.0%
neg-sub098.0%
neg-sub098.0%
*-commutative98.0%
distribute-lft-neg-in98.0%
remove-double-neg98.0%
distribute-rgt-out--98.0%
*-lft-identity98.0%
associate-+l-98.0%
distribute-lft-out--100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 z)
double code(double x, double y, double z) {
return z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z
end function
public static double code(double x, double y, double z) {
return z;
}
def code(x, y, z): return z
function code(x, y, z) return z end
function tmp = code(x, y, z) tmp = z; end
code[x_, y_, z_] := z
\begin{array}{l}
\\
z
\end{array}
Initial program 98.0%
Taylor expanded in x around 0 30.9%
Final simplification30.9%
herbie shell --seed 2024059
(FPCore (x y z)
:name "Diagrams.Backend.Rasterific:$crender from diagrams-rasterific-1.3.1.3"
:precision binary64
(+ (* x y) (* (- 1.0 x) z)))