
(FPCore (x y z t) :precision binary64 (+ (* x (+ (+ (+ (+ y z) z) y) t)) (* y 5.0)))
double code(double x, double y, double z, double t) {
return (x * ((((y + z) + z) + y) + t)) + (y * 5.0);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x * ((((y + z) + z) + y) + t)) + (y * 5.0d0)
end function
public static double code(double x, double y, double z, double t) {
return (x * ((((y + z) + z) + y) + t)) + (y * 5.0);
}
def code(x, y, z, t): return (x * ((((y + z) + z) + y) + t)) + (y * 5.0)
function code(x, y, z, t) return Float64(Float64(x * Float64(Float64(Float64(Float64(y + z) + z) + y) + t)) + Float64(y * 5.0)) end
function tmp = code(x, y, z, t) tmp = (x * ((((y + z) + z) + y) + t)) + (y * 5.0); end
code[x_, y_, z_, t_] := N[(N[(x * N[(N[(N[(N[(y + z), $MachinePrecision] + z), $MachinePrecision] + y), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision] + N[(y * 5.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right) + y \cdot 5
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ (* x (+ (+ (+ (+ y z) z) y) t)) (* y 5.0)))
double code(double x, double y, double z, double t) {
return (x * ((((y + z) + z) + y) + t)) + (y * 5.0);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x * ((((y + z) + z) + y) + t)) + (y * 5.0d0)
end function
public static double code(double x, double y, double z, double t) {
return (x * ((((y + z) + z) + y) + t)) + (y * 5.0);
}
def code(x, y, z, t): return (x * ((((y + z) + z) + y) + t)) + (y * 5.0)
function code(x, y, z, t) return Float64(Float64(x * Float64(Float64(Float64(Float64(y + z) + z) + y) + t)) + Float64(y * 5.0)) end
function tmp = code(x, y, z, t) tmp = (x * ((((y + z) + z) + y) + t)) + (y * 5.0); end
code[x_, y_, z_, t_] := N[(N[(x * N[(N[(N[(N[(y + z), $MachinePrecision] + z), $MachinePrecision] + y), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision] + N[(y * 5.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right) + y \cdot 5
\end{array}
(FPCore (x y z t) :precision binary64 (fma y 5.0 (* x (fma (+ y z) 2.0 t))))
double code(double x, double y, double z, double t) {
return fma(y, 5.0, (x * fma((y + z), 2.0, t)));
}
function code(x, y, z, t) return fma(y, 5.0, Float64(x * fma(Float64(y + z), 2.0, t))) end
code[x_, y_, z_, t_] := N[(y * 5.0 + N[(x * N[(N[(y + z), $MachinePrecision] * 2.0 + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, 5, x \cdot \mathsf{fma}\left(y + z, 2, t\right)\right)
\end{array}
Initial program 100.0%
+-commutative100.0%
fma-def100.0%
flip-+58.9%
associate-*r/56.6%
fma-neg59.6%
associate-+l+59.6%
+-commutative59.6%
count-259.6%
associate-+l+59.6%
+-commutative59.6%
count-259.6%
fma-neg56.6%
associate-+l+56.6%
+-commutative56.6%
count-256.6%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y z t) :precision binary64 (fma x (+ t (* (+ y z) 2.0)) (* y 5.0)))
double code(double x, double y, double z, double t) {
return fma(x, (t + ((y + z) * 2.0)), (y * 5.0));
}
function code(x, y, z, t) return fma(x, Float64(t + Float64(Float64(y + z) * 2.0)), Float64(y * 5.0)) end
code[x_, y_, z_, t_] := N[(x * N[(t + N[(N[(y + z), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] + N[(y * 5.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, t + \left(y + z\right) \cdot 2, y \cdot 5\right)
\end{array}
Initial program 100.0%
fma-def100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* z (* x 2.0))) (t_2 (* x (* y 2.0))))
(if (<= x -4.5e+183)
t_1
(if (<= x -5.6e+106)
t_2
(if (<= x -5.7e+20)
(* x t)
(if (<= x -9e-80)
t_1
(if (<= x 2.7e-29)
(* y 5.0)
(if (<= x 500.0) (* x t) (if (<= x 4.1e+80) t_2 t_1)))))))))
double code(double x, double y, double z, double t) {
double t_1 = z * (x * 2.0);
double t_2 = x * (y * 2.0);
double tmp;
if (x <= -4.5e+183) {
tmp = t_1;
} else if (x <= -5.6e+106) {
tmp = t_2;
} else if (x <= -5.7e+20) {
tmp = x * t;
} else if (x <= -9e-80) {
tmp = t_1;
} else if (x <= 2.7e-29) {
tmp = y * 5.0;
} else if (x <= 500.0) {
tmp = x * t;
} else if (x <= 4.1e+80) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = z * (x * 2.0d0)
t_2 = x * (y * 2.0d0)
if (x <= (-4.5d+183)) then
tmp = t_1
else if (x <= (-5.6d+106)) then
tmp = t_2
else if (x <= (-5.7d+20)) then
tmp = x * t
else if (x <= (-9d-80)) then
tmp = t_1
else if (x <= 2.7d-29) then
tmp = y * 5.0d0
else if (x <= 500.0d0) then
tmp = x * t
else if (x <= 4.1d+80) then
tmp = t_2
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = z * (x * 2.0);
double t_2 = x * (y * 2.0);
double tmp;
if (x <= -4.5e+183) {
tmp = t_1;
} else if (x <= -5.6e+106) {
tmp = t_2;
} else if (x <= -5.7e+20) {
tmp = x * t;
} else if (x <= -9e-80) {
tmp = t_1;
} else if (x <= 2.7e-29) {
tmp = y * 5.0;
} else if (x <= 500.0) {
tmp = x * t;
} else if (x <= 4.1e+80) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = z * (x * 2.0) t_2 = x * (y * 2.0) tmp = 0 if x <= -4.5e+183: tmp = t_1 elif x <= -5.6e+106: tmp = t_2 elif x <= -5.7e+20: tmp = x * t elif x <= -9e-80: tmp = t_1 elif x <= 2.7e-29: tmp = y * 5.0 elif x <= 500.0: tmp = x * t elif x <= 4.1e+80: tmp = t_2 else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(z * Float64(x * 2.0)) t_2 = Float64(x * Float64(y * 2.0)) tmp = 0.0 if (x <= -4.5e+183) tmp = t_1; elseif (x <= -5.6e+106) tmp = t_2; elseif (x <= -5.7e+20) tmp = Float64(x * t); elseif (x <= -9e-80) tmp = t_1; elseif (x <= 2.7e-29) tmp = Float64(y * 5.0); elseif (x <= 500.0) tmp = Float64(x * t); elseif (x <= 4.1e+80) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = z * (x * 2.0); t_2 = x * (y * 2.0); tmp = 0.0; if (x <= -4.5e+183) tmp = t_1; elseif (x <= -5.6e+106) tmp = t_2; elseif (x <= -5.7e+20) tmp = x * t; elseif (x <= -9e-80) tmp = t_1; elseif (x <= 2.7e-29) tmp = y * 5.0; elseif (x <= 500.0) tmp = x * t; elseif (x <= 4.1e+80) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(x * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x * N[(y * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.5e+183], t$95$1, If[LessEqual[x, -5.6e+106], t$95$2, If[LessEqual[x, -5.7e+20], N[(x * t), $MachinePrecision], If[LessEqual[x, -9e-80], t$95$1, If[LessEqual[x, 2.7e-29], N[(y * 5.0), $MachinePrecision], If[LessEqual[x, 500.0], N[(x * t), $MachinePrecision], If[LessEqual[x, 4.1e+80], t$95$2, t$95$1]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \left(x \cdot 2\right)\\
t_2 := x \cdot \left(y \cdot 2\right)\\
\mathbf{if}\;x \leq -4.5 \cdot 10^{+183}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -5.6 \cdot 10^{+106}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq -5.7 \cdot 10^{+20}:\\
\;\;\;\;x \cdot t\\
\mathbf{elif}\;x \leq -9 \cdot 10^{-80}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{-29}:\\
\;\;\;\;y \cdot 5\\
\mathbf{elif}\;x \leq 500:\\
\;\;\;\;x \cdot t\\
\mathbf{elif}\;x \leq 4.1 \cdot 10^{+80}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -4.50000000000000017e183 or -5.7e20 < x < -9.0000000000000006e-80 or 4.10000000000000001e80 < x Initial program 100.0%
fma-def100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around inf 96.4%
Taylor expanded in z around inf 52.2%
associate-*r*52.2%
Simplified52.2%
if -4.50000000000000017e183 < x < -5.59999999999999986e106 or 500 < x < 4.10000000000000001e80Initial program 100.0%
fma-def100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around inf 93.2%
Taylor expanded in y around inf 52.1%
associate-*r*52.1%
*-commutative52.1%
associate-*r*52.1%
Simplified52.1%
if -5.59999999999999986e106 < x < -5.7e20 or 2.70000000000000023e-29 < x < 500Initial program 99.9%
fma-def99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in x around inf 92.7%
Taylor expanded in t around inf 62.3%
*-commutative62.3%
Simplified62.3%
if -9.0000000000000006e-80 < x < 2.70000000000000023e-29Initial program 100.0%
Taylor expanded in x around 0 60.8%
Simplified60.8%
Final simplification57.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* x (* y 2.0))))
(if (<= x -3.2e+143)
(* x t)
(if (<= x -5e+106)
t_1
(if (<= x -3.8e-87)
(* x t)
(if (<= x 1.4e-40)
(* y 5.0)
(if (or (<= x 500.0) (not (<= x 3.5e+101))) (* x t) t_1)))))))
double code(double x, double y, double z, double t) {
double t_1 = x * (y * 2.0);
double tmp;
if (x <= -3.2e+143) {
tmp = x * t;
} else if (x <= -5e+106) {
tmp = t_1;
} else if (x <= -3.8e-87) {
tmp = x * t;
} else if (x <= 1.4e-40) {
tmp = y * 5.0;
} else if ((x <= 500.0) || !(x <= 3.5e+101)) {
tmp = x * t;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = x * (y * 2.0d0)
if (x <= (-3.2d+143)) then
tmp = x * t
else if (x <= (-5d+106)) then
tmp = t_1
else if (x <= (-3.8d-87)) then
tmp = x * t
else if (x <= 1.4d-40) then
tmp = y * 5.0d0
else if ((x <= 500.0d0) .or. (.not. (x <= 3.5d+101))) then
tmp = x * t
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x * (y * 2.0);
double tmp;
if (x <= -3.2e+143) {
tmp = x * t;
} else if (x <= -5e+106) {
tmp = t_1;
} else if (x <= -3.8e-87) {
tmp = x * t;
} else if (x <= 1.4e-40) {
tmp = y * 5.0;
} else if ((x <= 500.0) || !(x <= 3.5e+101)) {
tmp = x * t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x * (y * 2.0) tmp = 0 if x <= -3.2e+143: tmp = x * t elif x <= -5e+106: tmp = t_1 elif x <= -3.8e-87: tmp = x * t elif x <= 1.4e-40: tmp = y * 5.0 elif (x <= 500.0) or not (x <= 3.5e+101): tmp = x * t else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x * Float64(y * 2.0)) tmp = 0.0 if (x <= -3.2e+143) tmp = Float64(x * t); elseif (x <= -5e+106) tmp = t_1; elseif (x <= -3.8e-87) tmp = Float64(x * t); elseif (x <= 1.4e-40) tmp = Float64(y * 5.0); elseif ((x <= 500.0) || !(x <= 3.5e+101)) tmp = Float64(x * t); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x * (y * 2.0); tmp = 0.0; if (x <= -3.2e+143) tmp = x * t; elseif (x <= -5e+106) tmp = t_1; elseif (x <= -3.8e-87) tmp = x * t; elseif (x <= 1.4e-40) tmp = y * 5.0; elseif ((x <= 500.0) || ~((x <= 3.5e+101))) tmp = x * t; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[(y * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.2e+143], N[(x * t), $MachinePrecision], If[LessEqual[x, -5e+106], t$95$1, If[LessEqual[x, -3.8e-87], N[(x * t), $MachinePrecision], If[LessEqual[x, 1.4e-40], N[(y * 5.0), $MachinePrecision], If[Or[LessEqual[x, 500.0], N[Not[LessEqual[x, 3.5e+101]], $MachinePrecision]], N[(x * t), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \left(y \cdot 2\right)\\
\mathbf{if}\;x \leq -3.2 \cdot 10^{+143}:\\
\;\;\;\;x \cdot t\\
\mathbf{elif}\;x \leq -5 \cdot 10^{+106}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -3.8 \cdot 10^{-87}:\\
\;\;\;\;x \cdot t\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{-40}:\\
\;\;\;\;y \cdot 5\\
\mathbf{elif}\;x \leq 500 \lor \neg \left(x \leq 3.5 \cdot 10^{+101}\right):\\
\;\;\;\;x \cdot t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -3.20000000000000016e143 or -4.9999999999999998e106 < x < -3.8e-87 or 1.4e-40 < x < 500 or 3.50000000000000023e101 < x Initial program 100.0%
fma-def100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around inf 95.1%
Taylor expanded in t around inf 44.4%
*-commutative44.4%
Simplified44.4%
if -3.20000000000000016e143 < x < -4.9999999999999998e106 or 500 < x < 3.50000000000000023e101Initial program 99.9%
fma-def100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around inf 91.1%
Taylor expanded in y around inf 55.7%
associate-*r*55.7%
*-commutative55.7%
associate-*r*55.7%
Simplified55.7%
if -3.8e-87 < x < 1.4e-40Initial program 100.0%
Taylor expanded in x around 0 61.0%
Simplified61.0%
Final simplification52.9%
(FPCore (x y z t)
:precision binary64
(if (or (<= x -6e-185)
(and (not (<= x 7.2e-238))
(or (<= x 1.38e-188) (not (<= x 1.35e-41)))))
(* x (+ t (* z 2.0)))
(* y 5.0)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -6e-185) || (!(x <= 7.2e-238) && ((x <= 1.38e-188) || !(x <= 1.35e-41)))) {
tmp = x * (t + (z * 2.0));
} else {
tmp = y * 5.0;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((x <= (-6d-185)) .or. (.not. (x <= 7.2d-238)) .and. (x <= 1.38d-188) .or. (.not. (x <= 1.35d-41))) then
tmp = x * (t + (z * 2.0d0))
else
tmp = y * 5.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -6e-185) || (!(x <= 7.2e-238) && ((x <= 1.38e-188) || !(x <= 1.35e-41)))) {
tmp = x * (t + (z * 2.0));
} else {
tmp = y * 5.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -6e-185) or (not (x <= 7.2e-238) and ((x <= 1.38e-188) or not (x <= 1.35e-41))): tmp = x * (t + (z * 2.0)) else: tmp = y * 5.0 return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -6e-185) || (!(x <= 7.2e-238) && ((x <= 1.38e-188) || !(x <= 1.35e-41)))) tmp = Float64(x * Float64(t + Float64(z * 2.0))); else tmp = Float64(y * 5.0); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -6e-185) || (~((x <= 7.2e-238)) && ((x <= 1.38e-188) || ~((x <= 1.35e-41))))) tmp = x * (t + (z * 2.0)); else tmp = y * 5.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -6e-185], And[N[Not[LessEqual[x, 7.2e-238]], $MachinePrecision], Or[LessEqual[x, 1.38e-188], N[Not[LessEqual[x, 1.35e-41]], $MachinePrecision]]]], N[(x * N[(t + N[(z * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * 5.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6 \cdot 10^{-185} \lor \neg \left(x \leq 7.2 \cdot 10^{-238}\right) \land \left(x \leq 1.38 \cdot 10^{-188} \lor \neg \left(x \leq 1.35 \cdot 10^{-41}\right)\right):\\
\;\;\;\;x \cdot \left(t + z \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot 5\\
\end{array}
\end{array}
if x < -6.00000000000000061e-185 or 7.20000000000000021e-238 < x < 1.3800000000000001e-188 or 1.35e-41 < x Initial program 100.0%
fma-def100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around inf 88.5%
Taylor expanded in y around 0 69.3%
if -6.00000000000000061e-185 < x < 7.20000000000000021e-238 or 1.3800000000000001e-188 < x < 1.35e-41Initial program 100.0%
Taylor expanded in x around 0 69.0%
Simplified69.0%
Final simplification69.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* x (+ t (* (+ y z) 2.0)))))
(if (<= x -9.5e-74)
t_1
(if (<= x 1.2e-298)
(+ (* y 5.0) (* x t))
(if (<= x 9e-35) (+ (* y 5.0) (* 2.0 (* x z))) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = x * (t + ((y + z) * 2.0));
double tmp;
if (x <= -9.5e-74) {
tmp = t_1;
} else if (x <= 1.2e-298) {
tmp = (y * 5.0) + (x * t);
} else if (x <= 9e-35) {
tmp = (y * 5.0) + (2.0 * (x * z));
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = x * (t + ((y + z) * 2.0d0))
if (x <= (-9.5d-74)) then
tmp = t_1
else if (x <= 1.2d-298) then
tmp = (y * 5.0d0) + (x * t)
else if (x <= 9d-35) then
tmp = (y * 5.0d0) + (2.0d0 * (x * z))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x * (t + ((y + z) * 2.0));
double tmp;
if (x <= -9.5e-74) {
tmp = t_1;
} else if (x <= 1.2e-298) {
tmp = (y * 5.0) + (x * t);
} else if (x <= 9e-35) {
tmp = (y * 5.0) + (2.0 * (x * z));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x * (t + ((y + z) * 2.0)) tmp = 0 if x <= -9.5e-74: tmp = t_1 elif x <= 1.2e-298: tmp = (y * 5.0) + (x * t) elif x <= 9e-35: tmp = (y * 5.0) + (2.0 * (x * z)) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x * Float64(t + Float64(Float64(y + z) * 2.0))) tmp = 0.0 if (x <= -9.5e-74) tmp = t_1; elseif (x <= 1.2e-298) tmp = Float64(Float64(y * 5.0) + Float64(x * t)); elseif (x <= 9e-35) tmp = Float64(Float64(y * 5.0) + Float64(2.0 * Float64(x * z))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x * (t + ((y + z) * 2.0)); tmp = 0.0; if (x <= -9.5e-74) tmp = t_1; elseif (x <= 1.2e-298) tmp = (y * 5.0) + (x * t); elseif (x <= 9e-35) tmp = (y * 5.0) + (2.0 * (x * z)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[(t + N[(N[(y + z), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -9.5e-74], t$95$1, If[LessEqual[x, 1.2e-298], N[(N[(y * 5.0), $MachinePrecision] + N[(x * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 9e-35], N[(N[(y * 5.0), $MachinePrecision] + N[(2.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \left(t + \left(y + z\right) \cdot 2\right)\\
\mathbf{if}\;x \leq -9.5 \cdot 10^{-74}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{-298}:\\
\;\;\;\;y \cdot 5 + x \cdot t\\
\mathbf{elif}\;x \leq 9 \cdot 10^{-35}:\\
\;\;\;\;y \cdot 5 + 2 \cdot \left(x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -9.5000000000000007e-74 or 9.0000000000000002e-35 < x Initial program 100.0%
fma-def100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around inf 95.0%
if -9.5000000000000007e-74 < x < 1.19999999999999994e-298Initial program 100.0%
Taylor expanded in t around inf 90.5%
if 1.19999999999999994e-298 < x < 9.0000000000000002e-35Initial program 99.9%
Taylor expanded in z around inf 86.8%
Final simplification92.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* x (+ t (* y 2.0)))))
(if (<= x -8.6e+20)
t_1
(if (<= x -2.3e-74) (* z (* x 2.0)) (if (<= x 5.2e-36) (* y 5.0) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = x * (t + (y * 2.0));
double tmp;
if (x <= -8.6e+20) {
tmp = t_1;
} else if (x <= -2.3e-74) {
tmp = z * (x * 2.0);
} else if (x <= 5.2e-36) {
tmp = y * 5.0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = x * (t + (y * 2.0d0))
if (x <= (-8.6d+20)) then
tmp = t_1
else if (x <= (-2.3d-74)) then
tmp = z * (x * 2.0d0)
else if (x <= 5.2d-36) then
tmp = y * 5.0d0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x * (t + (y * 2.0));
double tmp;
if (x <= -8.6e+20) {
tmp = t_1;
} else if (x <= -2.3e-74) {
tmp = z * (x * 2.0);
} else if (x <= 5.2e-36) {
tmp = y * 5.0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x * (t + (y * 2.0)) tmp = 0 if x <= -8.6e+20: tmp = t_1 elif x <= -2.3e-74: tmp = z * (x * 2.0) elif x <= 5.2e-36: tmp = y * 5.0 else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x * Float64(t + Float64(y * 2.0))) tmp = 0.0 if (x <= -8.6e+20) tmp = t_1; elseif (x <= -2.3e-74) tmp = Float64(z * Float64(x * 2.0)); elseif (x <= 5.2e-36) tmp = Float64(y * 5.0); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x * (t + (y * 2.0)); tmp = 0.0; if (x <= -8.6e+20) tmp = t_1; elseif (x <= -2.3e-74) tmp = z * (x * 2.0); elseif (x <= 5.2e-36) tmp = y * 5.0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[(t + N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -8.6e+20], t$95$1, If[LessEqual[x, -2.3e-74], N[(z * N[(x * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.2e-36], N[(y * 5.0), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \left(t + y \cdot 2\right)\\
\mathbf{if}\;x \leq -8.6 \cdot 10^{+20}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -2.3 \cdot 10^{-74}:\\
\;\;\;\;z \cdot \left(x \cdot 2\right)\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{-36}:\\
\;\;\;\;y \cdot 5\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -8.6e20 or 5.2000000000000001e-36 < x Initial program 100.0%
fma-def100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around inf 96.8%
Taylor expanded in z around 0 66.6%
if -8.6e20 < x < -2.2999999999999998e-74Initial program 100.0%
fma-def100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around inf 81.5%
Taylor expanded in z around inf 57.9%
associate-*r*57.9%
Simplified57.9%
if -2.2999999999999998e-74 < x < 5.2000000000000001e-36Initial program 100.0%
Taylor expanded in x around 0 60.8%
Simplified60.8%
Final simplification63.4%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (+ 5.0 (* x 2.0)))))
(if (<= y -1.4e+111)
t_1
(if (<= y 1.05e-63)
(* x (+ t (* z 2.0)))
(if (<= y 2.9e+94) (+ (* y 5.0) (* x t)) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = y * (5.0 + (x * 2.0));
double tmp;
if (y <= -1.4e+111) {
tmp = t_1;
} else if (y <= 1.05e-63) {
tmp = x * (t + (z * 2.0));
} else if (y <= 2.9e+94) {
tmp = (y * 5.0) + (x * t);
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = y * (5.0d0 + (x * 2.0d0))
if (y <= (-1.4d+111)) then
tmp = t_1
else if (y <= 1.05d-63) then
tmp = x * (t + (z * 2.0d0))
else if (y <= 2.9d+94) then
tmp = (y * 5.0d0) + (x * t)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = y * (5.0 + (x * 2.0));
double tmp;
if (y <= -1.4e+111) {
tmp = t_1;
} else if (y <= 1.05e-63) {
tmp = x * (t + (z * 2.0));
} else if (y <= 2.9e+94) {
tmp = (y * 5.0) + (x * t);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = y * (5.0 + (x * 2.0)) tmp = 0 if y <= -1.4e+111: tmp = t_1 elif y <= 1.05e-63: tmp = x * (t + (z * 2.0)) elif y <= 2.9e+94: tmp = (y * 5.0) + (x * t) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(y * Float64(5.0 + Float64(x * 2.0))) tmp = 0.0 if (y <= -1.4e+111) tmp = t_1; elseif (y <= 1.05e-63) tmp = Float64(x * Float64(t + Float64(z * 2.0))); elseif (y <= 2.9e+94) tmp = Float64(Float64(y * 5.0) + Float64(x * t)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = y * (5.0 + (x * 2.0)); tmp = 0.0; if (y <= -1.4e+111) tmp = t_1; elseif (y <= 1.05e-63) tmp = x * (t + (z * 2.0)); elseif (y <= 2.9e+94) tmp = (y * 5.0) + (x * t); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(5.0 + N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.4e+111], t$95$1, If[LessEqual[y, 1.05e-63], N[(x * N[(t + N[(z * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.9e+94], N[(N[(y * 5.0), $MachinePrecision] + N[(x * t), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(5 + x \cdot 2\right)\\
\mathbf{if}\;y \leq -1.4 \cdot 10^{+111}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{-63}:\\
\;\;\;\;x \cdot \left(t + z \cdot 2\right)\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{+94}:\\
\;\;\;\;y \cdot 5 + x \cdot t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1.4e111 or 2.8999999999999998e94 < y Initial program 100.0%
Taylor expanded in y around inf 89.2%
if -1.4e111 < y < 1.05e-63Initial program 100.0%
fma-def100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around inf 83.6%
Taylor expanded in y around 0 80.1%
if 1.05e-63 < y < 2.8999999999999998e94Initial program 100.0%
Taylor expanded in t around inf 70.8%
Final simplification81.5%
(FPCore (x y z t) :precision binary64 (if (or (<= x -1.15e-73) (not (<= x 3.7e-38))) (* x (+ t (* (+ y z) 2.0))) (+ (* y 5.0) (* x t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.15e-73) || !(x <= 3.7e-38)) {
tmp = x * (t + ((y + z) * 2.0));
} else {
tmp = (y * 5.0) + (x * t);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((x <= (-1.15d-73)) .or. (.not. (x <= 3.7d-38))) then
tmp = x * (t + ((y + z) * 2.0d0))
else
tmp = (y * 5.0d0) + (x * t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.15e-73) || !(x <= 3.7e-38)) {
tmp = x * (t + ((y + z) * 2.0));
} else {
tmp = (y * 5.0) + (x * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -1.15e-73) or not (x <= 3.7e-38): tmp = x * (t + ((y + z) * 2.0)) else: tmp = (y * 5.0) + (x * t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -1.15e-73) || !(x <= 3.7e-38)) tmp = Float64(x * Float64(t + Float64(Float64(y + z) * 2.0))); else tmp = Float64(Float64(y * 5.0) + Float64(x * t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -1.15e-73) || ~((x <= 3.7e-38))) tmp = x * (t + ((y + z) * 2.0)); else tmp = (y * 5.0) + (x * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -1.15e-73], N[Not[LessEqual[x, 3.7e-38]], $MachinePrecision]], N[(x * N[(t + N[(N[(y + z), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * 5.0), $MachinePrecision] + N[(x * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.15 \cdot 10^{-73} \lor \neg \left(x \leq 3.7 \cdot 10^{-38}\right):\\
\;\;\;\;x \cdot \left(t + \left(y + z\right) \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot 5 + x \cdot t\\
\end{array}
\end{array}
if x < -1.14999999999999994e-73 or 3.7e-38 < x Initial program 100.0%
fma-def100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around inf 95.0%
if -1.14999999999999994e-73 < x < 3.7e-38Initial program 100.0%
Taylor expanded in t around inf 79.1%
Final simplification87.9%
(FPCore (x y z t) :precision binary64 (if (or (<= y -2.35e+111) (not (<= y 6.1e-18))) (* y (+ 5.0 (* x 2.0))) (* x (+ t (* z 2.0)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2.35e+111) || !(y <= 6.1e-18)) {
tmp = y * (5.0 + (x * 2.0));
} else {
tmp = x * (t + (z * 2.0));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((y <= (-2.35d+111)) .or. (.not. (y <= 6.1d-18))) then
tmp = y * (5.0d0 + (x * 2.0d0))
else
tmp = x * (t + (z * 2.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2.35e+111) || !(y <= 6.1e-18)) {
tmp = y * (5.0 + (x * 2.0));
} else {
tmp = x * (t + (z * 2.0));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -2.35e+111) or not (y <= 6.1e-18): tmp = y * (5.0 + (x * 2.0)) else: tmp = x * (t + (z * 2.0)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -2.35e+111) || !(y <= 6.1e-18)) tmp = Float64(y * Float64(5.0 + Float64(x * 2.0))); else tmp = Float64(x * Float64(t + Float64(z * 2.0))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -2.35e+111) || ~((y <= 6.1e-18))) tmp = y * (5.0 + (x * 2.0)); else tmp = x * (t + (z * 2.0)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -2.35e+111], N[Not[LessEqual[y, 6.1e-18]], $MachinePrecision]], N[(y * N[(5.0 + N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(t + N[(z * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.35 \cdot 10^{+111} \lor \neg \left(y \leq 6.1 \cdot 10^{-18}\right):\\
\;\;\;\;y \cdot \left(5 + x \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(t + z \cdot 2\right)\\
\end{array}
\end{array}
if y < -2.35000000000000004e111 or 6.0999999999999999e-18 < y Initial program 100.0%
Taylor expanded in y around inf 82.9%
if -2.35000000000000004e111 < y < 6.0999999999999999e-18Initial program 100.0%
fma-def100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around inf 81.5%
Taylor expanded in y around 0 78.2%
Final simplification80.0%
(FPCore (x y z t) :precision binary64 (+ (* y 5.0) (* x (+ t (+ y (+ z (+ y z)))))))
double code(double x, double y, double z, double t) {
return (y * 5.0) + (x * (t + (y + (z + (y + z)))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (y * 5.0d0) + (x * (t + (y + (z + (y + z)))))
end function
public static double code(double x, double y, double z, double t) {
return (y * 5.0) + (x * (t + (y + (z + (y + z)))));
}
def code(x, y, z, t): return (y * 5.0) + (x * (t + (y + (z + (y + z)))))
function code(x, y, z, t) return Float64(Float64(y * 5.0) + Float64(x * Float64(t + Float64(y + Float64(z + Float64(y + z)))))) end
function tmp = code(x, y, z, t) tmp = (y * 5.0) + (x * (t + (y + (z + (y + z))))); end
code[x_, y_, z_, t_] := N[(N[(y * 5.0), $MachinePrecision] + N[(x * N[(t + N[(y + N[(z + N[(y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot 5 + x \cdot \left(t + \left(y + \left(z + \left(y + z\right)\right)\right)\right)
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z t) :precision binary64 (if (or (<= x -9e-87) (not (<= x 4e-29))) (* x t) (* y 5.0)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -9e-87) || !(x <= 4e-29)) {
tmp = x * t;
} else {
tmp = y * 5.0;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((x <= (-9d-87)) .or. (.not. (x <= 4d-29))) then
tmp = x * t
else
tmp = y * 5.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -9e-87) || !(x <= 4e-29)) {
tmp = x * t;
} else {
tmp = y * 5.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -9e-87) or not (x <= 4e-29): tmp = x * t else: tmp = y * 5.0 return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -9e-87) || !(x <= 4e-29)) tmp = Float64(x * t); else tmp = Float64(y * 5.0); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -9e-87) || ~((x <= 4e-29))) tmp = x * t; else tmp = y * 5.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -9e-87], N[Not[LessEqual[x, 4e-29]], $MachinePrecision]], N[(x * t), $MachinePrecision], N[(y * 5.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9 \cdot 10^{-87} \lor \neg \left(x \leq 4 \cdot 10^{-29}\right):\\
\;\;\;\;x \cdot t\\
\mathbf{else}:\\
\;\;\;\;y \cdot 5\\
\end{array}
\end{array}
if x < -8.99999999999999915e-87 or 3.99999999999999977e-29 < x Initial program 100.0%
fma-def100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around inf 94.4%
Taylor expanded in t around inf 37.7%
*-commutative37.7%
Simplified37.7%
if -8.99999999999999915e-87 < x < 3.99999999999999977e-29Initial program 100.0%
Taylor expanded in x around 0 61.0%
Simplified61.0%
Final simplification48.0%
(FPCore (x y z t) :precision binary64 (* x t))
double code(double x, double y, double z, double t) {
return x * t;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x * t
end function
public static double code(double x, double y, double z, double t) {
return x * t;
}
def code(x, y, z, t): return x * t
function code(x, y, z, t) return Float64(x * t) end
function tmp = code(x, y, z, t) tmp = x * t; end
code[x_, y_, z_, t_] := N[(x * t), $MachinePrecision]
\begin{array}{l}
\\
x \cdot t
\end{array}
Initial program 100.0%
fma-def100.0%
associate-+l+100.0%
+-commutative100.0%
count-2100.0%
Simplified100.0%
Taylor expanded in x around inf 70.6%
Taylor expanded in t around inf 30.0%
*-commutative30.0%
Simplified30.0%
Final simplification30.0%
herbie shell --seed 2024031
(FPCore (x y z t)
:name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendOutside from plot-0.2.3.4, B"
:precision binary64
(+ (* x (+ (+ (+ (+ y z) z) y) t)) (* y 5.0)))