
(FPCore (x y z) :precision binary64 (+ (* x (+ y z)) (* z 5.0)))
double code(double x, double y, double z) {
return (x * (y + z)) + (z * 5.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 * (y + z)) + (z * 5.0d0)
end function
public static double code(double x, double y, double z) {
return (x * (y + z)) + (z * 5.0);
}
def code(x, y, z): return (x * (y + z)) + (z * 5.0)
function code(x, y, z) return Float64(Float64(x * Float64(y + z)) + Float64(z * 5.0)) end
function tmp = code(x, y, z) tmp = (x * (y + z)) + (z * 5.0); end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] + N[(z * 5.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(y + z\right) + z \cdot 5
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (* x (+ y z)) (* z 5.0)))
double code(double x, double y, double z) {
return (x * (y + z)) + (z * 5.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 * (y + z)) + (z * 5.0d0)
end function
public static double code(double x, double y, double z) {
return (x * (y + z)) + (z * 5.0);
}
def code(x, y, z): return (x * (y + z)) + (z * 5.0)
function code(x, y, z) return Float64(Float64(x * Float64(y + z)) + Float64(z * 5.0)) end
function tmp = code(x, y, z) tmp = (x * (y + z)) + (z * 5.0); end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] + N[(z * 5.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(y + z\right) + z \cdot 5
\end{array}
(FPCore (x y z) :precision binary64 (fma z 5.0 (* x (+ z y))))
double code(double x, double y, double z) {
return fma(z, 5.0, (x * (z + y)));
}
function code(x, y, z) return fma(z, 5.0, Float64(x * Float64(z + y))) end
code[x_, y_, z_] := N[(z * 5.0 + N[(x * N[(z + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, 5, x \cdot \left(z + y\right)\right)
\end{array}
Initial program 99.9%
+-commutative99.9%
fma-define100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(if (<= x -2.8e+218)
(* z x)
(if (<= x -1.05e+179)
(* x y)
(if (<= x -1.2e+136)
(* z x)
(if (<= x -6.6e+44)
(* x y)
(if (<= x -5.0)
(* z x)
(if (<= x -1.55e-42)
(* z 5.0)
(if (<= x -2e-64)
(* x y)
(if (<= x 1.6e-97)
(* z 5.0)
(if (or (<= x 6.8e+53) (not (<= x 2.5e+135)))
(* x y)
(* z x)))))))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.8e+218) {
tmp = z * x;
} else if (x <= -1.05e+179) {
tmp = x * y;
} else if (x <= -1.2e+136) {
tmp = z * x;
} else if (x <= -6.6e+44) {
tmp = x * y;
} else if (x <= -5.0) {
tmp = z * x;
} else if (x <= -1.55e-42) {
tmp = z * 5.0;
} else if (x <= -2e-64) {
tmp = x * y;
} else if (x <= 1.6e-97) {
tmp = z * 5.0;
} else if ((x <= 6.8e+53) || !(x <= 2.5e+135)) {
tmp = x * y;
} 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 (x <= (-2.8d+218)) then
tmp = z * x
else if (x <= (-1.05d+179)) then
tmp = x * y
else if (x <= (-1.2d+136)) then
tmp = z * x
else if (x <= (-6.6d+44)) then
tmp = x * y
else if (x <= (-5.0d0)) then
tmp = z * x
else if (x <= (-1.55d-42)) then
tmp = z * 5.0d0
else if (x <= (-2d-64)) then
tmp = x * y
else if (x <= 1.6d-97) then
tmp = z * 5.0d0
else if ((x <= 6.8d+53) .or. (.not. (x <= 2.5d+135))) then
tmp = x * y
else
tmp = z * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -2.8e+218) {
tmp = z * x;
} else if (x <= -1.05e+179) {
tmp = x * y;
} else if (x <= -1.2e+136) {
tmp = z * x;
} else if (x <= -6.6e+44) {
tmp = x * y;
} else if (x <= -5.0) {
tmp = z * x;
} else if (x <= -1.55e-42) {
tmp = z * 5.0;
} else if (x <= -2e-64) {
tmp = x * y;
} else if (x <= 1.6e-97) {
tmp = z * 5.0;
} else if ((x <= 6.8e+53) || !(x <= 2.5e+135)) {
tmp = x * y;
} else {
tmp = z * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.8e+218: tmp = z * x elif x <= -1.05e+179: tmp = x * y elif x <= -1.2e+136: tmp = z * x elif x <= -6.6e+44: tmp = x * y elif x <= -5.0: tmp = z * x elif x <= -1.55e-42: tmp = z * 5.0 elif x <= -2e-64: tmp = x * y elif x <= 1.6e-97: tmp = z * 5.0 elif (x <= 6.8e+53) or not (x <= 2.5e+135): tmp = x * y else: tmp = z * x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.8e+218) tmp = Float64(z * x); elseif (x <= -1.05e+179) tmp = Float64(x * y); elseif (x <= -1.2e+136) tmp = Float64(z * x); elseif (x <= -6.6e+44) tmp = Float64(x * y); elseif (x <= -5.0) tmp = Float64(z * x); elseif (x <= -1.55e-42) tmp = Float64(z * 5.0); elseif (x <= -2e-64) tmp = Float64(x * y); elseif (x <= 1.6e-97) tmp = Float64(z * 5.0); elseif ((x <= 6.8e+53) || !(x <= 2.5e+135)) tmp = Float64(x * y); else tmp = Float64(z * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -2.8e+218) tmp = z * x; elseif (x <= -1.05e+179) tmp = x * y; elseif (x <= -1.2e+136) tmp = z * x; elseif (x <= -6.6e+44) tmp = x * y; elseif (x <= -5.0) tmp = z * x; elseif (x <= -1.55e-42) tmp = z * 5.0; elseif (x <= -2e-64) tmp = x * y; elseif (x <= 1.6e-97) tmp = z * 5.0; elseif ((x <= 6.8e+53) || ~((x <= 2.5e+135))) tmp = x * y; else tmp = z * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2.8e+218], N[(z * x), $MachinePrecision], If[LessEqual[x, -1.05e+179], N[(x * y), $MachinePrecision], If[LessEqual[x, -1.2e+136], N[(z * x), $MachinePrecision], If[LessEqual[x, -6.6e+44], N[(x * y), $MachinePrecision], If[LessEqual[x, -5.0], N[(z * x), $MachinePrecision], If[LessEqual[x, -1.55e-42], N[(z * 5.0), $MachinePrecision], If[LessEqual[x, -2e-64], N[(x * y), $MachinePrecision], If[LessEqual[x, 1.6e-97], N[(z * 5.0), $MachinePrecision], If[Or[LessEqual[x, 6.8e+53], N[Not[LessEqual[x, 2.5e+135]], $MachinePrecision]], N[(x * y), $MachinePrecision], N[(z * x), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.8 \cdot 10^{+218}:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;x \leq -1.05 \cdot 10^{+179}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq -1.2 \cdot 10^{+136}:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;x \leq -6.6 \cdot 10^{+44}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq -5:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;x \leq -1.55 \cdot 10^{-42}:\\
\;\;\;\;z \cdot 5\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-64}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{-97}:\\
\;\;\;\;z \cdot 5\\
\mathbf{elif}\;x \leq 6.8 \cdot 10^{+53} \lor \neg \left(x \leq 2.5 \cdot 10^{+135}\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if x < -2.7999999999999998e218 or -1.0499999999999999e179 < x < -1.2e136 or -6.60000000000000027e44 < x < -5 or 6.79999999999999995e53 < x < 2.50000000000000015e135Initial program 99.9%
Taylor expanded in x around inf 97.1%
+-commutative97.1%
Simplified97.1%
Taylor expanded in z around inf 71.7%
if -2.7999999999999998e218 < x < -1.0499999999999999e179 or -1.2e136 < x < -6.60000000000000027e44 or -1.5500000000000001e-42 < x < -1.99999999999999993e-64 or 1.5999999999999999e-97 < x < 6.79999999999999995e53 or 2.50000000000000015e135 < x Initial program 99.9%
Taylor expanded in y around inf 67.4%
if -5 < x < -1.5500000000000001e-42 or -1.99999999999999993e-64 < x < 1.5999999999999999e-97Initial program 99.8%
Taylor expanded in x around 0 82.0%
Final simplification73.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (+ z y))))
(if (<= x -0.112)
t_0
(if (<= x -1.5e-40)
(* z 5.0)
(if (<= x -1.4e-64) (* x y) (if (<= x 1.6e-97) (* z 5.0) t_0))))))
double code(double x, double y, double z) {
double t_0 = x * (z + y);
double tmp;
if (x <= -0.112) {
tmp = t_0;
} else if (x <= -1.5e-40) {
tmp = z * 5.0;
} else if (x <= -1.4e-64) {
tmp = x * y;
} else if (x <= 1.6e-97) {
tmp = z * 5.0;
} 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 + y)
if (x <= (-0.112d0)) then
tmp = t_0
else if (x <= (-1.5d-40)) then
tmp = z * 5.0d0
else if (x <= (-1.4d-64)) then
tmp = x * y
else if (x <= 1.6d-97) then
tmp = z * 5.0d0
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 + y);
double tmp;
if (x <= -0.112) {
tmp = t_0;
} else if (x <= -1.5e-40) {
tmp = z * 5.0;
} else if (x <= -1.4e-64) {
tmp = x * y;
} else if (x <= 1.6e-97) {
tmp = z * 5.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (z + y) tmp = 0 if x <= -0.112: tmp = t_0 elif x <= -1.5e-40: tmp = z * 5.0 elif x <= -1.4e-64: tmp = x * y elif x <= 1.6e-97: tmp = z * 5.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(z + y)) tmp = 0.0 if (x <= -0.112) tmp = t_0; elseif (x <= -1.5e-40) tmp = Float64(z * 5.0); elseif (x <= -1.4e-64) tmp = Float64(x * y); elseif (x <= 1.6e-97) tmp = Float64(z * 5.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (z + y); tmp = 0.0; if (x <= -0.112) tmp = t_0; elseif (x <= -1.5e-40) tmp = z * 5.0; elseif (x <= -1.4e-64) tmp = x * y; elseif (x <= 1.6e-97) tmp = z * 5.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(z + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -0.112], t$95$0, If[LessEqual[x, -1.5e-40], N[(z * 5.0), $MachinePrecision], If[LessEqual[x, -1.4e-64], N[(x * y), $MachinePrecision], If[LessEqual[x, 1.6e-97], N[(z * 5.0), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(z + y\right)\\
\mathbf{if}\;x \leq -0.112:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -1.5 \cdot 10^{-40}:\\
\;\;\;\;z \cdot 5\\
\mathbf{elif}\;x \leq -1.4 \cdot 10^{-64}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{-97}:\\
\;\;\;\;z \cdot 5\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -0.112000000000000002 or 1.5999999999999999e-97 < x Initial program 99.9%
Taylor expanded in x around inf 94.1%
+-commutative94.1%
Simplified94.1%
if -0.112000000000000002 < x < -1.5000000000000001e-40 or -1.40000000000000002e-64 < x < 1.5999999999999999e-97Initial program 99.8%
Taylor expanded in x around 0 82.0%
if -1.5000000000000001e-40 < x < -1.40000000000000002e-64Initial program 100.0%
Taylor expanded in y around inf 100.0%
Final simplification89.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (+ z y))))
(if (<= x -33000000000.0)
t_0
(if (<= x -4.8e-44)
(* z (+ 5.0 x))
(if (<= x -1.55e-64) (* x y) (if (<= x 1.42e-97) (* z 5.0) t_0))))))
double code(double x, double y, double z) {
double t_0 = x * (z + y);
double tmp;
if (x <= -33000000000.0) {
tmp = t_0;
} else if (x <= -4.8e-44) {
tmp = z * (5.0 + x);
} else if (x <= -1.55e-64) {
tmp = x * y;
} else if (x <= 1.42e-97) {
tmp = z * 5.0;
} 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 + y)
if (x <= (-33000000000.0d0)) then
tmp = t_0
else if (x <= (-4.8d-44)) then
tmp = z * (5.0d0 + x)
else if (x <= (-1.55d-64)) then
tmp = x * y
else if (x <= 1.42d-97) then
tmp = z * 5.0d0
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 + y);
double tmp;
if (x <= -33000000000.0) {
tmp = t_0;
} else if (x <= -4.8e-44) {
tmp = z * (5.0 + x);
} else if (x <= -1.55e-64) {
tmp = x * y;
} else if (x <= 1.42e-97) {
tmp = z * 5.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (z + y) tmp = 0 if x <= -33000000000.0: tmp = t_0 elif x <= -4.8e-44: tmp = z * (5.0 + x) elif x <= -1.55e-64: tmp = x * y elif x <= 1.42e-97: tmp = z * 5.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(z + y)) tmp = 0.0 if (x <= -33000000000.0) tmp = t_0; elseif (x <= -4.8e-44) tmp = Float64(z * Float64(5.0 + x)); elseif (x <= -1.55e-64) tmp = Float64(x * y); elseif (x <= 1.42e-97) tmp = Float64(z * 5.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (z + y); tmp = 0.0; if (x <= -33000000000.0) tmp = t_0; elseif (x <= -4.8e-44) tmp = z * (5.0 + x); elseif (x <= -1.55e-64) tmp = x * y; elseif (x <= 1.42e-97) tmp = z * 5.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(z + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -33000000000.0], t$95$0, If[LessEqual[x, -4.8e-44], N[(z * N[(5.0 + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.55e-64], N[(x * y), $MachinePrecision], If[LessEqual[x, 1.42e-97], N[(z * 5.0), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(z + y\right)\\
\mathbf{if}\;x \leq -33000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -4.8 \cdot 10^{-44}:\\
\;\;\;\;z \cdot \left(5 + x\right)\\
\mathbf{elif}\;x \leq -1.55 \cdot 10^{-64}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq 1.42 \cdot 10^{-97}:\\
\;\;\;\;z \cdot 5\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -3.3e10 or 1.42000000000000009e-97 < x Initial program 99.9%
Taylor expanded in x around inf 95.0%
+-commutative95.0%
Simplified95.0%
if -3.3e10 < x < -4.80000000000000017e-44Initial program 99.6%
Taylor expanded in y around 0 86.9%
distribute-rgt-in87.1%
Simplified87.1%
if -4.80000000000000017e-44 < x < -1.55000000000000012e-64Initial program 100.0%
Taylor expanded in y around inf 100.0%
if -1.55000000000000012e-64 < x < 1.42000000000000009e-97Initial program 99.8%
Taylor expanded in x around 0 83.3%
Final simplification90.6%
(FPCore (x y z)
:precision binary64
(if (or (<= x -0.0075)
(not (or (<= x -1.7e-42) (and (not (<= x -1.8e-64)) (<= x 1.5e-97)))))
(* x y)
(* z 5.0)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -0.0075) || !((x <= -1.7e-42) || (!(x <= -1.8e-64) && (x <= 1.5e-97)))) {
tmp = x * y;
} else {
tmp = z * 5.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) :: tmp
if ((x <= (-0.0075d0)) .or. (.not. (x <= (-1.7d-42)) .or. (.not. (x <= (-1.8d-64))) .and. (x <= 1.5d-97))) then
tmp = x * y
else
tmp = z * 5.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -0.0075) || !((x <= -1.7e-42) || (!(x <= -1.8e-64) && (x <= 1.5e-97)))) {
tmp = x * y;
} else {
tmp = z * 5.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -0.0075) or not ((x <= -1.7e-42) or (not (x <= -1.8e-64) and (x <= 1.5e-97))): tmp = x * y else: tmp = z * 5.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -0.0075) || !((x <= -1.7e-42) || (!(x <= -1.8e-64) && (x <= 1.5e-97)))) tmp = Float64(x * y); else tmp = Float64(z * 5.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -0.0075) || ~(((x <= -1.7e-42) || (~((x <= -1.8e-64)) && (x <= 1.5e-97))))) tmp = x * y; else tmp = z * 5.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -0.0075], N[Not[Or[LessEqual[x, -1.7e-42], And[N[Not[LessEqual[x, -1.8e-64]], $MachinePrecision], LessEqual[x, 1.5e-97]]]], $MachinePrecision]], N[(x * y), $MachinePrecision], N[(z * 5.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0075 \lor \neg \left(x \leq -1.7 \cdot 10^{-42} \lor \neg \left(x \leq -1.8 \cdot 10^{-64}\right) \land x \leq 1.5 \cdot 10^{-97}\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;z \cdot 5\\
\end{array}
\end{array}
if x < -0.0074999999999999997 or -1.70000000000000011e-42 < x < -1.7999999999999999e-64 or 1.50000000000000012e-97 < x Initial program 99.9%
Taylor expanded in y around inf 55.0%
if -0.0074999999999999997 < x < -1.70000000000000011e-42 or -1.7999999999999999e-64 < x < 1.50000000000000012e-97Initial program 99.8%
Taylor expanded in x around 0 82.0%
Final simplification65.3%
(FPCore (x y z) :precision binary64 (if (or (<= x -5.0) (not (<= x 5.0))) (* x (+ z y)) (* y (+ x (* 5.0 (/ z y))))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.0) || !(x <= 5.0)) {
tmp = x * (z + y);
} else {
tmp = y * (x + (5.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 ((x <= (-5.0d0)) .or. (.not. (x <= 5.0d0))) then
tmp = x * (z + y)
else
tmp = y * (x + (5.0d0 * (z / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -5.0) || !(x <= 5.0)) {
tmp = x * (z + y);
} else {
tmp = y * (x + (5.0 * (z / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5.0) or not (x <= 5.0): tmp = x * (z + y) else: tmp = y * (x + (5.0 * (z / y))) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5.0) || !(x <= 5.0)) tmp = Float64(x * Float64(z + y)); else tmp = Float64(y * Float64(x + Float64(5.0 * Float64(z / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -5.0) || ~((x <= 5.0))) tmp = x * (z + y); else tmp = y * (x + (5.0 * (z / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5.0], N[Not[LessEqual[x, 5.0]], $MachinePrecision]], N[(x * N[(z + y), $MachinePrecision]), $MachinePrecision], N[(y * N[(x + N[(5.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \lor \neg \left(x \leq 5\right):\\
\;\;\;\;x \cdot \left(z + y\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x + 5 \cdot \frac{z}{y}\right)\\
\end{array}
\end{array}
if x < -5 or 5 < x Initial program 99.9%
Taylor expanded in x around inf 97.9%
+-commutative97.9%
Simplified97.9%
if -5 < x < 5Initial program 99.8%
+-commutative99.8%
fma-define100.0%
Applied egg-rr100.0%
Taylor expanded in y around inf 91.9%
associate-/l*91.7%
distribute-rgt-out92.1%
+-commutative92.1%
Simplified92.1%
Taylor expanded in x around 0 89.3%
Final simplification93.8%
(FPCore (x y z) :precision binary64 (+ (* x (+ z y)) (* z 5.0)))
double code(double x, double y, double z) {
return (x * (z + y)) + (z * 5.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 + y)) + (z * 5.0d0)
end function
public static double code(double x, double y, double z) {
return (x * (z + y)) + (z * 5.0);
}
def code(x, y, z): return (x * (z + y)) + (z * 5.0)
function code(x, y, z) return Float64(Float64(x * Float64(z + y)) + Float64(z * 5.0)) end
function tmp = code(x, y, z) tmp = (x * (z + y)) + (z * 5.0); end
code[x_, y_, z_] := N[(N[(x * N[(z + y), $MachinePrecision]), $MachinePrecision] + N[(z * 5.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(z + y\right) + z \cdot 5
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (* z 5.0))
double code(double x, double y, double z) {
return z * 5.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z * 5.0d0
end function
public static double code(double x, double y, double z) {
return z * 5.0;
}
def code(x, y, z): return z * 5.0
function code(x, y, z) return Float64(z * 5.0) end
function tmp = code(x, y, z) tmp = z * 5.0; end
code[x_, y_, z_] := N[(z * 5.0), $MachinePrecision]
\begin{array}{l}
\\
z \cdot 5
\end{array}
Initial program 99.9%
Taylor expanded in x around 0 34.9%
Final simplification34.9%
(FPCore (x y z) :precision binary64 (+ (* (+ x 5.0) z) (* x y)))
double code(double x, double y, double z) {
return ((x + 5.0) * z) + (x * 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 + 5.0d0) * z) + (x * y)
end function
public static double code(double x, double y, double z) {
return ((x + 5.0) * z) + (x * y);
}
def code(x, y, z): return ((x + 5.0) * z) + (x * y)
function code(x, y, z) return Float64(Float64(Float64(x + 5.0) * z) + Float64(x * y)) end
function tmp = code(x, y, z) tmp = ((x + 5.0) * z) + (x * y); end
code[x_, y_, z_] := N[(N[(N[(x + 5.0), $MachinePrecision] * z), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + 5\right) \cdot z + x \cdot y
\end{array}
herbie shell --seed 2024115
(FPCore (x y z)
:name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendOutside from plot-0.2.3.4, C"
:precision binary64
:alt
(+ (* (+ x 5.0) z) (* x y))
(+ (* x (+ y z)) (* z 5.0)))