
(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 -3.4e+250)
(* z x)
(if (<= x -2.8e+77)
(* x y)
(if (<= x -2e+15)
(* z x)
(if (<= x 9.8e-29)
(* z 5.0)
(if (or (<= x 5.8e+29)
(and (not (<= x 1.18e+101))
(or (<= x 8.4e+133)
(and (not (<= x 5.8e+163)) (<= x 2e+235)))))
(* x y)
(* z x)))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -3.4e+250) {
tmp = z * x;
} else if (x <= -2.8e+77) {
tmp = x * y;
} else if (x <= -2e+15) {
tmp = z * x;
} else if (x <= 9.8e-29) {
tmp = z * 5.0;
} else if ((x <= 5.8e+29) || (!(x <= 1.18e+101) && ((x <= 8.4e+133) || (!(x <= 5.8e+163) && (x <= 2e+235))))) {
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 <= (-3.4d+250)) then
tmp = z * x
else if (x <= (-2.8d+77)) then
tmp = x * y
else if (x <= (-2d+15)) then
tmp = z * x
else if (x <= 9.8d-29) then
tmp = z * 5.0d0
else if ((x <= 5.8d+29) .or. (.not. (x <= 1.18d+101)) .and. (x <= 8.4d+133) .or. (.not. (x <= 5.8d+163)) .and. (x <= 2d+235)) 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 <= -3.4e+250) {
tmp = z * x;
} else if (x <= -2.8e+77) {
tmp = x * y;
} else if (x <= -2e+15) {
tmp = z * x;
} else if (x <= 9.8e-29) {
tmp = z * 5.0;
} else if ((x <= 5.8e+29) || (!(x <= 1.18e+101) && ((x <= 8.4e+133) || (!(x <= 5.8e+163) && (x <= 2e+235))))) {
tmp = x * y;
} else {
tmp = z * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -3.4e+250: tmp = z * x elif x <= -2.8e+77: tmp = x * y elif x <= -2e+15: tmp = z * x elif x <= 9.8e-29: tmp = z * 5.0 elif (x <= 5.8e+29) or (not (x <= 1.18e+101) and ((x <= 8.4e+133) or (not (x <= 5.8e+163) and (x <= 2e+235)))): tmp = x * y else: tmp = z * x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -3.4e+250) tmp = Float64(z * x); elseif (x <= -2.8e+77) tmp = Float64(x * y); elseif (x <= -2e+15) tmp = Float64(z * x); elseif (x <= 9.8e-29) tmp = Float64(z * 5.0); elseif ((x <= 5.8e+29) || (!(x <= 1.18e+101) && ((x <= 8.4e+133) || (!(x <= 5.8e+163) && (x <= 2e+235))))) 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 <= -3.4e+250) tmp = z * x; elseif (x <= -2.8e+77) tmp = x * y; elseif (x <= -2e+15) tmp = z * x; elseif (x <= 9.8e-29) tmp = z * 5.0; elseif ((x <= 5.8e+29) || (~((x <= 1.18e+101)) && ((x <= 8.4e+133) || (~((x <= 5.8e+163)) && (x <= 2e+235))))) tmp = x * y; else tmp = z * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -3.4e+250], N[(z * x), $MachinePrecision], If[LessEqual[x, -2.8e+77], N[(x * y), $MachinePrecision], If[LessEqual[x, -2e+15], N[(z * x), $MachinePrecision], If[LessEqual[x, 9.8e-29], N[(z * 5.0), $MachinePrecision], If[Or[LessEqual[x, 5.8e+29], And[N[Not[LessEqual[x, 1.18e+101]], $MachinePrecision], Or[LessEqual[x, 8.4e+133], And[N[Not[LessEqual[x, 5.8e+163]], $MachinePrecision], LessEqual[x, 2e+235]]]]], N[(x * y), $MachinePrecision], N[(z * x), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.4 \cdot 10^{+250}:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;x \leq -2.8 \cdot 10^{+77}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq -2 \cdot 10^{+15}:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;x \leq 9.8 \cdot 10^{-29}:\\
\;\;\;\;z \cdot 5\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{+29} \lor \neg \left(x \leq 1.18 \cdot 10^{+101}\right) \land \left(x \leq 8.4 \cdot 10^{+133} \lor \neg \left(x \leq 5.8 \cdot 10^{+163}\right) \land x \leq 2 \cdot 10^{+235}\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if x < -3.39999999999999973e250 or -2.8e77 < x < -2e15 or 5.7999999999999999e29 < x < 1.18000000000000005e101 or 8.4e133 < x < 5.79999999999999996e163 or 2.0000000000000001e235 < x Initial program 100.0%
Taylor expanded in x around inf 100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in z around inf 73.9%
if -3.39999999999999973e250 < x < -2.8e77 or 9.7999999999999997e-29 < x < 5.7999999999999999e29 or 1.18000000000000005e101 < x < 8.4e133 or 5.79999999999999996e163 < x < 2.0000000000000001e235Initial program 100.0%
Taylor expanded in y around inf 72.5%
if -2e15 < x < 9.7999999999999997e-29Initial program 99.9%
Taylor expanded in x around 0 71.0%
Final simplification72.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (+ z y))))
(if (<= x -1.05e-6)
t_0
(if (<= x -3.2e-28)
(* z 5.0)
(if (<= x -2.6e-90)
(* x y)
(if (<= x -7e-233)
(* z 5.0)
(if (<= x -1.75e-235)
(* x y)
(if (<= x 5.2e-225)
(* z 5.0)
(if (<= x 5.3e-225)
(* x y)
(if (<= x 1.9e-37) (* z 5.0) t_0))))))))))
double code(double x, double y, double z) {
double t_0 = x * (z + y);
double tmp;
if (x <= -1.05e-6) {
tmp = t_0;
} else if (x <= -3.2e-28) {
tmp = z * 5.0;
} else if (x <= -2.6e-90) {
tmp = x * y;
} else if (x <= -7e-233) {
tmp = z * 5.0;
} else if (x <= -1.75e-235) {
tmp = x * y;
} else if (x <= 5.2e-225) {
tmp = z * 5.0;
} else if (x <= 5.3e-225) {
tmp = x * y;
} else if (x <= 1.9e-37) {
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 <= (-1.05d-6)) then
tmp = t_0
else if (x <= (-3.2d-28)) then
tmp = z * 5.0d0
else if (x <= (-2.6d-90)) then
tmp = x * y
else if (x <= (-7d-233)) then
tmp = z * 5.0d0
else if (x <= (-1.75d-235)) then
tmp = x * y
else if (x <= 5.2d-225) then
tmp = z * 5.0d0
else if (x <= 5.3d-225) then
tmp = x * y
else if (x <= 1.9d-37) 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 <= -1.05e-6) {
tmp = t_0;
} else if (x <= -3.2e-28) {
tmp = z * 5.0;
} else if (x <= -2.6e-90) {
tmp = x * y;
} else if (x <= -7e-233) {
tmp = z * 5.0;
} else if (x <= -1.75e-235) {
tmp = x * y;
} else if (x <= 5.2e-225) {
tmp = z * 5.0;
} else if (x <= 5.3e-225) {
tmp = x * y;
} else if (x <= 1.9e-37) {
tmp = z * 5.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (z + y) tmp = 0 if x <= -1.05e-6: tmp = t_0 elif x <= -3.2e-28: tmp = z * 5.0 elif x <= -2.6e-90: tmp = x * y elif x <= -7e-233: tmp = z * 5.0 elif x <= -1.75e-235: tmp = x * y elif x <= 5.2e-225: tmp = z * 5.0 elif x <= 5.3e-225: tmp = x * y elif x <= 1.9e-37: 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 <= -1.05e-6) tmp = t_0; elseif (x <= -3.2e-28) tmp = Float64(z * 5.0); elseif (x <= -2.6e-90) tmp = Float64(x * y); elseif (x <= -7e-233) tmp = Float64(z * 5.0); elseif (x <= -1.75e-235) tmp = Float64(x * y); elseif (x <= 5.2e-225) tmp = Float64(z * 5.0); elseif (x <= 5.3e-225) tmp = Float64(x * y); elseif (x <= 1.9e-37) 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 <= -1.05e-6) tmp = t_0; elseif (x <= -3.2e-28) tmp = z * 5.0; elseif (x <= -2.6e-90) tmp = x * y; elseif (x <= -7e-233) tmp = z * 5.0; elseif (x <= -1.75e-235) tmp = x * y; elseif (x <= 5.2e-225) tmp = z * 5.0; elseif (x <= 5.3e-225) tmp = x * y; elseif (x <= 1.9e-37) 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, -1.05e-6], t$95$0, If[LessEqual[x, -3.2e-28], N[(z * 5.0), $MachinePrecision], If[LessEqual[x, -2.6e-90], N[(x * y), $MachinePrecision], If[LessEqual[x, -7e-233], N[(z * 5.0), $MachinePrecision], If[LessEqual[x, -1.75e-235], N[(x * y), $MachinePrecision], If[LessEqual[x, 5.2e-225], N[(z * 5.0), $MachinePrecision], If[LessEqual[x, 5.3e-225], N[(x * y), $MachinePrecision], If[LessEqual[x, 1.9e-37], 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 -1.05 \cdot 10^{-6}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -3.2 \cdot 10^{-28}:\\
\;\;\;\;z \cdot 5\\
\mathbf{elif}\;x \leq -2.6 \cdot 10^{-90}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq -7 \cdot 10^{-233}:\\
\;\;\;\;z \cdot 5\\
\mathbf{elif}\;x \leq -1.75 \cdot 10^{-235}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{-225}:\\
\;\;\;\;z \cdot 5\\
\mathbf{elif}\;x \leq 5.3 \cdot 10^{-225}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-37}:\\
\;\;\;\;z \cdot 5\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.0499999999999999e-6 or 1.9000000000000002e-37 < x Initial program 100.0%
Taylor expanded in x around inf 97.0%
+-commutative97.0%
Simplified97.0%
if -1.0499999999999999e-6 < x < -3.19999999999999982e-28 or -2.6e-90 < x < -6.99999999999999982e-233 or -1.7499999999999999e-235 < x < 5.20000000000000027e-225 or 5.30000000000000005e-225 < x < 1.9000000000000002e-37Initial program 99.9%
Taylor expanded in x around 0 78.3%
if -3.19999999999999982e-28 < x < -2.6e-90 or -6.99999999999999982e-233 < x < -1.7499999999999999e-235 or 5.20000000000000027e-225 < x < 5.30000000000000005e-225Initial program 99.8%
Taylor expanded in y around inf 71.0%
Final simplification86.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (+ z y))))
(if (<= x -8.5e-6)
t_0
(if (<= x -3.5e-14)
(* z (+ 5.0 x))
(if (<= x -4.6e-90) (* x y) (if (<= x 7.1e-43) (* z 5.0) t_0))))))
double code(double x, double y, double z) {
double t_0 = x * (z + y);
double tmp;
if (x <= -8.5e-6) {
tmp = t_0;
} else if (x <= -3.5e-14) {
tmp = z * (5.0 + x);
} else if (x <= -4.6e-90) {
tmp = x * y;
} else if (x <= 7.1e-43) {
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 <= (-8.5d-6)) then
tmp = t_0
else if (x <= (-3.5d-14)) then
tmp = z * (5.0d0 + x)
else if (x <= (-4.6d-90)) then
tmp = x * y
else if (x <= 7.1d-43) 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 <= -8.5e-6) {
tmp = t_0;
} else if (x <= -3.5e-14) {
tmp = z * (5.0 + x);
} else if (x <= -4.6e-90) {
tmp = x * y;
} else if (x <= 7.1e-43) {
tmp = z * 5.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (z + y) tmp = 0 if x <= -8.5e-6: tmp = t_0 elif x <= -3.5e-14: tmp = z * (5.0 + x) elif x <= -4.6e-90: tmp = x * y elif x <= 7.1e-43: 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 <= -8.5e-6) tmp = t_0; elseif (x <= -3.5e-14) tmp = Float64(z * Float64(5.0 + x)); elseif (x <= -4.6e-90) tmp = Float64(x * y); elseif (x <= 7.1e-43) 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 <= -8.5e-6) tmp = t_0; elseif (x <= -3.5e-14) tmp = z * (5.0 + x); elseif (x <= -4.6e-90) tmp = x * y; elseif (x <= 7.1e-43) 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, -8.5e-6], t$95$0, If[LessEqual[x, -3.5e-14], N[(z * N[(5.0 + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -4.6e-90], N[(x * y), $MachinePrecision], If[LessEqual[x, 7.1e-43], 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 -8.5 \cdot 10^{-6}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -3.5 \cdot 10^{-14}:\\
\;\;\;\;z \cdot \left(5 + x\right)\\
\mathbf{elif}\;x \leq -4.6 \cdot 10^{-90}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq 7.1 \cdot 10^{-43}:\\
\;\;\;\;z \cdot 5\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -8.4999999999999999e-6 or 7.10000000000000025e-43 < x Initial program 100.0%
Taylor expanded in x around inf 96.3%
+-commutative96.3%
Simplified96.3%
if -8.4999999999999999e-6 < x < -3.5000000000000002e-14Initial program 100.0%
Taylor expanded in y around 0 100.0%
distribute-rgt-in100.0%
Simplified100.0%
if -3.5000000000000002e-14 < x < -4.5999999999999996e-90Initial program 99.8%
Taylor expanded in y around inf 59.7%
if -4.5999999999999996e-90 < x < 7.10000000000000025e-43Initial program 99.9%
Taylor expanded in x around 0 76.4%
Final simplification85.4%
(FPCore (x y z)
:precision binary64
(if (or (<= x -1.1e-6)
(and (not (<= x -6.1e-37)) (or (<= x -4.4e-91) (not (<= x 9.5e-29)))))
(* x y)
(* z 5.0)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.1e-6) || (!(x <= -6.1e-37) && ((x <= -4.4e-91) || !(x <= 9.5e-29)))) {
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 <= (-1.1d-6)) .or. (.not. (x <= (-6.1d-37))) .and. (x <= (-4.4d-91)) .or. (.not. (x <= 9.5d-29))) 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 <= -1.1e-6) || (!(x <= -6.1e-37) && ((x <= -4.4e-91) || !(x <= 9.5e-29)))) {
tmp = x * y;
} else {
tmp = z * 5.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.1e-6) or (not (x <= -6.1e-37) and ((x <= -4.4e-91) or not (x <= 9.5e-29))): tmp = x * y else: tmp = z * 5.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.1e-6) || (!(x <= -6.1e-37) && ((x <= -4.4e-91) || !(x <= 9.5e-29)))) 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 <= -1.1e-6) || (~((x <= -6.1e-37)) && ((x <= -4.4e-91) || ~((x <= 9.5e-29))))) tmp = x * y; else tmp = z * 5.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.1e-6], And[N[Not[LessEqual[x, -6.1e-37]], $MachinePrecision], Or[LessEqual[x, -4.4e-91], N[Not[LessEqual[x, 9.5e-29]], $MachinePrecision]]]], N[(x * y), $MachinePrecision], N[(z * 5.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.1 \cdot 10^{-6} \lor \neg \left(x \leq -6.1 \cdot 10^{-37}\right) \land \left(x \leq -4.4 \cdot 10^{-91} \lor \neg \left(x \leq 9.5 \cdot 10^{-29}\right)\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;z \cdot 5\\
\end{array}
\end{array}
if x < -1.1000000000000001e-6 or -6.1000000000000003e-37 < x < -4.4000000000000002e-91 or 9.50000000000000023e-29 < x Initial program 100.0%
Taylor expanded in y around inf 55.9%
if -1.1000000000000001e-6 < x < -6.1000000000000003e-37 or -4.4000000000000002e-91 < x < 9.50000000000000023e-29Initial program 99.9%
Taylor expanded in x around 0 76.6%
Final simplification65.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -5.0) (not (<= x 1.26e-31))) (* x (+ z y)) (+ (* z 5.0) (* x y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.0) || !(x <= 1.26e-31)) {
tmp = x * (z + y);
} else {
tmp = (z * 5.0) + (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)) .or. (.not. (x <= 1.26d-31))) then
tmp = x * (z + y)
else
tmp = (z * 5.0d0) + (x * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -5.0) || !(x <= 1.26e-31)) {
tmp = x * (z + y);
} else {
tmp = (z * 5.0) + (x * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5.0) or not (x <= 1.26e-31): tmp = x * (z + y) else: tmp = (z * 5.0) + (x * y) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5.0) || !(x <= 1.26e-31)) tmp = Float64(x * Float64(z + y)); else tmp = Float64(Float64(z * 5.0) + Float64(x * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -5.0) || ~((x <= 1.26e-31))) tmp = x * (z + y); else tmp = (z * 5.0) + (x * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5.0], N[Not[LessEqual[x, 1.26e-31]], $MachinePrecision]], N[(x * N[(z + y), $MachinePrecision]), $MachinePrecision], N[(N[(z * 5.0), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \lor \neg \left(x \leq 1.26 \cdot 10^{-31}\right):\\
\;\;\;\;x \cdot \left(z + y\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot 5 + x \cdot y\\
\end{array}
\end{array}
if x < -5 or 1.2599999999999999e-31 < x Initial program 100.0%
Taylor expanded in x around inf 96.9%
+-commutative96.9%
Simplified96.9%
if -5 < x < 1.2599999999999999e-31Initial program 99.9%
Taylor expanded in y around -inf 89.4%
associate-*r*89.4%
mul-1-neg89.4%
distribute-lft-out89.4%
distribute-rgt-in89.4%
associate-/l*89.2%
Simplified89.2%
clear-num89.1%
un-div-inv89.2%
Applied egg-rr89.2%
Taylor expanded in x around 0 88.3%
*-commutative88.3%
Simplified88.3%
Taylor expanded in y around 0 99.1%
Final simplification98.1%
(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 40.4%
Final simplification40.4%
(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 2024107
(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)))