
(FPCore (x y z t) :precision binary64 (- (* x x) (* (* y 4.0) (- (* z z) t))))
double code(double x, double y, double z, double t) {
return (x * x) - ((y * 4.0) * ((z * z) - 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 * x) - ((y * 4.0d0) * ((z * z) - t))
end function
public static double code(double x, double y, double z, double t) {
return (x * x) - ((y * 4.0) * ((z * z) - t));
}
def code(x, y, z, t): return (x * x) - ((y * 4.0) * ((z * z) - t))
function code(x, y, z, t) return Float64(Float64(x * x) - Float64(Float64(y * 4.0) * Float64(Float64(z * z) - t))) end
function tmp = code(x, y, z, t) tmp = (x * x) - ((y * 4.0) * ((z * z) - t)); end
code[x_, y_, z_, t_] := N[(N[(x * x), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (- (* x x) (* (* y 4.0) (- (* z z) t))))
double code(double x, double y, double z, double t) {
return (x * x) - ((y * 4.0) * ((z * z) - 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 * x) - ((y * 4.0d0) * ((z * z) - t))
end function
public static double code(double x, double y, double z, double t) {
return (x * x) - ((y * 4.0) * ((z * z) - t));
}
def code(x, y, z, t): return (x * x) - ((y * 4.0) * ((z * z) - t))
function code(x, y, z, t) return Float64(Float64(x * x) - Float64(Float64(y * 4.0) * Float64(Float64(z * z) - t))) end
function tmp = code(x, y, z, t) tmp = (x * x) - ((y * 4.0) * ((z * z) - t)); end
code[x_, y_, z_, t_] := N[(N[(x * x), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\end{array}
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* z z) t)))
(if (<= t_1 4e+291)
(fma x x (* t_1 (* y -4.0)))
(+ (* (* z y) (* z -4.0)) (* x x)))))
double code(double x, double y, double z, double t) {
double t_1 = (z * z) - t;
double tmp;
if (t_1 <= 4e+291) {
tmp = fma(x, x, (t_1 * (y * -4.0)));
} else {
tmp = ((z * y) * (z * -4.0)) + (x * x);
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(z * z) - t) tmp = 0.0 if (t_1 <= 4e+291) tmp = fma(x, x, Float64(t_1 * Float64(y * -4.0))); else tmp = Float64(Float64(Float64(z * y) * Float64(z * -4.0)) + Float64(x * x)); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision]}, If[LessEqual[t$95$1, 4e+291], N[(x * x + N[(t$95$1 * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z * y), $MachinePrecision] * N[(z * -4.0), $MachinePrecision]), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot z - t\\
\mathbf{if}\;t_1 \leq 4 \cdot 10^{+291}:\\
\;\;\;\;\mathsf{fma}\left(x, x, t_1 \cdot \left(y \cdot -4\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot y\right) \cdot \left(z \cdot -4\right) + x \cdot x\\
\end{array}
\end{array}
if (-.f64 (*.f64 z z) t) < 3.9999999999999998e291Initial program 98.3%
fma-neg99.4%
*-commutative99.4%
distribute-rgt-neg-in99.4%
distribute-rgt-neg-in99.4%
metadata-eval99.4%
Simplified99.4%
if 3.9999999999999998e291 < (-.f64 (*.f64 z z) t) Initial program 71.7%
Taylor expanded in t around 0 73.0%
unpow273.0%
fma-neg81.4%
distribute-lft-neg-in81.4%
metadata-eval81.4%
*-commutative81.4%
unpow281.4%
associate-*l*81.4%
Simplified81.4%
fma-udef73.0%
+-commutative73.0%
associate-*l*73.0%
associate-*r*88.8%
Applied egg-rr88.8%
Final simplification96.5%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (* t 4.0))) (t_2 (* z (* y (* z -4.0)))))
(if (<= x 4.5e-248)
t_2
(if (<= x 6.4e-146)
t_1
(if (<= x 2e-131)
t_2
(if (<= x 4.7e-104)
t_1
(if (or (<= x 9.8e-26) (and (not (<= x 2.2e+60)) (<= x 5.4e+107)))
t_2
(* x x))))))))
double code(double x, double y, double z, double t) {
double t_1 = y * (t * 4.0);
double t_2 = z * (y * (z * -4.0));
double tmp;
if (x <= 4.5e-248) {
tmp = t_2;
} else if (x <= 6.4e-146) {
tmp = t_1;
} else if (x <= 2e-131) {
tmp = t_2;
} else if (x <= 4.7e-104) {
tmp = t_1;
} else if ((x <= 9.8e-26) || (!(x <= 2.2e+60) && (x <= 5.4e+107))) {
tmp = t_2;
} else {
tmp = x * x;
}
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 * (t * 4.0d0)
t_2 = z * (y * (z * (-4.0d0)))
if (x <= 4.5d-248) then
tmp = t_2
else if (x <= 6.4d-146) then
tmp = t_1
else if (x <= 2d-131) then
tmp = t_2
else if (x <= 4.7d-104) then
tmp = t_1
else if ((x <= 9.8d-26) .or. (.not. (x <= 2.2d+60)) .and. (x <= 5.4d+107)) then
tmp = t_2
else
tmp = x * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = y * (t * 4.0);
double t_2 = z * (y * (z * -4.0));
double tmp;
if (x <= 4.5e-248) {
tmp = t_2;
} else if (x <= 6.4e-146) {
tmp = t_1;
} else if (x <= 2e-131) {
tmp = t_2;
} else if (x <= 4.7e-104) {
tmp = t_1;
} else if ((x <= 9.8e-26) || (!(x <= 2.2e+60) && (x <= 5.4e+107))) {
tmp = t_2;
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): t_1 = y * (t * 4.0) t_2 = z * (y * (z * -4.0)) tmp = 0 if x <= 4.5e-248: tmp = t_2 elif x <= 6.4e-146: tmp = t_1 elif x <= 2e-131: tmp = t_2 elif x <= 4.7e-104: tmp = t_1 elif (x <= 9.8e-26) or (not (x <= 2.2e+60) and (x <= 5.4e+107)): tmp = t_2 else: tmp = x * x return tmp
function code(x, y, z, t) t_1 = Float64(y * Float64(t * 4.0)) t_2 = Float64(z * Float64(y * Float64(z * -4.0))) tmp = 0.0 if (x <= 4.5e-248) tmp = t_2; elseif (x <= 6.4e-146) tmp = t_1; elseif (x <= 2e-131) tmp = t_2; elseif (x <= 4.7e-104) tmp = t_1; elseif ((x <= 9.8e-26) || (!(x <= 2.2e+60) && (x <= 5.4e+107))) tmp = t_2; else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = y * (t * 4.0); t_2 = z * (y * (z * -4.0)); tmp = 0.0; if (x <= 4.5e-248) tmp = t_2; elseif (x <= 6.4e-146) tmp = t_1; elseif (x <= 2e-131) tmp = t_2; elseif (x <= 4.7e-104) tmp = t_1; elseif ((x <= 9.8e-26) || (~((x <= 2.2e+60)) && (x <= 5.4e+107))) tmp = t_2; else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(t * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(z * N[(y * N[(z * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 4.5e-248], t$95$2, If[LessEqual[x, 6.4e-146], t$95$1, If[LessEqual[x, 2e-131], t$95$2, If[LessEqual[x, 4.7e-104], t$95$1, If[Or[LessEqual[x, 9.8e-26], And[N[Not[LessEqual[x, 2.2e+60]], $MachinePrecision], LessEqual[x, 5.4e+107]]], t$95$2, N[(x * x), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(t \cdot 4\right)\\
t_2 := z \cdot \left(y \cdot \left(z \cdot -4\right)\right)\\
\mathbf{if}\;x \leq 4.5 \cdot 10^{-248}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 6.4 \cdot 10^{-146}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-131}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 4.7 \cdot 10^{-104}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 9.8 \cdot 10^{-26} \lor \neg \left(x \leq 2.2 \cdot 10^{+60}\right) \land x \leq 5.4 \cdot 10^{+107}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if x < 4.4999999999999996e-248 or 6.3999999999999998e-146 < x < 2e-131 or 4.7e-104 < x < 9.7999999999999998e-26 or 2.19999999999999996e60 < x < 5.4000000000000003e107Initial program 93.2%
Taylor expanded in z around inf 43.7%
*-commutative43.7%
unpow243.7%
associate-*l*43.7%
Simplified43.7%
Taylor expanded in y around 0 43.7%
*-commutative43.7%
unpow243.7%
associate-*r*45.1%
associate-*r*45.1%
*-commutative45.1%
associate-*l*45.1%
*-commutative45.1%
Simplified45.1%
if 4.4999999999999996e-248 < x < 6.3999999999999998e-146 or 2e-131 < x < 4.7e-104Initial program 91.1%
Taylor expanded in t around inf 67.7%
associate-*r*67.7%
*-commutative67.7%
Simplified67.7%
if 9.7999999999999998e-26 < x < 2.19999999999999996e60 or 5.4000000000000003e107 < x Initial program 84.5%
Taylor expanded in x around inf 75.5%
unpow275.5%
Simplified75.5%
Final simplification54.6%
(FPCore (x y z t)
:precision binary64
(if (or (<= (* x x) 1.8e-46)
(and (not (<= (* x x) 2.2e+110)) (<= (* x x) 7.5e+216)))
(* (- (* z z) t) (* y -4.0))
(* x x)))
double code(double x, double y, double z, double t) {
double tmp;
if (((x * x) <= 1.8e-46) || (!((x * x) <= 2.2e+110) && ((x * x) <= 7.5e+216))) {
tmp = ((z * z) - t) * (y * -4.0);
} else {
tmp = x * x;
}
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 * x) <= 1.8d-46) .or. (.not. ((x * x) <= 2.2d+110)) .and. ((x * x) <= 7.5d+216)) then
tmp = ((z * z) - t) * (y * (-4.0d0))
else
tmp = x * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((x * x) <= 1.8e-46) || (!((x * x) <= 2.2e+110) && ((x * x) <= 7.5e+216))) {
tmp = ((z * z) - t) * (y * -4.0);
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x * x) <= 1.8e-46) or (not ((x * x) <= 2.2e+110) and ((x * x) <= 7.5e+216)): tmp = ((z * z) - t) * (y * -4.0) else: tmp = x * x return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(x * x) <= 1.8e-46) || (!(Float64(x * x) <= 2.2e+110) && (Float64(x * x) <= 7.5e+216))) tmp = Float64(Float64(Float64(z * z) - t) * Float64(y * -4.0)); else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((x * x) <= 1.8e-46) || (~(((x * x) <= 2.2e+110)) && ((x * x) <= 7.5e+216))) tmp = ((z * z) - t) * (y * -4.0); else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x * x), $MachinePrecision], 1.8e-46], And[N[Not[LessEqual[N[(x * x), $MachinePrecision], 2.2e+110]], $MachinePrecision], LessEqual[N[(x * x), $MachinePrecision], 7.5e+216]]], N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(y * -4.0), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 1.8 \cdot 10^{-46} \lor \neg \left(x \cdot x \leq 2.2 \cdot 10^{+110}\right) \land x \cdot x \leq 7.5 \cdot 10^{+216}:\\
\;\;\;\;\left(z \cdot z - t\right) \cdot \left(y \cdot -4\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 1.8e-46 or 2.19999999999999992e110 < (*.f64 x x) < 7.4999999999999994e216Initial program 96.6%
Taylor expanded in x around 0 92.1%
associate-*r*92.1%
unpow292.1%
*-commutative92.1%
*-commutative92.1%
Simplified92.1%
if 1.8e-46 < (*.f64 x x) < 2.19999999999999992e110 or 7.4999999999999994e216 < (*.f64 x x) Initial program 84.6%
Taylor expanded in x around inf 78.6%
unpow278.6%
Simplified78.6%
Final simplification85.6%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (* (* z z) -4.0))) (t_2 (* y (* t 4.0))))
(if (<= x 6e-147)
t_2
(if (<= x 1.65e-131)
t_1
(if (<= x 3.6e-103)
t_2
(if (or (<= x 3.2e-25) (and (not (<= x 2e+61)) (<= x 4.5e+107)))
t_1
(* x x)))))))
double code(double x, double y, double z, double t) {
double t_1 = y * ((z * z) * -4.0);
double t_2 = y * (t * 4.0);
double tmp;
if (x <= 6e-147) {
tmp = t_2;
} else if (x <= 1.65e-131) {
tmp = t_1;
} else if (x <= 3.6e-103) {
tmp = t_2;
} else if ((x <= 3.2e-25) || (!(x <= 2e+61) && (x <= 4.5e+107))) {
tmp = t_1;
} else {
tmp = x * x;
}
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 * ((z * z) * (-4.0d0))
t_2 = y * (t * 4.0d0)
if (x <= 6d-147) then
tmp = t_2
else if (x <= 1.65d-131) then
tmp = t_1
else if (x <= 3.6d-103) then
tmp = t_2
else if ((x <= 3.2d-25) .or. (.not. (x <= 2d+61)) .and. (x <= 4.5d+107)) then
tmp = t_1
else
tmp = x * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = y * ((z * z) * -4.0);
double t_2 = y * (t * 4.0);
double tmp;
if (x <= 6e-147) {
tmp = t_2;
} else if (x <= 1.65e-131) {
tmp = t_1;
} else if (x <= 3.6e-103) {
tmp = t_2;
} else if ((x <= 3.2e-25) || (!(x <= 2e+61) && (x <= 4.5e+107))) {
tmp = t_1;
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): t_1 = y * ((z * z) * -4.0) t_2 = y * (t * 4.0) tmp = 0 if x <= 6e-147: tmp = t_2 elif x <= 1.65e-131: tmp = t_1 elif x <= 3.6e-103: tmp = t_2 elif (x <= 3.2e-25) or (not (x <= 2e+61) and (x <= 4.5e+107)): tmp = t_1 else: tmp = x * x return tmp
function code(x, y, z, t) t_1 = Float64(y * Float64(Float64(z * z) * -4.0)) t_2 = Float64(y * Float64(t * 4.0)) tmp = 0.0 if (x <= 6e-147) tmp = t_2; elseif (x <= 1.65e-131) tmp = t_1; elseif (x <= 3.6e-103) tmp = t_2; elseif ((x <= 3.2e-25) || (!(x <= 2e+61) && (x <= 4.5e+107))) tmp = t_1; else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = y * ((z * z) * -4.0); t_2 = y * (t * 4.0); tmp = 0.0; if (x <= 6e-147) tmp = t_2; elseif (x <= 1.65e-131) tmp = t_1; elseif (x <= 3.6e-103) tmp = t_2; elseif ((x <= 3.2e-25) || (~((x <= 2e+61)) && (x <= 4.5e+107))) tmp = t_1; else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(N[(z * z), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y * N[(t * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 6e-147], t$95$2, If[LessEqual[x, 1.65e-131], t$95$1, If[LessEqual[x, 3.6e-103], t$95$2, If[Or[LessEqual[x, 3.2e-25], And[N[Not[LessEqual[x, 2e+61]], $MachinePrecision], LessEqual[x, 4.5e+107]]], t$95$1, N[(x * x), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(\left(z \cdot z\right) \cdot -4\right)\\
t_2 := y \cdot \left(t \cdot 4\right)\\
\mathbf{if}\;x \leq 6 \cdot 10^{-147}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{-131}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 3.6 \cdot 10^{-103}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{-25} \lor \neg \left(x \leq 2 \cdot 10^{+61}\right) \land x \leq 4.5 \cdot 10^{+107}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if x < 6.0000000000000004e-147 or 1.6500000000000001e-131 < x < 3.5999999999999998e-103Initial program 92.0%
Taylor expanded in t around inf 40.6%
associate-*r*40.6%
*-commutative40.6%
Simplified40.6%
if 6.0000000000000004e-147 < x < 1.6500000000000001e-131 or 3.5999999999999998e-103 < x < 3.2000000000000001e-25 or 1.9999999999999999e61 < x < 4.5e107Initial program 97.3%
Taylor expanded in z around inf 67.9%
*-commutative67.9%
unpow267.9%
associate-*l*67.9%
Simplified67.9%
if 3.2000000000000001e-25 < x < 1.9999999999999999e61 or 4.5e107 < x Initial program 84.5%
Taylor expanded in x around inf 75.5%
unpow275.5%
Simplified75.5%
Final simplification52.9%
(FPCore (x y z t) :precision binary64 (if (<= (- (* z z) t) 4e+291) (+ (* x x) (* (* y 4.0) (- t (* z z)))) (+ (* (* z y) (* z -4.0)) (* x x))))
double code(double x, double y, double z, double t) {
double tmp;
if (((z * z) - t) <= 4e+291) {
tmp = (x * x) + ((y * 4.0) * (t - (z * z)));
} else {
tmp = ((z * y) * (z * -4.0)) + (x * x);
}
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 (((z * z) - t) <= 4d+291) then
tmp = (x * x) + ((y * 4.0d0) * (t - (z * z)))
else
tmp = ((z * y) * (z * (-4.0d0))) + (x * x)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((z * z) - t) <= 4e+291) {
tmp = (x * x) + ((y * 4.0) * (t - (z * z)));
} else {
tmp = ((z * y) * (z * -4.0)) + (x * x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((z * z) - t) <= 4e+291: tmp = (x * x) + ((y * 4.0) * (t - (z * z))) else: tmp = ((z * y) * (z * -4.0)) + (x * x) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(z * z) - t) <= 4e+291) tmp = Float64(Float64(x * x) + Float64(Float64(y * 4.0) * Float64(t - Float64(z * z)))); else tmp = Float64(Float64(Float64(z * y) * Float64(z * -4.0)) + Float64(x * x)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((z * z) - t) <= 4e+291) tmp = (x * x) + ((y * 4.0) * (t - (z * z))); else tmp = ((z * y) * (z * -4.0)) + (x * x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision], 4e+291], N[(N[(x * x), $MachinePrecision] + N[(N[(y * 4.0), $MachinePrecision] * N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z * y), $MachinePrecision] * N[(z * -4.0), $MachinePrecision]), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z - t \leq 4 \cdot 10^{+291}:\\
\;\;\;\;x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot y\right) \cdot \left(z \cdot -4\right) + x \cdot x\\
\end{array}
\end{array}
if (-.f64 (*.f64 z z) t) < 3.9999999999999998e291Initial program 98.3%
if 3.9999999999999998e291 < (-.f64 (*.f64 z z) t) Initial program 71.7%
Taylor expanded in t around 0 73.0%
unpow273.0%
fma-neg81.4%
distribute-lft-neg-in81.4%
metadata-eval81.4%
*-commutative81.4%
unpow281.4%
associate-*l*81.4%
Simplified81.4%
fma-udef73.0%
+-commutative73.0%
associate-*l*73.0%
associate-*r*88.8%
Applied egg-rr88.8%
Final simplification95.7%
(FPCore (x y z t) :precision binary64 (if (<= (* x x) 1e-46) (* (- (* z z) t) (* y -4.0)) (+ (* (* z y) (* z -4.0)) (* x x))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 1e-46) {
tmp = ((z * z) - t) * (y * -4.0);
} else {
tmp = ((z * y) * (z * -4.0)) + (x * x);
}
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 * x) <= 1d-46) then
tmp = ((z * z) - t) * (y * (-4.0d0))
else
tmp = ((z * y) * (z * (-4.0d0))) + (x * x)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 1e-46) {
tmp = ((z * z) - t) * (y * -4.0);
} else {
tmp = ((z * y) * (z * -4.0)) + (x * x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x * x) <= 1e-46: tmp = ((z * z) - t) * (y * -4.0) else: tmp = ((z * y) * (z * -4.0)) + (x * x) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x * x) <= 1e-46) tmp = Float64(Float64(Float64(z * z) - t) * Float64(y * -4.0)); else tmp = Float64(Float64(Float64(z * y) * Float64(z * -4.0)) + Float64(x * x)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x * x) <= 1e-46) tmp = ((z * z) - t) * (y * -4.0); else tmp = ((z * y) * (z * -4.0)) + (x * x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x * x), $MachinePrecision], 1e-46], N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(y * -4.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z * y), $MachinePrecision] * N[(z * -4.0), $MachinePrecision]), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 10^{-46}:\\
\;\;\;\;\left(z \cdot z - t\right) \cdot \left(y \cdot -4\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot y\right) \cdot \left(z \cdot -4\right) + x \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 1.00000000000000002e-46Initial program 96.6%
Taylor expanded in x around 0 96.6%
associate-*r*96.6%
unpow296.6%
*-commutative96.6%
*-commutative96.6%
Simplified96.6%
if 1.00000000000000002e-46 < (*.f64 x x) Initial program 86.5%
Taylor expanded in t around 0 78.8%
unpow278.8%
fma-neg83.6%
distribute-lft-neg-in83.6%
metadata-eval83.6%
*-commutative83.6%
unpow283.6%
associate-*l*83.6%
Simplified83.6%
fma-udef78.8%
+-commutative78.8%
associate-*l*78.8%
associate-*r*84.1%
Applied egg-rr84.1%
Final simplification89.4%
(FPCore (x y z t) :precision binary64 (if (<= (* x x) 1.8e-46) (* y (* t 4.0)) (* x x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 1.8e-46) {
tmp = y * (t * 4.0);
} else {
tmp = x * x;
}
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 * x) <= 1.8d-46) then
tmp = y * (t * 4.0d0)
else
tmp = x * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 1.8e-46) {
tmp = y * (t * 4.0);
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x * x) <= 1.8e-46: tmp = y * (t * 4.0) else: tmp = x * x return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x * x) <= 1.8e-46) tmp = Float64(y * Float64(t * 4.0)); else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x * x) <= 1.8e-46) tmp = y * (t * 4.0); else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x * x), $MachinePrecision], 1.8e-46], N[(y * N[(t * 4.0), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 1.8 \cdot 10^{-46}:\\
\;\;\;\;y \cdot \left(t \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 1.8e-46Initial program 96.6%
Taylor expanded in t around inf 54.7%
associate-*r*54.7%
*-commutative54.7%
Simplified54.7%
if 1.8e-46 < (*.f64 x x) Initial program 86.5%
Taylor expanded in x around inf 70.6%
unpow270.6%
Simplified70.6%
Final simplification63.8%
(FPCore (x y z t) :precision binary64 (* x x))
double code(double x, double y, double z, double t) {
return x * x;
}
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 * x
end function
public static double code(double x, double y, double z, double t) {
return x * x;
}
def code(x, y, z, t): return x * x
function code(x, y, z, t) return Float64(x * x) end
function tmp = code(x, y, z, t) tmp = x * x; end
code[x_, y_, z_, t_] := N[(x * x), $MachinePrecision]
\begin{array}{l}
\\
x \cdot x
\end{array}
Initial program 90.8%
Taylor expanded in x around inf 42.8%
unpow242.8%
Simplified42.8%
Final simplification42.8%
(FPCore (x y z t) :precision binary64 (- (* x x) (* 4.0 (* y (- (* z z) t)))))
double code(double x, double y, double z, double t) {
return (x * x) - (4.0 * (y * ((z * z) - 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 * x) - (4.0d0 * (y * ((z * z) - t)))
end function
public static double code(double x, double y, double z, double t) {
return (x * x) - (4.0 * (y * ((z * z) - t)));
}
def code(x, y, z, t): return (x * x) - (4.0 * (y * ((z * z) - t)))
function code(x, y, z, t) return Float64(Float64(x * x) - Float64(4.0 * Float64(y * Float64(Float64(z * z) - t)))) end
function tmp = code(x, y, z, t) tmp = (x * x) - (4.0 * (y * ((z * z) - t))); end
code[x_, y_, z_, t_] := N[(N[(x * x), $MachinePrecision] - N[(4.0 * N[(y * N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot x - 4 \cdot \left(y \cdot \left(z \cdot z - t\right)\right)
\end{array}
herbie shell --seed 2023275
(FPCore (x y z t)
:name "Graphics.Rasterific.Shading:$sradialGradientWithFocusShader from Rasterific-0.6.1, B"
:precision binary64
:herbie-target
(- (* x x) (* 4.0 (* y (- (* z z) t))))
(- (* x x) (* (* y 4.0) (- (* z z) t))))