
(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 11 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 99.9%
+-commutative99.9%
fma-def100.0%
distribute-rgt-in96.5%
associate-+l+96.4%
+-commutative96.4%
count-296.4%
distribute-rgt-in100.0%
*-commutative100.0%
fma-def100.0%
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 99.9%
fma-def99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ (* y 5.0) (* 2.0 (* x z)))) (t_2 (* x (+ t (* (+ y z) 2.0)))))
(if (<= x -0.000145)
t_2
(if (<= x -1.75e-74)
t_1
(if (<= x -2.4e-87)
(* x (+ t (* z 2.0)))
(if (<= x 3.2e-50) t_1 t_2))))))
double code(double x, double y, double z, double t) {
double t_1 = (y * 5.0) + (2.0 * (x * z));
double t_2 = x * (t + ((y + z) * 2.0));
double tmp;
if (x <= -0.000145) {
tmp = t_2;
} else if (x <= -1.75e-74) {
tmp = t_1;
} else if (x <= -2.4e-87) {
tmp = x * (t + (z * 2.0));
} else if (x <= 3.2e-50) {
tmp = t_1;
} else {
tmp = t_2;
}
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 = (y * 5.0d0) + (2.0d0 * (x * z))
t_2 = x * (t + ((y + z) * 2.0d0))
if (x <= (-0.000145d0)) then
tmp = t_2
else if (x <= (-1.75d-74)) then
tmp = t_1
else if (x <= (-2.4d-87)) then
tmp = x * (t + (z * 2.0d0))
else if (x <= 3.2d-50) then
tmp = t_1
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (y * 5.0) + (2.0 * (x * z));
double t_2 = x * (t + ((y + z) * 2.0));
double tmp;
if (x <= -0.000145) {
tmp = t_2;
} else if (x <= -1.75e-74) {
tmp = t_1;
} else if (x <= -2.4e-87) {
tmp = x * (t + (z * 2.0));
} else if (x <= 3.2e-50) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t): t_1 = (y * 5.0) + (2.0 * (x * z)) t_2 = x * (t + ((y + z) * 2.0)) tmp = 0 if x <= -0.000145: tmp = t_2 elif x <= -1.75e-74: tmp = t_1 elif x <= -2.4e-87: tmp = x * (t + (z * 2.0)) elif x <= 3.2e-50: tmp = t_1 else: tmp = t_2 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(y * 5.0) + Float64(2.0 * Float64(x * z))) t_2 = Float64(x * Float64(t + Float64(Float64(y + z) * 2.0))) tmp = 0.0 if (x <= -0.000145) tmp = t_2; elseif (x <= -1.75e-74) tmp = t_1; elseif (x <= -2.4e-87) tmp = Float64(x * Float64(t + Float64(z * 2.0))); elseif (x <= 3.2e-50) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (y * 5.0) + (2.0 * (x * z)); t_2 = x * (t + ((y + z) * 2.0)); tmp = 0.0; if (x <= -0.000145) tmp = t_2; elseif (x <= -1.75e-74) tmp = t_1; elseif (x <= -2.4e-87) tmp = x * (t + (z * 2.0)); elseif (x <= 3.2e-50) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y * 5.0), $MachinePrecision] + N[(2.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x * N[(t + N[(N[(y + z), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -0.000145], t$95$2, If[LessEqual[x, -1.75e-74], t$95$1, If[LessEqual[x, -2.4e-87], N[(x * N[(t + N[(z * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.2e-50], t$95$1, t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot 5 + 2 \cdot \left(x \cdot z\right)\\
t_2 := x \cdot \left(t + \left(y + z\right) \cdot 2\right)\\
\mathbf{if}\;x \leq -0.000145:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq -1.75 \cdot 10^{-74}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -2.4 \cdot 10^{-87}:\\
\;\;\;\;x \cdot \left(t + z \cdot 2\right)\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{-50}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if x < -1.45e-4 or 3.2e-50 < x Initial program 99.9%
fma-def99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in x around inf 97.1%
if -1.45e-4 < x < -1.75000000000000007e-74 or -2.4e-87 < x < 3.2e-50Initial program 99.8%
Taylor expanded in y around 0 98.7%
Simplified98.7%
Taylor expanded in t around 0 89.0%
if -1.75000000000000007e-74 < x < -2.4e-87Initial program 100.0%
Taylor expanded in y around 0 100.0%
Final simplification93.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* 2.0 (* x z))) (t_2 (* y (+ 5.0 (* x 2.0)))))
(if (<= z -7.2e+147)
t_1
(if (<= z -4.1e-308)
t_2
(if (<= z 7.4e-298) (* x t) (if (<= z 5.8e+37) t_2 t_1))))))
double code(double x, double y, double z, double t) {
double t_1 = 2.0 * (x * z);
double t_2 = y * (5.0 + (x * 2.0));
double tmp;
if (z <= -7.2e+147) {
tmp = t_1;
} else if (z <= -4.1e-308) {
tmp = t_2;
} else if (z <= 7.4e-298) {
tmp = x * t;
} else if (z <= 5.8e+37) {
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 = 2.0d0 * (x * z)
t_2 = y * (5.0d0 + (x * 2.0d0))
if (z <= (-7.2d+147)) then
tmp = t_1
else if (z <= (-4.1d-308)) then
tmp = t_2
else if (z <= 7.4d-298) then
tmp = x * t
else if (z <= 5.8d+37) 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 = 2.0 * (x * z);
double t_2 = y * (5.0 + (x * 2.0));
double tmp;
if (z <= -7.2e+147) {
tmp = t_1;
} else if (z <= -4.1e-308) {
tmp = t_2;
} else if (z <= 7.4e-298) {
tmp = x * t;
} else if (z <= 5.8e+37) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = 2.0 * (x * z) t_2 = y * (5.0 + (x * 2.0)) tmp = 0 if z <= -7.2e+147: tmp = t_1 elif z <= -4.1e-308: tmp = t_2 elif z <= 7.4e-298: tmp = x * t elif z <= 5.8e+37: tmp = t_2 else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(2.0 * Float64(x * z)) t_2 = Float64(y * Float64(5.0 + Float64(x * 2.0))) tmp = 0.0 if (z <= -7.2e+147) tmp = t_1; elseif (z <= -4.1e-308) tmp = t_2; elseif (z <= 7.4e-298) tmp = Float64(x * t); elseif (z <= 5.8e+37) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = 2.0 * (x * z); t_2 = y * (5.0 + (x * 2.0)); tmp = 0.0; if (z <= -7.2e+147) tmp = t_1; elseif (z <= -4.1e-308) tmp = t_2; elseif (z <= 7.4e-298) tmp = x * t; elseif (z <= 5.8e+37) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(2.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y * N[(5.0 + N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -7.2e+147], t$95$1, If[LessEqual[z, -4.1e-308], t$95$2, If[LessEqual[z, 7.4e-298], N[(x * t), $MachinePrecision], If[LessEqual[z, 5.8e+37], t$95$2, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 2 \cdot \left(x \cdot z\right)\\
t_2 := y \cdot \left(5 + x \cdot 2\right)\\
\mathbf{if}\;z \leq -7.2 \cdot 10^{+147}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -4.1 \cdot 10^{-308}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;z \leq 7.4 \cdot 10^{-298}:\\
\;\;\;\;x \cdot t\\
\mathbf{elif}\;z \leq 5.8 \cdot 10^{+37}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if z < -7.20000000000000041e147 or 5.79999999999999957e37 < z Initial program 99.9%
Taylor expanded in z around inf 66.0%
if -7.20000000000000041e147 < z < -4.09999999999999983e-308 or 7.3999999999999996e-298 < z < 5.79999999999999957e37Initial program 99.9%
fma-def99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in y around inf 61.6%
if -4.09999999999999983e-308 < z < 7.3999999999999996e-298Initial program 100.0%
Taylor expanded in t around inf 100.0%
Final simplification63.9%
(FPCore (x y z t) :precision binary64 (if (or (<= x -7.4e+18) (not (<= x 2.5))) (* x (+ t (* (+ y z) 2.0))) (+ (* x (+ t (+ z z))) (* y 5.0))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -7.4e+18) || !(x <= 2.5)) {
tmp = x * (t + ((y + z) * 2.0));
} else {
tmp = (x * (t + (z + z))) + (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 <= (-7.4d+18)) .or. (.not. (x <= 2.5d0))) then
tmp = x * (t + ((y + z) * 2.0d0))
else
tmp = (x * (t + (z + z))) + (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 <= -7.4e+18) || !(x <= 2.5)) {
tmp = x * (t + ((y + z) * 2.0));
} else {
tmp = (x * (t + (z + z))) + (y * 5.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -7.4e+18) or not (x <= 2.5): tmp = x * (t + ((y + z) * 2.0)) else: tmp = (x * (t + (z + z))) + (y * 5.0) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -7.4e+18) || !(x <= 2.5)) tmp = Float64(x * Float64(t + Float64(Float64(y + z) * 2.0))); else tmp = Float64(Float64(x * Float64(t + Float64(z + z))) + Float64(y * 5.0)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -7.4e+18) || ~((x <= 2.5))) tmp = x * (t + ((y + z) * 2.0)); else tmp = (x * (t + (z + z))) + (y * 5.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -7.4e+18], N[Not[LessEqual[x, 2.5]], $MachinePrecision]], N[(x * N[(t + N[(N[(y + z), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(t + N[(z + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * 5.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.4 \cdot 10^{+18} \lor \neg \left(x \leq 2.5\right):\\
\;\;\;\;x \cdot \left(t + \left(y + z\right) \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(t + \left(z + z\right)\right) + y \cdot 5\\
\end{array}
\end{array}
if x < -7.4e18 or 2.5 < 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 99.5%
if -7.4e18 < x < 2.5Initial program 99.8%
Taylor expanded in y around 0 97.5%
Simplified97.5%
Final simplification98.5%
(FPCore (x y z t) :precision binary64 (+ (* x (+ t (+ y (+ z (+ y z))))) (* y 5.0)))
double code(double x, double y, double z, double t) {
return (x * (t + (y + (z + (y + z))))) + (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 * (t + (y + (z + (y + z))))) + (y * 5.0d0)
end function
public static double code(double x, double y, double z, double t) {
return (x * (t + (y + (z + (y + z))))) + (y * 5.0);
}
def code(x, y, z, t): return (x * (t + (y + (z + (y + z))))) + (y * 5.0)
function code(x, y, z, t) return Float64(Float64(x * Float64(t + Float64(y + Float64(z + Float64(y + z))))) + Float64(y * 5.0)) end
function tmp = code(x, y, z, t) tmp = (x * (t + (y + (z + (y + z))))) + (y * 5.0); end
code[x_, y_, z_, t_] := N[(N[(x * N[(t + N[(y + N[(z + N[(y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * 5.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(t + \left(y + \left(z + \left(y + z\right)\right)\right)\right) + y \cdot 5
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z t) :precision binary64 (if (or (<= x -0.006) (not (<= x 4.6e-76))) (* 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 <= -0.006) || !(x <= 4.6e-76)) {
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 <= (-0.006d0)) .or. (.not. (x <= 4.6d-76))) 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 <= -0.006) || !(x <= 4.6e-76)) {
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 <= -0.006) or not (x <= 4.6e-76): 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 <= -0.006) || !(x <= 4.6e-76)) 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 <= -0.006) || ~((x <= 4.6e-76))) 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, -0.006], N[Not[LessEqual[x, 4.6e-76]], $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 -0.006 \lor \neg \left(x \leq 4.6 \cdot 10^{-76}\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 < -0.0060000000000000001 or 4.60000000000000012e-76 < x Initial program 99.9%
fma-def99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in x around inf 95.8%
if -0.0060000000000000001 < x < 4.60000000000000012e-76Initial program 99.9%
Taylor expanded in y around 0 98.7%
Simplified98.7%
Taylor expanded in z around 0 72.3%
Final simplification85.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* 2.0 (* x z))))
(if (<= z -3e-15)
t_1
(if (<= z -8e-106) (* y 5.0) (if (<= z 2.8e-39) (* x t) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = 2.0 * (x * z);
double tmp;
if (z <= -3e-15) {
tmp = t_1;
} else if (z <= -8e-106) {
tmp = y * 5.0;
} else if (z <= 2.8e-39) {
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 = 2.0d0 * (x * z)
if (z <= (-3d-15)) then
tmp = t_1
else if (z <= (-8d-106)) then
tmp = y * 5.0d0
else if (z <= 2.8d-39) 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 = 2.0 * (x * z);
double tmp;
if (z <= -3e-15) {
tmp = t_1;
} else if (z <= -8e-106) {
tmp = y * 5.0;
} else if (z <= 2.8e-39) {
tmp = x * t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = 2.0 * (x * z) tmp = 0 if z <= -3e-15: tmp = t_1 elif z <= -8e-106: tmp = y * 5.0 elif z <= 2.8e-39: tmp = x * t else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(2.0 * Float64(x * z)) tmp = 0.0 if (z <= -3e-15) tmp = t_1; elseif (z <= -8e-106) tmp = Float64(y * 5.0); elseif (z <= 2.8e-39) tmp = Float64(x * t); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = 2.0 * (x * z); tmp = 0.0; if (z <= -3e-15) tmp = t_1; elseif (z <= -8e-106) tmp = y * 5.0; elseif (z <= 2.8e-39) tmp = x * t; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(2.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3e-15], t$95$1, If[LessEqual[z, -8e-106], N[(y * 5.0), $MachinePrecision], If[LessEqual[z, 2.8e-39], N[(x * t), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 2 \cdot \left(x \cdot z\right)\\
\mathbf{if}\;z \leq -3 \cdot 10^{-15}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -8 \cdot 10^{-106}:\\
\;\;\;\;y \cdot 5\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{-39}:\\
\;\;\;\;x \cdot t\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if z < -3e-15 or 2.8000000000000001e-39 < z Initial program 99.9%
Taylor expanded in z around inf 53.2%
if -3e-15 < z < -7.99999999999999953e-106Initial program 99.9%
Taylor expanded in x around 0 53.1%
if -7.99999999999999953e-106 < z < 2.8000000000000001e-39Initial program 99.9%
Taylor expanded in t around inf 42.6%
Final simplification49.2%
(FPCore (x y z t) :precision binary64 (if (or (<= y -2e+35) (not (<= y 4.7e+61))) (* 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 <= -2e+35) || !(y <= 4.7e+61)) {
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 <= (-2d+35)) .or. (.not. (y <= 4.7d+61))) 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 <= -2e+35) || !(y <= 4.7e+61)) {
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 <= -2e+35) or not (y <= 4.7e+61): 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 <= -2e+35) || !(y <= 4.7e+61)) 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 <= -2e+35) || ~((y <= 4.7e+61))) 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, -2e+35], N[Not[LessEqual[y, 4.7e+61]], $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 \cdot 10^{+35} \lor \neg \left(y \leq 4.7 \cdot 10^{+61}\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 < -1.9999999999999999e35 or 4.6999999999999998e61 < y Initial program 99.9%
fma-def99.9%
associate-+l+99.9%
+-commutative99.9%
count-299.9%
Simplified99.9%
Taylor expanded in y around inf 79.7%
if -1.9999999999999999e35 < y < 4.6999999999999998e61Initial program 99.9%
Taylor expanded in y around 0 78.3%
Final simplification78.9%
(FPCore (x y z t) :precision binary64 (if (<= x -0.00075) (* x t) (if (<= x 0.6) (* y 5.0) (* x t))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -0.00075) {
tmp = x * t;
} else if (x <= 0.6) {
tmp = y * 5.0;
} else {
tmp = 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 <= (-0.00075d0)) then
tmp = x * t
else if (x <= 0.6d0) then
tmp = y * 5.0d0
else
tmp = x * t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -0.00075) {
tmp = x * t;
} else if (x <= 0.6) {
tmp = y * 5.0;
} else {
tmp = x * t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -0.00075: tmp = x * t elif x <= 0.6: tmp = y * 5.0 else: tmp = x * t return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -0.00075) tmp = Float64(x * t); elseif (x <= 0.6) tmp = Float64(y * 5.0); else tmp = Float64(x * t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -0.00075) tmp = x * t; elseif (x <= 0.6) tmp = y * 5.0; else tmp = x * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -0.00075], N[(x * t), $MachinePrecision], If[LessEqual[x, 0.6], N[(y * 5.0), $MachinePrecision], N[(x * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.00075:\\
\;\;\;\;x \cdot t\\
\mathbf{elif}\;x \leq 0.6:\\
\;\;\;\;y \cdot 5\\
\mathbf{else}:\\
\;\;\;\;x \cdot t\\
\end{array}
\end{array}
if x < -7.5000000000000002e-4 or 0.599999999999999978 < x Initial program 100.0%
Taylor expanded in t around inf 38.4%
if -7.5000000000000002e-4 < x < 0.599999999999999978Initial program 99.8%
Taylor expanded in x around 0 55.1%
Final simplification46.5%
(FPCore (x y z t) :precision binary64 (* y 5.0))
double code(double x, double y, double z, double t) {
return 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 = y * 5.0d0
end function
public static double code(double x, double y, double z, double t) {
return y * 5.0;
}
def code(x, y, z, t): return y * 5.0
function code(x, y, z, t) return Float64(y * 5.0) end
function tmp = code(x, y, z, t) tmp = y * 5.0; end
code[x_, y_, z_, t_] := N[(y * 5.0), $MachinePrecision]
\begin{array}{l}
\\
y \cdot 5
\end{array}
Initial program 99.9%
Taylor expanded in x around 0 28.2%
Final simplification28.2%
herbie shell --seed 2023195
(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)))