
(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 (<= (* 4.0 y) 5e-119) (fma (* (* -4.0 y) z) z (fma (* (- t) y) -4.0 (* x x))) (fma x x (* (* (- (* z z) t) y) -4.0))))
double code(double x, double y, double z, double t) {
double tmp;
if ((4.0 * y) <= 5e-119) {
tmp = fma(((-4.0 * y) * z), z, fma((-t * y), -4.0, (x * x)));
} else {
tmp = fma(x, x, ((((z * z) - t) * y) * -4.0));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(4.0 * y) <= 5e-119) tmp = fma(Float64(Float64(-4.0 * y) * z), z, fma(Float64(Float64(-t) * y), -4.0, Float64(x * x))); else tmp = fma(x, x, Float64(Float64(Float64(Float64(z * z) - t) * y) * -4.0)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(4.0 * y), $MachinePrecision], 5e-119], N[(N[(N[(-4.0 * y), $MachinePrecision] * z), $MachinePrecision] * z + N[(N[((-t) * y), $MachinePrecision] * -4.0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * x + N[(N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;4 \cdot y \leq 5 \cdot 10^{-119}:\\
\;\;\;\;\mathsf{fma}\left(\left(-4 \cdot y\right) \cdot z, z, \mathsf{fma}\left(\left(-t\right) \cdot y, -4, x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(\left(z \cdot z - t\right) \cdot y\right) \cdot -4\right)\\
\end{array}
\end{array}
if (*.f64 y #s(literal 4 binary64)) < 4.99999999999999993e-119Initial program 92.1%
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 rewrites99.3%
if 4.99999999999999993e-119 < (*.f64 y #s(literal 4 binary64)) Initial program 91.7%
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.6
Applied rewrites97.6%
Final simplification98.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* t (* 4.0 y))))
(if (<= (* x x) 8.2e-297)
t_1
(if (<= (* x x) 8e-108)
(* (* (* -4.0 y) z) z)
(if (<= (* x x) 2.7e+65) t_1 (* x x))))))
double code(double x, double y, double z, double t) {
double t_1 = t * (4.0 * y);
double tmp;
if ((x * x) <= 8.2e-297) {
tmp = t_1;
} else if ((x * x) <= 8e-108) {
tmp = ((-4.0 * y) * z) * z;
} else if ((x * x) <= 2.7e+65) {
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) :: tmp
t_1 = t * (4.0d0 * y)
if ((x * x) <= 8.2d-297) then
tmp = t_1
else if ((x * x) <= 8d-108) then
tmp = (((-4.0d0) * y) * z) * z
else if ((x * x) <= 2.7d+65) 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 = t * (4.0 * y);
double tmp;
if ((x * x) <= 8.2e-297) {
tmp = t_1;
} else if ((x * x) <= 8e-108) {
tmp = ((-4.0 * y) * z) * z;
} else if ((x * x) <= 2.7e+65) {
tmp = t_1;
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): t_1 = t * (4.0 * y) tmp = 0 if (x * x) <= 8.2e-297: tmp = t_1 elif (x * x) <= 8e-108: tmp = ((-4.0 * y) * z) * z elif (x * x) <= 2.7e+65: tmp = t_1 else: tmp = x * x return tmp
function code(x, y, z, t) t_1 = Float64(t * Float64(4.0 * y)) tmp = 0.0 if (Float64(x * x) <= 8.2e-297) tmp = t_1; elseif (Float64(x * x) <= 8e-108) tmp = Float64(Float64(Float64(-4.0 * y) * z) * z); elseif (Float64(x * x) <= 2.7e+65) tmp = t_1; else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = t * (4.0 * y); tmp = 0.0; if ((x * x) <= 8.2e-297) tmp = t_1; elseif ((x * x) <= 8e-108) tmp = ((-4.0 * y) * z) * z; elseif ((x * x) <= 2.7e+65) tmp = t_1; else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t * N[(4.0 * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 8.2e-297], t$95$1, If[LessEqual[N[(x * x), $MachinePrecision], 8e-108], N[(N[(N[(-4.0 * y), $MachinePrecision] * z), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 2.7e+65], t$95$1, N[(x * x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t \cdot \left(4 \cdot y\right)\\
\mathbf{if}\;x \cdot x \leq 8.2 \cdot 10^{-297}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \cdot x \leq 8 \cdot 10^{-108}:\\
\;\;\;\;\left(\left(-4 \cdot y\right) \cdot z\right) \cdot z\\
\mathbf{elif}\;x \cdot x \leq 2.7 \cdot 10^{+65}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 8.2000000000000004e-297 or 8.00000000000000032e-108 < (*.f64 x x) < 2.70000000000000019e65Initial program 94.3%
Taylor expanded in t around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6458.1
Applied rewrites58.1%
if 8.2000000000000004e-297 < (*.f64 x x) < 8.00000000000000032e-108Initial program 92.0%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6455.6
Applied rewrites55.6%
Applied rewrites63.3%
if 2.70000000000000019e65 < (*.f64 x x) Initial program 90.0%
Taylor expanded in y around 0
unpow2N/A
lower-*.f6479.0
Applied rewrites79.0%
Final simplification68.5%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* t (* 4.0 y))))
(if (<= (* x x) 4.5e-294)
t_1
(if (<= (* x x) 6e-108)
(* (* (* z z) y) -4.0)
(if (<= (* x x) 2.7e+65) t_1 (* x x))))))
double code(double x, double y, double z, double t) {
double t_1 = t * (4.0 * y);
double tmp;
if ((x * x) <= 4.5e-294) {
tmp = t_1;
} else if ((x * x) <= 6e-108) {
tmp = ((z * z) * y) * -4.0;
} else if ((x * x) <= 2.7e+65) {
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) :: tmp
t_1 = t * (4.0d0 * y)
if ((x * x) <= 4.5d-294) then
tmp = t_1
else if ((x * x) <= 6d-108) then
tmp = ((z * z) * y) * (-4.0d0)
else if ((x * x) <= 2.7d+65) 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 = t * (4.0 * y);
double tmp;
if ((x * x) <= 4.5e-294) {
tmp = t_1;
} else if ((x * x) <= 6e-108) {
tmp = ((z * z) * y) * -4.0;
} else if ((x * x) <= 2.7e+65) {
tmp = t_1;
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): t_1 = t * (4.0 * y) tmp = 0 if (x * x) <= 4.5e-294: tmp = t_1 elif (x * x) <= 6e-108: tmp = ((z * z) * y) * -4.0 elif (x * x) <= 2.7e+65: tmp = t_1 else: tmp = x * x return tmp
function code(x, y, z, t) t_1 = Float64(t * Float64(4.0 * y)) tmp = 0.0 if (Float64(x * x) <= 4.5e-294) tmp = t_1; elseif (Float64(x * x) <= 6e-108) tmp = Float64(Float64(Float64(z * z) * y) * -4.0); elseif (Float64(x * x) <= 2.7e+65) tmp = t_1; else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = t * (4.0 * y); tmp = 0.0; if ((x * x) <= 4.5e-294) tmp = t_1; elseif ((x * x) <= 6e-108) tmp = ((z * z) * y) * -4.0; elseif ((x * x) <= 2.7e+65) tmp = t_1; else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t * N[(4.0 * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 4.5e-294], t$95$1, If[LessEqual[N[(x * x), $MachinePrecision], 6e-108], N[(N[(N[(z * z), $MachinePrecision] * y), $MachinePrecision] * -4.0), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 2.7e+65], t$95$1, N[(x * x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t \cdot \left(4 \cdot y\right)\\
\mathbf{if}\;x \cdot x \leq 4.5 \cdot 10^{-294}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \cdot x \leq 6 \cdot 10^{-108}:\\
\;\;\;\;\left(\left(z \cdot z\right) \cdot y\right) \cdot -4\\
\mathbf{elif}\;x \cdot x \leq 2.7 \cdot 10^{+65}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 4.49999999999999981e-294 or 5.99999999999999986e-108 < (*.f64 x x) < 2.70000000000000019e65Initial program 94.3%
Taylor expanded in t around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6458.1
Applied rewrites58.1%
if 4.49999999999999981e-294 < (*.f64 x x) < 5.99999999999999986e-108Initial program 92.0%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6455.6
Applied rewrites55.6%
if 2.70000000000000019e65 < (*.f64 x x) Initial program 90.0%
Taylor expanded in y around 0
unpow2N/A
lower-*.f6479.0
Applied rewrites79.0%
Final simplification67.5%
(FPCore (x y z t)
:precision binary64
(if (<= (* z z) 2e+125)
(fma x x (* (* t y) 4.0))
(if (<= (* z z) 2e+270)
(fma x x (* (* (* z z) y) -4.0))
(* (* (* -4.0 y) z) z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 2e+125) {
tmp = fma(x, x, ((t * y) * 4.0));
} else if ((z * z) <= 2e+270) {
tmp = fma(x, x, (((z * z) * y) * -4.0));
} else {
tmp = ((-4.0 * y) * z) * z;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 2e+125) tmp = fma(x, x, Float64(Float64(t * y) * 4.0)); elseif (Float64(z * z) <= 2e+270) tmp = fma(x, x, Float64(Float64(Float64(z * z) * y) * -4.0)); else tmp = Float64(Float64(Float64(-4.0 * y) * z) * z); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+125], N[(x * x + N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 2e+270], N[(x * x + N[(N[(N[(z * z), $MachinePrecision] * y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-4.0 * y), $MachinePrecision] * z), $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+125}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(t \cdot y\right) \cdot 4\right)\\
\mathbf{elif}\;z \cdot z \leq 2 \cdot 10^{+270}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(\left(z \cdot z\right) \cdot y\right) \cdot -4\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-4 \cdot y\right) \cdot z\right) \cdot z\\
\end{array}
\end{array}
if (*.f64 z z) < 1.9999999999999998e125Initial program 98.1%
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-eval99.3
Applied rewrites99.3%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6490.7
Applied rewrites90.7%
if 1.9999999999999998e125 < (*.f64 z z) < 2.0000000000000001e270Initial program 96.5%
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-eval99.8
Applied rewrites99.8%
Taylor expanded in t around 0
unpow2N/A
lower-*.f6489.9
Applied rewrites89.9%
if 2.0000000000000001e270 < (*.f64 z z) Initial program 72.7%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6477.7
Applied rewrites77.7%
Applied rewrites91.7%
Final simplification90.9%
(FPCore (x y z t)
:precision binary64
(if (<= (* z z) 2e+125)
(fma x x (* (* t y) 4.0))
(if (<= (* z z) 2e+266)
(fma -4.0 (* (* z z) y) (* x x))
(* (* (* -4.0 y) z) z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 2e+125) {
tmp = fma(x, x, ((t * y) * 4.0));
} else if ((z * z) <= 2e+266) {
tmp = fma(-4.0, ((z * z) * y), (x * x));
} else {
tmp = ((-4.0 * y) * z) * z;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 2e+125) tmp = fma(x, x, Float64(Float64(t * y) * 4.0)); elseif (Float64(z * z) <= 2e+266) tmp = fma(-4.0, Float64(Float64(z * z) * y), Float64(x * x)); else tmp = Float64(Float64(Float64(-4.0 * y) * z) * z); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+125], N[(x * x + N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 2e+266], N[(-4.0 * N[(N[(z * z), $MachinePrecision] * y), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-4.0 * y), $MachinePrecision] * z), $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+125}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(t \cdot y\right) \cdot 4\right)\\
\mathbf{elif}\;z \cdot z \leq 2 \cdot 10^{+266}:\\
\;\;\;\;\mathsf{fma}\left(-4, \left(z \cdot z\right) \cdot y, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-4 \cdot y\right) \cdot z\right) \cdot z\\
\end{array}
\end{array}
if (*.f64 z z) < 1.9999999999999998e125Initial program 98.1%
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-eval99.3
Applied rewrites99.3%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6490.7
Applied rewrites90.7%
if 1.9999999999999998e125 < (*.f64 z z) < 2.0000000000000001e266Initial program 99.8%
Taylor expanded in t around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6489.2
Applied rewrites89.2%
if 2.0000000000000001e266 < (*.f64 z z) Initial program 72.0%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6476.9
Applied rewrites76.9%
Applied rewrites90.5%
Final simplification90.5%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 2e+270) (fma x x (* (* (- (* z z) t) y) -4.0)) (* (* (* -4.0 y) z) z)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 2e+270) {
tmp = fma(x, x, ((((z * z) - t) * y) * -4.0));
} else {
tmp = ((-4.0 * y) * z) * z;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 2e+270) tmp = fma(x, x, Float64(Float64(Float64(Float64(z * z) - t) * y) * -4.0)); else tmp = Float64(Float64(Float64(-4.0 * y) * z) * z); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+270], N[(x * x + N[(N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-4.0 * y), $MachinePrecision] * z), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+270}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(\left(z \cdot z - t\right) \cdot y\right) \cdot -4\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-4 \cdot y\right) \cdot z\right) \cdot z\\
\end{array}
\end{array}
if (*.f64 z z) < 2.0000000000000001e270Initial program 97.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-eval99.4
Applied rewrites99.4%
if 2.0000000000000001e270 < (*.f64 z z) Initial program 72.7%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6477.7
Applied rewrites77.7%
Applied rewrites91.7%
Final simplification97.6%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 5e+193) (fma x x (* (* t y) 4.0)) (* (* (* -4.0 y) z) z)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 5e+193) {
tmp = fma(x, x, ((t * y) * 4.0));
} else {
tmp = ((-4.0 * y) * z) * z;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 5e+193) tmp = fma(x, x, Float64(Float64(t * y) * 4.0)); else tmp = Float64(Float64(Float64(-4.0 * y) * z) * z); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e+193], N[(x * x + N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-4.0 * y), $MachinePrecision] * z), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+193}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(t \cdot y\right) \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-4 \cdot y\right) \cdot z\right) \cdot z\\
\end{array}
\end{array}
if (*.f64 z z) < 4.99999999999999972e193Initial program 98.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-eval99.4
Applied rewrites99.4%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6487.8
Applied rewrites87.8%
if 4.99999999999999972e193 < (*.f64 z z) Initial program 75.8%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6478.7
Applied rewrites78.7%
Applied rewrites90.3%
Final simplification88.5%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 5e+193) (fma (* t y) 4.0 (* x x)) (* (* (* -4.0 y) z) z)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 5e+193) {
tmp = fma((t * y), 4.0, (x * x));
} else {
tmp = ((-4.0 * y) * z) * z;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 5e+193) tmp = fma(Float64(t * y), 4.0, Float64(x * x)); else tmp = Float64(Float64(Float64(-4.0 * y) * z) * z); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e+193], N[(N[(t * y), $MachinePrecision] * 4.0 + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-4.0 * y), $MachinePrecision] * z), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+193}:\\
\;\;\;\;\mathsf{fma}\left(t \cdot y, 4, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-4 \cdot y\right) \cdot z\right) \cdot z\\
\end{array}
\end{array}
if (*.f64 z z) < 4.99999999999999972e193Initial program 98.3%
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-*.f6486.7
Applied rewrites86.7%
if 4.99999999999999972e193 < (*.f64 z z) Initial program 75.8%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6478.7
Applied rewrites78.7%
Applied rewrites90.3%
Final simplification87.7%
(FPCore (x y z t) :precision binary64 (if (<= x 1.65e+33) (* t (* 4.0 y)) (* x x)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= 1.65e+33) {
tmp = t * (4.0 * 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 <= 1.65d+33) then
tmp = t * (4.0d0 * 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 <= 1.65e+33) {
tmp = t * (4.0 * y);
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= 1.65e+33: tmp = t * (4.0 * y) else: tmp = x * x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= 1.65e+33) tmp = Float64(t * Float64(4.0 * y)); else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= 1.65e+33) tmp = t * (4.0 * y); else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, 1.65e+33], N[(t * N[(4.0 * y), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.65 \cdot 10^{+33}:\\
\;\;\;\;t \cdot \left(4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if x < 1.64999999999999988e33Initial program 93.8%
Taylor expanded in t around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6438.2
Applied rewrites38.2%
if 1.64999999999999988e33 < x Initial program 85.0%
Taylor expanded in y around 0
unpow2N/A
lower-*.f6473.0
Applied rewrites73.0%
Final simplification45.4%
(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 92.0%
Taylor expanded in y around 0
unpow2N/A
lower-*.f6444.4
Applied rewrites44.4%
(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 2024235
(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))))