
(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 10 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 (<= (* x x) 5e+248) (fma (* z (* y -4.0)) z (fma (* (- t) y) -4.0 (* x x))) (* (fma (* (/ z x) (* (* (/ y x) -4.0) z)) x x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 5e+248) {
tmp = fma((z * (y * -4.0)), z, fma((-t * y), -4.0, (x * x)));
} else {
tmp = fma(((z / x) * (((y / x) * -4.0) * z)), x, x) * x;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(x * x) <= 5e+248) tmp = fma(Float64(z * Float64(y * -4.0)), z, fma(Float64(Float64(-t) * y), -4.0, Float64(x * x))); else tmp = Float64(fma(Float64(Float64(z / x) * Float64(Float64(Float64(y / x) * -4.0) * z)), x, x) * x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(x * x), $MachinePrecision], 5e+248], N[(N[(z * N[(y * -4.0), $MachinePrecision]), $MachinePrecision] * z + N[(N[((-t) * y), $MachinePrecision] * -4.0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(z / x), $MachinePrecision] * N[(N[(N[(y / x), $MachinePrecision] * -4.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] * x + x), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{+248}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot \left(y \cdot -4\right), z, \mathsf{fma}\left(\left(-t\right) \cdot y, -4, x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{x} \cdot \left(\left(\frac{y}{x} \cdot -4\right) \cdot z\right), x, x\right) \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 4.9999999999999996e248Initial program 93.2%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
associate-+l+N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-evalN/A
Applied rewrites98.2%
if 4.9999999999999996e248 < (*.f64 x x) Initial program 83.8%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
associate-+l+N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-evalN/A
Applied rewrites89.0%
Taylor expanded in x around inf
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites97.2%
Taylor expanded in t around 0
Applied rewrites98.6%
Final simplification98.3%
(FPCore (x y z t) :precision binary64 (if (<= (* 4.0 y) -2e-21) (fma x x (* (* (- (* z z) t) y) -4.0)) (fma (* z (* y -4.0)) z (fma (* (- t) y) -4.0 (* x x)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((4.0 * y) <= -2e-21) {
tmp = fma(x, x, ((((z * z) - t) * y) * -4.0));
} else {
tmp = fma((z * (y * -4.0)), z, fma((-t * y), -4.0, (x * x)));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(4.0 * y) <= -2e-21) tmp = fma(x, x, Float64(Float64(Float64(Float64(z * z) - t) * y) * -4.0)); else tmp = fma(Float64(z * Float64(y * -4.0)), z, fma(Float64(Float64(-t) * y), -4.0, Float64(x * x))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(4.0 * y), $MachinePrecision], -2e-21], N[(x * x + N[(N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision], N[(N[(z * N[(y * -4.0), $MachinePrecision]), $MachinePrecision] * z + N[(N[((-t) * y), $MachinePrecision] * -4.0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;4 \cdot y \leq -2 \cdot 10^{-21}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(\left(z \cdot z - t\right) \cdot y\right) \cdot -4\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot \left(y \cdot -4\right), z, \mathsf{fma}\left(\left(-t\right) \cdot y, -4, x \cdot x\right)\right)\\
\end{array}
\end{array}
if (*.f64 y #s(literal 4 binary64)) < -1.99999999999999982e-21Initial program 95.8%
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-*.f64N/A
metadata-eval97.2
Applied rewrites97.2%
if -1.99999999999999982e-21 < (*.f64 y #s(literal 4 binary64)) Initial program 88.5%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
associate-+l+N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-evalN/A
Applied rewrites97.7%
Final simplification97.6%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* z z) t)))
(if (<= t_1 -4e-66)
(* (* 4.0 y) t)
(if (<= t_1 4e+219) (* x x) (* (* (* z -4.0) y) z)))))
double code(double x, double y, double z, double t) {
double t_1 = (z * z) - t;
double tmp;
if (t_1 <= -4e-66) {
tmp = (4.0 * y) * t;
} else if (t_1 <= 4e+219) {
tmp = x * x;
} else {
tmp = ((z * -4.0) * y) * z;
}
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 = (z * z) - t
if (t_1 <= (-4d-66)) then
tmp = (4.0d0 * y) * t
else if (t_1 <= 4d+219) then
tmp = x * x
else
tmp = ((z * (-4.0d0)) * y) * z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (z * z) - t;
double tmp;
if (t_1 <= -4e-66) {
tmp = (4.0 * y) * t;
} else if (t_1 <= 4e+219) {
tmp = x * x;
} else {
tmp = ((z * -4.0) * y) * z;
}
return tmp;
}
def code(x, y, z, t): t_1 = (z * z) - t tmp = 0 if t_1 <= -4e-66: tmp = (4.0 * y) * t elif t_1 <= 4e+219: tmp = x * x else: tmp = ((z * -4.0) * y) * z return tmp
function code(x, y, z, t) t_1 = Float64(Float64(z * z) - t) tmp = 0.0 if (t_1 <= -4e-66) tmp = Float64(Float64(4.0 * y) * t); elseif (t_1 <= 4e+219) tmp = Float64(x * x); else tmp = Float64(Float64(Float64(z * -4.0) * y) * z); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (z * z) - t; tmp = 0.0; if (t_1 <= -4e-66) tmp = (4.0 * y) * t; elseif (t_1 <= 4e+219) tmp = x * x; else tmp = ((z * -4.0) * y) * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision]}, If[LessEqual[t$95$1, -4e-66], N[(N[(4.0 * y), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[t$95$1, 4e+219], N[(x * x), $MachinePrecision], N[(N[(N[(z * -4.0), $MachinePrecision] * y), $MachinePrecision] * z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot z - t\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{-66}:\\
\;\;\;\;\left(4 \cdot y\right) \cdot t\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+219}:\\
\;\;\;\;x \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(\left(z \cdot -4\right) \cdot y\right) \cdot z\\
\end{array}
\end{array}
if (-.f64 (*.f64 z z) t) < -3.9999999999999999e-66Initial program 93.6%
Taylor expanded in t around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6479.1
Applied rewrites79.1%
if -3.9999999999999999e-66 < (-.f64 (*.f64 z z) t) < 3.99999999999999986e219Initial program 99.1%
Taylor expanded in y around 0
unpow2N/A
lower-*.f6456.1
Applied rewrites56.1%
if 3.99999999999999986e219 < (-.f64 (*.f64 z z) t) Initial program 76.1%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6468.2
Applied rewrites68.2%
Applied rewrites75.8%
Final simplification66.8%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 2e+291) (fma x x (* (* (- (* z z) t) y) -4.0)) (* (* (* z -4.0) y) z)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 2e+291) {
tmp = fma(x, x, ((((z * z) - t) * y) * -4.0));
} else {
tmp = ((z * -4.0) * y) * z;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 2e+291) tmp = fma(x, x, Float64(Float64(Float64(Float64(z * z) - t) * y) * -4.0)); else tmp = Float64(Float64(Float64(z * -4.0) * y) * z); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+291], N[(x * x + N[(N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z * -4.0), $MachinePrecision] * y), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+291}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(\left(z \cdot z - t\right) \cdot y\right) \cdot -4\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(z \cdot -4\right) \cdot y\right) \cdot z\\
\end{array}
\end{array}
if (*.f64 z z) < 1.9999999999999999e291Initial program 97.3%
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-*.f64N/A
metadata-eval97.8
Applied rewrites97.8%
if 1.9999999999999999e291 < (*.f64 z z) Initial program 71.6%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6474.6
Applied rewrites74.6%
Applied rewrites84.1%
(FPCore (x y z t) :precision binary64 (if (<= x 3.2e-129) (* (* 4.0 y) t) (if (<= x 1.15e-29) (* (* (* z z) y) -4.0) (* x x))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= 3.2e-129) {
tmp = (4.0 * y) * t;
} else if (x <= 1.15e-29) {
tmp = ((z * z) * 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 <= 3.2d-129) then
tmp = (4.0d0 * y) * t
else if (x <= 1.15d-29) then
tmp = ((z * z) * 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 <= 3.2e-129) {
tmp = (4.0 * y) * t;
} else if (x <= 1.15e-29) {
tmp = ((z * z) * y) * -4.0;
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= 3.2e-129: tmp = (4.0 * y) * t elif x <= 1.15e-29: tmp = ((z * z) * y) * -4.0 else: tmp = x * x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= 3.2e-129) tmp = Float64(Float64(4.0 * y) * t); elseif (x <= 1.15e-29) tmp = Float64(Float64(Float64(z * z) * 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 <= 3.2e-129) tmp = (4.0 * y) * t; elseif (x <= 1.15e-29) tmp = ((z * z) * y) * -4.0; else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, 3.2e-129], N[(N[(4.0 * y), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[x, 1.15e-29], N[(N[(N[(z * z), $MachinePrecision] * y), $MachinePrecision] * -4.0), $MachinePrecision], N[(x * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.2 \cdot 10^{-129}:\\
\;\;\;\;\left(4 \cdot y\right) \cdot t\\
\mathbf{elif}\;x \leq 1.15 \cdot 10^{-29}:\\
\;\;\;\;\left(\left(z \cdot z\right) \cdot y\right) \cdot -4\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if x < 3.2000000000000003e-129Initial program 90.7%
Taylor expanded in t around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6442.2
Applied rewrites42.2%
if 3.2000000000000003e-129 < x < 1.14999999999999996e-29Initial program 99.8%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6458.8
Applied rewrites58.8%
if 1.14999999999999996e-29 < x Initial program 87.7%
Taylor expanded in y around 0
unpow2N/A
lower-*.f6472.3
Applied rewrites72.3%
Final simplification51.7%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 5e+225) (fma x x (* (* 4.0 t) y)) (* (* (* z -4.0) y) z)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 5e+225) {
tmp = fma(x, x, ((4.0 * t) * y));
} else {
tmp = ((z * -4.0) * y) * z;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 5e+225) tmp = fma(x, x, Float64(Float64(4.0 * t) * y)); else tmp = Float64(Float64(Float64(z * -4.0) * y) * z); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e+225], N[(x * x + N[(N[(4.0 * t), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z * -4.0), $MachinePrecision] * y), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+225}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(4 \cdot t\right) \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(z \cdot -4\right) \cdot y\right) \cdot z\\
\end{array}
\end{array}
if (*.f64 z z) < 4.99999999999999981e225Initial program 97.7%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
associate-+l+N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-evalN/A
Applied rewrites97.2%
Applied rewrites98.3%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f6485.8
Applied rewrites85.8%
if 4.99999999999999981e225 < (*.f64 z z) Initial program 73.3%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6474.6
Applied rewrites74.6%
Applied rewrites83.1%
Final simplification85.0%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 5e+225) (fma (* t y) 4.0 (* x x)) (* (* (* z -4.0) y) z)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 5e+225) {
tmp = fma((t * y), 4.0, (x * x));
} else {
tmp = ((z * -4.0) * y) * z;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 5e+225) tmp = fma(Float64(t * y), 4.0, Float64(x * x)); else tmp = Float64(Float64(Float64(z * -4.0) * y) * z); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e+225], N[(N[(t * y), $MachinePrecision] * 4.0 + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z * -4.0), $MachinePrecision] * y), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+225}:\\
\;\;\;\;\mathsf{fma}\left(t \cdot y, 4, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(z \cdot -4\right) \cdot y\right) \cdot z\\
\end{array}
\end{array}
if (*.f64 z z) < 4.99999999999999981e225Initial program 97.7%
Taylor expanded in z around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6485.2
Applied rewrites85.2%
if 4.99999999999999981e225 < (*.f64 z z) Initial program 73.3%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6474.6
Applied rewrites74.6%
Applied rewrites83.1%
(FPCore (x y z t) :precision binary64 (if (<= x 1.35e-34) (* (* (fma z z (- t)) y) -4.0) (fma x x (* (* 4.0 t) y))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= 1.35e-34) {
tmp = (fma(z, z, -t) * y) * -4.0;
} else {
tmp = fma(x, x, ((4.0 * t) * y));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (x <= 1.35e-34) tmp = Float64(Float64(fma(z, z, Float64(-t)) * y) * -4.0); else tmp = fma(x, x, Float64(Float64(4.0 * t) * y)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[x, 1.35e-34], N[(N[(N[(z * z + (-t)), $MachinePrecision] * y), $MachinePrecision] * -4.0), $MachinePrecision], N[(x * x + N[(N[(4.0 * t), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.35 \cdot 10^{-34}:\\
\;\;\;\;\left(\mathsf{fma}\left(z, z, -t\right) \cdot y\right) \cdot -4\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(4 \cdot t\right) \cdot y\right)\\
\end{array}
\end{array}
if x < 1.35000000000000008e-34Initial program 91.6%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
sub-negN/A
unpow2N/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f6473.0
Applied rewrites73.0%
if 1.35000000000000008e-34 < x Initial program 87.9%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
associate-+l+N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-evalN/A
Applied rewrites95.7%
Applied rewrites89.3%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f6480.8
Applied rewrites80.8%
Final simplification75.2%
(FPCore (x y z t) :precision binary64 (if (<= (* x x) 1.9e+94) (* (* 4.0 y) t) (* x x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 1.9e+94) {
tmp = (4.0 * y) * t;
} 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.9d+94) then
tmp = (4.0d0 * y) * t
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.9e+94) {
tmp = (4.0 * y) * t;
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x * x) <= 1.9e+94: tmp = (4.0 * y) * t else: tmp = x * x return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x * x) <= 1.9e+94) tmp = Float64(Float64(4.0 * y) * t); else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x * x) <= 1.9e+94) tmp = (4.0 * y) * t; else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x * x), $MachinePrecision], 1.9e+94], N[(N[(4.0 * y), $MachinePrecision] * t), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 1.9 \cdot 10^{+94}:\\
\;\;\;\;\left(4 \cdot y\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 1.8999999999999998e94Initial program 95.7%
Taylor expanded in t around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6449.9
Applied rewrites49.9%
if 1.8999999999999998e94 < (*.f64 x x) Initial program 83.0%
Taylor expanded in y around 0
unpow2N/A
lower-*.f6484.0
Applied rewrites84.0%
Final simplification63.6%
(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.5%
Taylor expanded in y around 0
unpow2N/A
lower-*.f6442.3
Applied rewrites42.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 2024244
(FPCore (x y z t)
:name "Graphics.Rasterific.Shading:$sradialGradientWithFocusShader from Rasterific-0.6.1, B"
:precision binary64
:alt
(! :herbie-platform default (- (* x x) (* 4 (* y (- (* z z) t)))))
(- (* x x) (* (* y 4.0) (- (* z z) t))))