
(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 9 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 (if (<= (* z z) 2e+301) (fma x x (* (- (* z z) t) (* y -4.0))) (fma (* z y) (* z -4.0) (* x x))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 2e+301) {
tmp = fma(x, x, (((z * z) - t) * (y * -4.0)));
} else {
tmp = fma((z * y), (z * -4.0), (x * x));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 2e+301) tmp = fma(x, x, Float64(Float64(Float64(z * z) - t) * Float64(y * -4.0))); else tmp = fma(Float64(z * y), Float64(z * -4.0), Float64(x * x)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+301], N[(x * x + N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z * y), $MachinePrecision] * N[(z * -4.0), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+301}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(z \cdot z - t\right) \cdot \left(y \cdot -4\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot y, z \cdot -4, x \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 2.00000000000000011e301Initial program 99.0%
fma-neg99.0%
*-commutative99.0%
distribute-rgt-neg-in99.0%
distribute-rgt-neg-in99.0%
metadata-eval99.0%
Simplified99.0%
if 2.00000000000000011e301 < (*.f64 z z) Initial program 75.3%
Taylor expanded in z around inf 75.3%
unpow275.3%
associate-*r*75.3%
*-commutative75.3%
associate-*r*98.0%
*-commutative98.0%
Simplified98.0%
sub-neg98.0%
+-commutative98.0%
distribute-lft-neg-in98.0%
add-sqr-sqrt44.4%
associate-*r*44.4%
associate-*l*44.4%
distribute-lft-neg-in44.4%
metadata-eval44.4%
associate-*l*44.4%
*-commutative44.4%
*-commutative44.4%
associate-*r*44.4%
add-sqr-sqrt98.0%
associate-*r*98.0%
associate-*l*98.0%
*-commutative98.0%
fma-def99.9%
Applied egg-rr99.9%
Final simplification99.2%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 2e+301) (+ (* x x) (* (* y 4.0) (- t (* z z)))) (fma (* z y) (* z -4.0) (* x x))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 2e+301) {
tmp = (x * x) + ((y * 4.0) * (t - (z * z)));
} else {
tmp = fma((z * y), (z * -4.0), (x * x));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 2e+301) tmp = Float64(Float64(x * x) + Float64(Float64(y * 4.0) * Float64(t - Float64(z * z)))); else tmp = fma(Float64(z * y), Float64(z * -4.0), Float64(x * x)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+301], N[(N[(x * x), $MachinePrecision] + N[(N[(y * 4.0), $MachinePrecision] * N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z * y), $MachinePrecision] * N[(z * -4.0), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+301}:\\
\;\;\;\;x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot y, z \cdot -4, x \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 2.00000000000000011e301Initial program 99.0%
if 2.00000000000000011e301 < (*.f64 z z) Initial program 75.3%
Taylor expanded in z around inf 75.3%
unpow275.3%
associate-*r*75.3%
*-commutative75.3%
associate-*r*98.0%
*-commutative98.0%
Simplified98.0%
sub-neg98.0%
+-commutative98.0%
distribute-lft-neg-in98.0%
add-sqr-sqrt44.4%
associate-*r*44.4%
associate-*l*44.4%
distribute-lft-neg-in44.4%
metadata-eval44.4%
associate-*l*44.4%
*-commutative44.4%
*-commutative44.4%
associate-*r*44.4%
add-sqr-sqrt98.0%
associate-*r*98.0%
associate-*l*98.0%
*-commutative98.0%
fma-def99.9%
Applied egg-rr99.9%
Final simplification99.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* x x) (* t (* y -4.0)))))
(if (<= (* z z) 5e+122)
t_1
(if (<= (* z z) 5e+158)
(* (- (* z z) t) (* y -4.0))
(if (<= (* z z) 4e+231) t_1 (* z (* z (* y -4.0))))))))
double code(double x, double y, double z, double t) {
double t_1 = (x * x) - (t * (y * -4.0));
double tmp;
if ((z * z) <= 5e+122) {
tmp = t_1;
} else if ((z * z) <= 5e+158) {
tmp = ((z * z) - t) * (y * -4.0);
} else if ((z * z) <= 4e+231) {
tmp = t_1;
} else {
tmp = z * (z * (y * -4.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) :: t_1
real(8) :: tmp
t_1 = (x * x) - (t * (y * (-4.0d0)))
if ((z * z) <= 5d+122) then
tmp = t_1
else if ((z * z) <= 5d+158) then
tmp = ((z * z) - t) * (y * (-4.0d0))
else if ((z * z) <= 4d+231) then
tmp = t_1
else
tmp = z * (z * (y * (-4.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (x * x) - (t * (y * -4.0));
double tmp;
if ((z * z) <= 5e+122) {
tmp = t_1;
} else if ((z * z) <= 5e+158) {
tmp = ((z * z) - t) * (y * -4.0);
} else if ((z * z) <= 4e+231) {
tmp = t_1;
} else {
tmp = z * (z * (y * -4.0));
}
return tmp;
}
def code(x, y, z, t): t_1 = (x * x) - (t * (y * -4.0)) tmp = 0 if (z * z) <= 5e+122: tmp = t_1 elif (z * z) <= 5e+158: tmp = ((z * z) - t) * (y * -4.0) elif (z * z) <= 4e+231: tmp = t_1 else: tmp = z * (z * (y * -4.0)) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x * x) - Float64(t * Float64(y * -4.0))) tmp = 0.0 if (Float64(z * z) <= 5e+122) tmp = t_1; elseif (Float64(z * z) <= 5e+158) tmp = Float64(Float64(Float64(z * z) - t) * Float64(y * -4.0)); elseif (Float64(z * z) <= 4e+231) tmp = t_1; else tmp = Float64(z * Float64(z * Float64(y * -4.0))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x * x) - (t * (y * -4.0)); tmp = 0.0; if ((z * z) <= 5e+122) tmp = t_1; elseif ((z * z) <= 5e+158) tmp = ((z * z) - t) * (y * -4.0); elseif ((z * z) <= 4e+231) tmp = t_1; else tmp = z * (z * (y * -4.0)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] - N[(t * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * z), $MachinePrecision], 5e+122], t$95$1, If[LessEqual[N[(z * z), $MachinePrecision], 5e+158], N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(y * -4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 4e+231], t$95$1, N[(z * N[(z * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot x - t \cdot \left(y \cdot -4\right)\\
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+122}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \cdot z \leq 5 \cdot 10^{+158}:\\
\;\;\;\;\left(z \cdot z - t\right) \cdot \left(y \cdot -4\right)\\
\mathbf{elif}\;z \cdot z \leq 4 \cdot 10^{+231}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 4.99999999999999989e122 or 4.9999999999999996e158 < (*.f64 z z) < 4.0000000000000002e231Initial program 98.8%
Taylor expanded in z around 0 91.2%
*-commutative91.2%
*-commutative91.2%
associate-*l*91.2%
Simplified91.2%
if 4.99999999999999989e122 < (*.f64 z z) < 4.9999999999999996e158Initial program 99.8%
Taylor expanded in x around 0 76.6%
*-commutative76.6%
*-commutative76.6%
unpow276.6%
*-commutative76.6%
associate-*l*76.6%
Simplified76.6%
if 4.0000000000000002e231 < (*.f64 z z) Initial program 81.5%
Taylor expanded in z around inf 76.0%
metadata-eval76.0%
distribute-lft-neg-in76.0%
*-commutative76.0%
unpow276.0%
*-commutative76.0%
associate-*r*76.0%
associate-*l*87.6%
distribute-rgt-neg-in87.6%
distribute-rgt-neg-in87.6%
distribute-rgt-neg-in87.6%
metadata-eval87.6%
Simplified87.6%
Final simplification89.2%
(FPCore (x y z t)
:precision binary64
(if (<= (* x x) 2.4e-11)
(* 4.0 (* t y))
(if (<= (* x x) 2.25e+92)
(* x x)
(if (<= (* x x) 4.5e+157) (* -4.0 (* (* z z) y)) (* x x)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 2.4e-11) {
tmp = 4.0 * (t * y);
} else if ((x * x) <= 2.25e+92) {
tmp = x * x;
} else if ((x * x) <= 4.5e+157) {
tmp = -4.0 * ((z * z) * y);
} 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) <= 2.4d-11) then
tmp = 4.0d0 * (t * y)
else if ((x * x) <= 2.25d+92) then
tmp = x * x
else if ((x * x) <= 4.5d+157) then
tmp = (-4.0d0) * ((z * z) * y)
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) <= 2.4e-11) {
tmp = 4.0 * (t * y);
} else if ((x * x) <= 2.25e+92) {
tmp = x * x;
} else if ((x * x) <= 4.5e+157) {
tmp = -4.0 * ((z * z) * y);
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x * x) <= 2.4e-11: tmp = 4.0 * (t * y) elif (x * x) <= 2.25e+92: tmp = x * x elif (x * x) <= 4.5e+157: tmp = -4.0 * ((z * z) * y) else: tmp = x * x return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x * x) <= 2.4e-11) tmp = Float64(4.0 * Float64(t * y)); elseif (Float64(x * x) <= 2.25e+92) tmp = Float64(x * x); elseif (Float64(x * x) <= 4.5e+157) tmp = Float64(-4.0 * Float64(Float64(z * z) * y)); else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x * x) <= 2.4e-11) tmp = 4.0 * (t * y); elseif ((x * x) <= 2.25e+92) tmp = x * x; elseif ((x * x) <= 4.5e+157) tmp = -4.0 * ((z * z) * y); else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x * x), $MachinePrecision], 2.4e-11], N[(4.0 * N[(t * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 2.25e+92], N[(x * x), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 4.5e+157], N[(-4.0 * N[(N[(z * z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2.4 \cdot 10^{-11}:\\
\;\;\;\;4 \cdot \left(t \cdot y\right)\\
\mathbf{elif}\;x \cdot x \leq 2.25 \cdot 10^{+92}:\\
\;\;\;\;x \cdot x\\
\mathbf{elif}\;x \cdot x \leq 4.5 \cdot 10^{+157}:\\
\;\;\;\;-4 \cdot \left(\left(z \cdot z\right) \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 2.4000000000000001e-11Initial program 93.4%
Taylor expanded in t around inf 55.5%
if 2.4000000000000001e-11 < (*.f64 x x) < 2.25e92 or 4.49999999999999985e157 < (*.f64 x x) Initial program 94.1%
Taylor expanded in x around inf 79.8%
unpow279.8%
Simplified79.8%
if 2.25e92 < (*.f64 x x) < 4.49999999999999985e157Initial program 100.0%
Taylor expanded in z around inf 64.7%
unpow264.7%
Simplified64.7%
Final simplification66.9%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 2e+301) (+ (* x x) (* (* y 4.0) (- t (* z z)))) (- (* x x) (* z (* z (* y 4.0))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 2e+301) {
tmp = (x * x) + ((y * 4.0) * (t - (z * z)));
} else {
tmp = (x * x) - (z * (z * (y * 4.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 ((z * z) <= 2d+301) then
tmp = (x * x) + ((y * 4.0d0) * (t - (z * z)))
else
tmp = (x * x) - (z * (z * (y * 4.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 2e+301) {
tmp = (x * x) + ((y * 4.0) * (t - (z * z)));
} else {
tmp = (x * x) - (z * (z * (y * 4.0)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z * z) <= 2e+301: tmp = (x * x) + ((y * 4.0) * (t - (z * z))) else: tmp = (x * x) - (z * (z * (y * 4.0))) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 2e+301) tmp = Float64(Float64(x * x) + Float64(Float64(y * 4.0) * Float64(t - Float64(z * z)))); else tmp = Float64(Float64(x * x) - Float64(z * Float64(z * Float64(y * 4.0)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z * z) <= 2e+301) tmp = (x * x) + ((y * 4.0) * (t - (z * z))); else tmp = (x * x) - (z * (z * (y * 4.0))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+301], N[(N[(x * x), $MachinePrecision] + N[(N[(y * 4.0), $MachinePrecision] * N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] - N[(z * N[(z * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+301}:\\
\;\;\;\;x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x - z \cdot \left(z \cdot \left(y \cdot 4\right)\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 2.00000000000000011e301Initial program 99.0%
if 2.00000000000000011e301 < (*.f64 z z) Initial program 75.3%
Taylor expanded in z around inf 75.3%
unpow275.3%
associate-*r*75.3%
*-commutative75.3%
associate-*r*98.0%
*-commutative98.0%
Simplified98.0%
Final simplification98.8%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 1e+115) (- (* x x) (* t (* y -4.0))) (- (* x x) (* z (* z (* y 4.0))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 1e+115) {
tmp = (x * x) - (t * (y * -4.0));
} else {
tmp = (x * x) - (z * (z * (y * 4.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 ((z * z) <= 1d+115) then
tmp = (x * x) - (t * (y * (-4.0d0)))
else
tmp = (x * x) - (z * (z * (y * 4.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 1e+115) {
tmp = (x * x) - (t * (y * -4.0));
} else {
tmp = (x * x) - (z * (z * (y * 4.0)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z * z) <= 1e+115: tmp = (x * x) - (t * (y * -4.0)) else: tmp = (x * x) - (z * (z * (y * 4.0))) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 1e+115) tmp = Float64(Float64(x * x) - Float64(t * Float64(y * -4.0))); else tmp = Float64(Float64(x * x) - Float64(z * Float64(z * Float64(y * 4.0)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z * z) <= 1e+115) tmp = (x * x) - (t * (y * -4.0)); else tmp = (x * x) - (z * (z * (y * 4.0))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 1e+115], N[(N[(x * x), $MachinePrecision] - N[(t * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] - N[(z * N[(z * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 10^{+115}:\\
\;\;\;\;x \cdot x - t \cdot \left(y \cdot -4\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x - z \cdot \left(z \cdot \left(y \cdot 4\right)\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 1e115Initial program 98.6%
Taylor expanded in z around 0 93.2%
*-commutative93.2%
*-commutative93.2%
associate-*l*93.2%
Simplified93.2%
if 1e115 < (*.f64 z z) Initial program 87.9%
Taylor expanded in z around inf 80.9%
unpow280.9%
associate-*r*80.9%
*-commutative80.9%
associate-*r*92.0%
*-commutative92.0%
Simplified92.0%
Final simplification92.6%
(FPCore (x y z t) :precision binary64 (if (<= (* x x) 4.2e+158) (* (- (* z z) t) (* y -4.0)) (* x x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 4.2e+158) {
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) <= 4.2d+158) 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) <= 4.2e+158) {
tmp = ((z * z) - t) * (y * -4.0);
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x * x) <= 4.2e+158: 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) <= 4.2e+158) 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) <= 4.2e+158) tmp = ((z * z) - t) * (y * -4.0); else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x * x), $MachinePrecision], 4.2e+158], 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 4.2 \cdot 10^{+158}:\\
\;\;\;\;\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) < 4.1999999999999998e158Initial program 94.3%
Taylor expanded in x around 0 80.5%
*-commutative80.5%
*-commutative80.5%
unpow280.5%
*-commutative80.5%
associate-*l*80.5%
Simplified80.5%
if 4.1999999999999998e158 < (*.f64 x x) Initial program 93.4%
Taylor expanded in x around inf 88.9%
unpow288.9%
Simplified88.9%
Final simplification83.5%
(FPCore (x y z t) :precision binary64 (if (<= (* x x) 3e-11) (* 4.0 (* t y)) (* x x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 3e-11) {
tmp = 4.0 * (t * y);
} 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) <= 3d-11) then
tmp = 4.0d0 * (t * y)
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) <= 3e-11) {
tmp = 4.0 * (t * y);
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x * x) <= 3e-11: tmp = 4.0 * (t * y) else: tmp = x * x return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x * x) <= 3e-11) tmp = Float64(4.0 * Float64(t * y)); else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x * x) <= 3e-11) tmp = 4.0 * (t * y); else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x * x), $MachinePrecision], 3e-11], N[(4.0 * N[(t * y), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 3 \cdot 10^{-11}:\\
\;\;\;\;4 \cdot \left(t \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 3e-11Initial program 93.4%
Taylor expanded in t around inf 55.5%
if 3e-11 < (*.f64 x x) Initial program 94.6%
Taylor expanded in x around inf 74.7%
unpow274.7%
Simplified74.7%
Final simplification65.0%
(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 94.0%
Taylor expanded in x around inf 43.3%
unpow243.3%
Simplified43.3%
Final simplification43.3%
(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 2023214
(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))))