
(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 10 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-def100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (+ z y))) (t_1 (* z (+ 5.0 x))))
(if (<= x -10500000.0)
t_0
(if (<= x -4.15e-51)
t_1
(if (<= x -1.15e-84) (* x y) (if (<= x 3.6e-35) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = x * (z + y);
double t_1 = z * (5.0 + x);
double tmp;
if (x <= -10500000.0) {
tmp = t_0;
} else if (x <= -4.15e-51) {
tmp = t_1;
} else if (x <= -1.15e-84) {
tmp = x * y;
} else if (x <= 3.6e-35) {
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 = x * (z + y)
t_1 = z * (5.0d0 + x)
if (x <= (-10500000.0d0)) then
tmp = t_0
else if (x <= (-4.15d-51)) then
tmp = t_1
else if (x <= (-1.15d-84)) then
tmp = x * y
else if (x <= 3.6d-35) 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 = x * (z + y);
double t_1 = z * (5.0 + x);
double tmp;
if (x <= -10500000.0) {
tmp = t_0;
} else if (x <= -4.15e-51) {
tmp = t_1;
} else if (x <= -1.15e-84) {
tmp = x * y;
} else if (x <= 3.6e-35) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (z + y) t_1 = z * (5.0 + x) tmp = 0 if x <= -10500000.0: tmp = t_0 elif x <= -4.15e-51: tmp = t_1 elif x <= -1.15e-84: tmp = x * y elif x <= 3.6e-35: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(z + y)) t_1 = Float64(z * Float64(5.0 + x)) tmp = 0.0 if (x <= -10500000.0) tmp = t_0; elseif (x <= -4.15e-51) tmp = t_1; elseif (x <= -1.15e-84) tmp = Float64(x * y); elseif (x <= 3.6e-35) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (z + y); t_1 = z * (5.0 + x); tmp = 0.0; if (x <= -10500000.0) tmp = t_0; elseif (x <= -4.15e-51) tmp = t_1; elseif (x <= -1.15e-84) tmp = x * y; elseif (x <= 3.6e-35) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(z + y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[(5.0 + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -10500000.0], t$95$0, If[LessEqual[x, -4.15e-51], t$95$1, If[LessEqual[x, -1.15e-84], N[(x * y), $MachinePrecision], If[LessEqual[x, 3.6e-35], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(z + y\right)\\
t_1 := z \cdot \left(5 + x\right)\\
\mathbf{if}\;x \leq -10500000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -4.15 \cdot 10^{-51}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -1.15 \cdot 10^{-84}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq 3.6 \cdot 10^{-35}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1.05e7 or 3.60000000000000019e-35 < x Initial program 100.0%
Taylor expanded in x around inf 99.4%
+-commutative99.4%
Simplified99.4%
if -1.05e7 < x < -4.14999999999999988e-51 or -1.1499999999999999e-84 < x < 3.60000000000000019e-35Initial program 99.8%
Taylor expanded in y around 0 72.8%
+-commutative72.8%
*-commutative72.8%
distribute-rgt-in72.8%
Simplified72.8%
if -4.14999999999999988e-51 < x < -1.1499999999999999e-84Initial program 100.0%
Taylor expanded in y around inf 100.0%
Final simplification85.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (+ 5.0 x))))
(if (<= x -10500000.0)
(+ (* z x) (* x y))
(if (<= x -5.6e-53)
t_0
(if (<= x -2.5e-81) (* x y) (if (<= x 1.95e-32) t_0 (* x (+ z y))))))))
double code(double x, double y, double z) {
double t_0 = z * (5.0 + x);
double tmp;
if (x <= -10500000.0) {
tmp = (z * x) + (x * y);
} else if (x <= -5.6e-53) {
tmp = t_0;
} else if (x <= -2.5e-81) {
tmp = x * y;
} else if (x <= 1.95e-32) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = z * (5.0d0 + x)
if (x <= (-10500000.0d0)) then
tmp = (z * x) + (x * y)
else if (x <= (-5.6d-53)) then
tmp = t_0
else if (x <= (-2.5d-81)) then
tmp = x * y
else if (x <= 1.95d-32) then
tmp = t_0
else
tmp = x * (z + y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * (5.0 + x);
double tmp;
if (x <= -10500000.0) {
tmp = (z * x) + (x * y);
} else if (x <= -5.6e-53) {
tmp = t_0;
} else if (x <= -2.5e-81) {
tmp = x * y;
} else if (x <= 1.95e-32) {
tmp = t_0;
} else {
tmp = x * (z + y);
}
return tmp;
}
def code(x, y, z): t_0 = z * (5.0 + x) tmp = 0 if x <= -10500000.0: tmp = (z * x) + (x * y) elif x <= -5.6e-53: tmp = t_0 elif x <= -2.5e-81: tmp = x * y elif x <= 1.95e-32: tmp = t_0 else: tmp = x * (z + y) return tmp
function code(x, y, z) t_0 = Float64(z * Float64(5.0 + x)) tmp = 0.0 if (x <= -10500000.0) tmp = Float64(Float64(z * x) + Float64(x * y)); elseif (x <= -5.6e-53) tmp = t_0; elseif (x <= -2.5e-81) tmp = Float64(x * y); elseif (x <= 1.95e-32) tmp = t_0; else tmp = Float64(x * Float64(z + y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (5.0 + x); tmp = 0.0; if (x <= -10500000.0) tmp = (z * x) + (x * y); elseif (x <= -5.6e-53) tmp = t_0; elseif (x <= -2.5e-81) tmp = x * y; elseif (x <= 1.95e-32) tmp = t_0; else tmp = x * (z + y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(5.0 + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -10500000.0], N[(N[(z * x), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -5.6e-53], t$95$0, If[LessEqual[x, -2.5e-81], N[(x * y), $MachinePrecision], If[LessEqual[x, 1.95e-32], t$95$0, N[(x * N[(z + y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(5 + x\right)\\
\mathbf{if}\;x \leq -10500000:\\
\;\;\;\;z \cdot x + x \cdot y\\
\mathbf{elif}\;x \leq -5.6 \cdot 10^{-53}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -2.5 \cdot 10^{-81}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq 1.95 \cdot 10^{-32}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(z + y\right)\\
\end{array}
\end{array}
if x < -1.05e7Initial program 99.9%
Taylor expanded in x around inf 99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in z around 0 100.0%
if -1.05e7 < x < -5.59999999999999971e-53 or -2.4999999999999999e-81 < x < 1.9500000000000001e-32Initial program 99.8%
Taylor expanded in y around 0 72.8%
+-commutative72.8%
*-commutative72.8%
distribute-rgt-in72.8%
Simplified72.8%
if -5.59999999999999971e-53 < x < -2.4999999999999999e-81Initial program 100.0%
Taylor expanded in y around inf 100.0%
if 1.9500000000000001e-32 < x Initial program 100.0%
Taylor expanded in x around inf 98.8%
+-commutative98.8%
Simplified98.8%
Final simplification85.5%
(FPCore (x y z)
:precision binary64
(if (<= x -10500000.0)
(+ (* z x) (* x y))
(if (<= x -1.56e-52)
(+ (* z 5.0) (* z x))
(if (<= x -5e-90)
(* x y)
(if (<= x 6.1e-33) (* z (+ 5.0 x)) (* x (+ z y)))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -10500000.0) {
tmp = (z * x) + (x * y);
} else if (x <= -1.56e-52) {
tmp = (z * 5.0) + (z * x);
} else if (x <= -5e-90) {
tmp = x * y;
} else if (x <= 6.1e-33) {
tmp = z * (5.0 + x);
} 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 (x <= (-10500000.0d0)) then
tmp = (z * x) + (x * y)
else if (x <= (-1.56d-52)) then
tmp = (z * 5.0d0) + (z * x)
else if (x <= (-5d-90)) then
tmp = x * y
else if (x <= 6.1d-33) then
tmp = z * (5.0d0 + x)
else
tmp = x * (z + y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -10500000.0) {
tmp = (z * x) + (x * y);
} else if (x <= -1.56e-52) {
tmp = (z * 5.0) + (z * x);
} else if (x <= -5e-90) {
tmp = x * y;
} else if (x <= 6.1e-33) {
tmp = z * (5.0 + x);
} else {
tmp = x * (z + y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -10500000.0: tmp = (z * x) + (x * y) elif x <= -1.56e-52: tmp = (z * 5.0) + (z * x) elif x <= -5e-90: tmp = x * y elif x <= 6.1e-33: tmp = z * (5.0 + x) else: tmp = x * (z + y) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -10500000.0) tmp = Float64(Float64(z * x) + Float64(x * y)); elseif (x <= -1.56e-52) tmp = Float64(Float64(z * 5.0) + Float64(z * x)); elseif (x <= -5e-90) tmp = Float64(x * y); elseif (x <= 6.1e-33) tmp = Float64(z * Float64(5.0 + x)); else tmp = Float64(x * Float64(z + y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -10500000.0) tmp = (z * x) + (x * y); elseif (x <= -1.56e-52) tmp = (z * 5.0) + (z * x); elseif (x <= -5e-90) tmp = x * y; elseif (x <= 6.1e-33) tmp = z * (5.0 + x); else tmp = x * (z + y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -10500000.0], N[(N[(z * x), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.56e-52], N[(N[(z * 5.0), $MachinePrecision] + N[(z * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -5e-90], N[(x * y), $MachinePrecision], If[LessEqual[x, 6.1e-33], N[(z * N[(5.0 + x), $MachinePrecision]), $MachinePrecision], N[(x * N[(z + y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10500000:\\
\;\;\;\;z \cdot x + x \cdot y\\
\mathbf{elif}\;x \leq -1.56 \cdot 10^{-52}:\\
\;\;\;\;z \cdot 5 + z \cdot x\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-90}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq 6.1 \cdot 10^{-33}:\\
\;\;\;\;z \cdot \left(5 + x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(z + y\right)\\
\end{array}
\end{array}
if x < -1.05e7Initial program 99.9%
Taylor expanded in x around inf 99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in z around 0 100.0%
if -1.05e7 < x < -1.5600000000000001e-52Initial program 99.8%
Taylor expanded in y around 0 67.3%
if -1.5600000000000001e-52 < x < -5.00000000000000019e-90Initial program 100.0%
Taylor expanded in y around inf 100.0%
if -5.00000000000000019e-90 < x < 6.1000000000000001e-33Initial program 99.8%
Taylor expanded in y around 0 73.5%
+-commutative73.5%
*-commutative73.5%
distribute-rgt-in73.5%
Simplified73.5%
if 6.1000000000000001e-33 < x Initial program 100.0%
Taylor expanded in x around inf 98.8%
+-commutative98.8%
Simplified98.8%
Final simplification85.5%
(FPCore (x y z) :precision binary64 (if (<= x -5.0) (+ (* z x) (* x y)) (if (<= x 1.75e-28) (- (* x y) (* z -5.0)) (* x (+ z y)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -5.0) {
tmp = (z * x) + (x * y);
} else if (x <= 1.75e-28) {
tmp = (x * y) - (z * -5.0);
} 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 (x <= (-5.0d0)) then
tmp = (z * x) + (x * y)
else if (x <= 1.75d-28) then
tmp = (x * y) - (z * (-5.0d0))
else
tmp = x * (z + y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -5.0) {
tmp = (z * x) + (x * y);
} else if (x <= 1.75e-28) {
tmp = (x * y) - (z * -5.0);
} else {
tmp = x * (z + y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -5.0: tmp = (z * x) + (x * y) elif x <= 1.75e-28: tmp = (x * y) - (z * -5.0) else: tmp = x * (z + y) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -5.0) tmp = Float64(Float64(z * x) + Float64(x * y)); elseif (x <= 1.75e-28) tmp = Float64(Float64(x * y) - Float64(z * -5.0)); else tmp = Float64(x * Float64(z + y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -5.0) tmp = (z * x) + (x * y); elseif (x <= 1.75e-28) tmp = (x * y) - (z * -5.0); else tmp = x * (z + y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -5.0], N[(N[(z * x), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.75e-28], N[(N[(x * y), $MachinePrecision] - N[(z * -5.0), $MachinePrecision]), $MachinePrecision], N[(x * N[(z + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5:\\
\;\;\;\;z \cdot x + x \cdot y\\
\mathbf{elif}\;x \leq 1.75 \cdot 10^{-28}:\\
\;\;\;\;x \cdot y - z \cdot -5\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(z + y\right)\\
\end{array}
\end{array}
if x < -5Initial program 99.9%
Taylor expanded in x around inf 98.1%
+-commutative98.1%
Simplified98.1%
Taylor expanded in z around 0 98.2%
if -5 < x < 1.75e-28Initial program 99.8%
+-commutative99.8%
fma-def100.0%
Applied egg-rr100.0%
Taylor expanded in z around -inf 99.8%
+-commutative99.8%
fma-def99.8%
mul-1-neg99.8%
fma-neg99.8%
sub-neg99.8%
+-commutative99.8%
mul-1-neg99.8%
unsub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around 0 99.0%
*-commutative99.0%
Simplified99.0%
if 1.75e-28 < x Initial program 100.0%
Taylor expanded in x around inf 98.8%
+-commutative98.8%
Simplified98.8%
Final simplification98.7%
(FPCore (x y z) :precision binary64 (if (<= y -1.9e+115) (* x y) (if (<= y 5.6e+54) (* z (+ 5.0 x)) (* x y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.9e+115) {
tmp = x * y;
} else if (y <= 5.6e+54) {
tmp = z * (5.0 + x);
} 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) :: tmp
if (y <= (-1.9d+115)) then
tmp = x * y
else if (y <= 5.6d+54) then
tmp = z * (5.0d0 + x)
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.9e+115) {
tmp = x * y;
} else if (y <= 5.6e+54) {
tmp = z * (5.0 + x);
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.9e+115: tmp = x * y elif y <= 5.6e+54: tmp = z * (5.0 + x) else: tmp = x * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.9e+115) tmp = Float64(x * y); elseif (y <= 5.6e+54) tmp = Float64(z * Float64(5.0 + x)); else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.9e+115) tmp = x * y; elseif (y <= 5.6e+54) tmp = z * (5.0 + x); else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.9e+115], N[(x * y), $MachinePrecision], If[LessEqual[y, 5.6e+54], N[(z * N[(5.0 + x), $MachinePrecision]), $MachinePrecision], N[(x * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.9 \cdot 10^{+115}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;y \leq 5.6 \cdot 10^{+54}:\\
\;\;\;\;z \cdot \left(5 + x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if y < -1.9e115 or 5.6000000000000003e54 < y Initial program 99.9%
Taylor expanded in y around inf 76.1%
if -1.9e115 < y < 5.6000000000000003e54Initial program 99.9%
Taylor expanded in y around 0 78.8%
+-commutative78.8%
*-commutative78.8%
distribute-rgt-in78.7%
Simplified78.7%
Final simplification77.9%
(FPCore (x y z) :precision binary64 (+ (* z 5.0) (* x (+ z y))))
double code(double x, double y, double z) {
return (z * 5.0) + (x * (z + y));
}
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) + (x * (z + y))
end function
public static double code(double x, double y, double z) {
return (z * 5.0) + (x * (z + y));
}
def code(x, y, z): return (z * 5.0) + (x * (z + y))
function code(x, y, z) return Float64(Float64(z * 5.0) + Float64(x * Float64(z + y))) end
function tmp = code(x, y, z) tmp = (z * 5.0) + (x * (z + y)); end
code[x_, y_, z_] := N[(N[(z * 5.0), $MachinePrecision] + N[(x * N[(z + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z \cdot 5 + x \cdot \left(z + y\right)
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= x -9.8e-85) (* x y) (if (<= x 5.6e-31) (* z 5.0) (* x y))))
double code(double x, double y, double z) {
double tmp;
if (x <= -9.8e-85) {
tmp = x * y;
} else if (x <= 5.6e-31) {
tmp = z * 5.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) :: tmp
if (x <= (-9.8d-85)) then
tmp = x * y
else if (x <= 5.6d-31) then
tmp = z * 5.0d0
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -9.8e-85) {
tmp = x * y;
} else if (x <= 5.6e-31) {
tmp = z * 5.0;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -9.8e-85: tmp = x * y elif x <= 5.6e-31: tmp = z * 5.0 else: tmp = x * y return tmp
function code(x, y, z) tmp = 0.0 if (x <= -9.8e-85) tmp = Float64(x * y); elseif (x <= 5.6e-31) tmp = Float64(z * 5.0); else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -9.8e-85) tmp = x * y; elseif (x <= 5.6e-31) tmp = z * 5.0; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -9.8e-85], N[(x * y), $MachinePrecision], If[LessEqual[x, 5.6e-31], N[(z * 5.0), $MachinePrecision], N[(x * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.8 \cdot 10^{-85}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq 5.6 \cdot 10^{-31}:\\
\;\;\;\;z \cdot 5\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if x < -9.80000000000000029e-85 or 5.5999999999999998e-31 < x Initial program 100.0%
Taylor expanded in y around inf 53.3%
if -9.80000000000000029e-85 < x < 5.5999999999999998e-31Initial program 99.8%
Taylor expanded in x around 0 73.5%
Final simplification62.7%
(FPCore (x y z) :precision binary64 (if (<= x -5.0) (* z x) (if (<= x 6e-35) (* z 5.0) (* x y))))
double code(double x, double y, double z) {
double tmp;
if (x <= -5.0) {
tmp = z * x;
} else if (x <= 6e-35) {
tmp = z * 5.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) :: tmp
if (x <= (-5.0d0)) then
tmp = z * x
else if (x <= 6d-35) then
tmp = z * 5.0d0
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -5.0) {
tmp = z * x;
} else if (x <= 6e-35) {
tmp = z * 5.0;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -5.0: tmp = z * x elif x <= 6e-35: tmp = z * 5.0 else: tmp = x * y return tmp
function code(x, y, z) tmp = 0.0 if (x <= -5.0) tmp = Float64(z * x); elseif (x <= 6e-35) tmp = Float64(z * 5.0); else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -5.0) tmp = z * x; elseif (x <= 6e-35) tmp = z * 5.0; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -5.0], N[(z * x), $MachinePrecision], If[LessEqual[x, 6e-35], N[(z * 5.0), $MachinePrecision], N[(x * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;x \leq 6 \cdot 10^{-35}:\\
\;\;\;\;z \cdot 5\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if x < -5Initial program 99.9%
Taylor expanded in y around 0 67.3%
+-commutative67.3%
*-commutative67.3%
distribute-rgt-in67.3%
Simplified67.3%
Taylor expanded in x around inf 65.5%
if -5 < x < 5.99999999999999978e-35Initial program 99.8%
Taylor expanded in x around 0 69.1%
if 5.99999999999999978e-35 < x Initial program 100.0%
Taylor expanded in y around inf 62.9%
Final simplification66.8%
(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 38.6%
Final simplification38.6%
(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 2023185
(FPCore (x y z)
:name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendOutside from plot-0.2.3.4, C"
:precision binary64
:herbie-target
(+ (* (+ x 5.0) z) (* x y))
(+ (* x (+ y z)) (* z 5.0)))