
(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
(let* ((t_1 (- (* z z) t)))
(if (<= (- (* x x) (* t_1 (* 4.0 y))) INFINITY)
(fma (* (* -4.0 y) z) z (fma (* (- t) y) -4.0 (* x x)))
(* (* t_1 y) -4.0))))
double code(double x, double y, double z, double t) {
double t_1 = (z * z) - t;
double tmp;
if (((x * x) - (t_1 * (4.0 * y))) <= ((double) INFINITY)) {
tmp = fma(((-4.0 * y) * z), z, fma((-t * y), -4.0, (x * x)));
} else {
tmp = (t_1 * y) * -4.0;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(z * z) - t) tmp = 0.0 if (Float64(Float64(x * x) - Float64(t_1 * Float64(4.0 * y))) <= Inf) tmp = fma(Float64(Float64(-4.0 * y) * z), z, fma(Float64(Float64(-t) * y), -4.0, Float64(x * x))); else tmp = Float64(Float64(t_1 * y) * -4.0); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision]}, If[LessEqual[N[(N[(x * x), $MachinePrecision] - N[(t$95$1 * N[(4.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(-4.0 * y), $MachinePrecision] * z), $MachinePrecision] * z + N[(N[((-t) * y), $MachinePrecision] * -4.0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 * y), $MachinePrecision] * -4.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot z - t\\
\mathbf{if}\;x \cdot x - t\_1 \cdot \left(4 \cdot y\right) \leq \infty:\\
\;\;\;\;\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}:\\
\;\;\;\;\left(t\_1 \cdot y\right) \cdot -4\\
\end{array}
\end{array}
if (-.f64 (*.f64 x x) (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t))) < +inf.0Initial program 96.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 rewrites99.1%
if +inf.0 < (-.f64 (*.f64 x x) (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t))) Initial program 0.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
unpow2N/A
lower-*.f6461.5
Applied rewrites61.5%
Final simplification97.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* x x) (* (- (* z z) t) (* 4.0 y)))))
(if (<= t_1 -5e+280)
(* (* (* -4.0 z) y) z)
(if (<= t_1 5e-30) (* t (* 4.0 y)) (* x x)))))
double code(double x, double y, double z, double t) {
double t_1 = (x * x) - (((z * z) - t) * (4.0 * y));
double tmp;
if (t_1 <= -5e+280) {
tmp = ((-4.0 * z) * y) * z;
} else if (t_1 <= 5e-30) {
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) :: t_1
real(8) :: tmp
t_1 = (x * x) - (((z * z) - t) * (4.0d0 * y))
if (t_1 <= (-5d+280)) then
tmp = (((-4.0d0) * z) * y) * z
else if (t_1 <= 5d-30) 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 t_1 = (x * x) - (((z * z) - t) * (4.0 * y));
double tmp;
if (t_1 <= -5e+280) {
tmp = ((-4.0 * z) * y) * z;
} else if (t_1 <= 5e-30) {
tmp = t * (4.0 * y);
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): t_1 = (x * x) - (((z * z) - t) * (4.0 * y)) tmp = 0 if t_1 <= -5e+280: tmp = ((-4.0 * z) * y) * z elif t_1 <= 5e-30: tmp = t * (4.0 * y) else: tmp = x * x return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x * x) - Float64(Float64(Float64(z * z) - t) * Float64(4.0 * y))) tmp = 0.0 if (t_1 <= -5e+280) tmp = Float64(Float64(Float64(-4.0 * z) * y) * z); elseif (t_1 <= 5e-30) tmp = Float64(t * Float64(4.0 * y)); else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x * x) - (((z * z) - t) * (4.0 * y)); tmp = 0.0; if (t_1 <= -5e+280) tmp = ((-4.0 * z) * y) * z; elseif (t_1 <= 5e-30) tmp = t * (4.0 * y); else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] - N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(4.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+280], N[(N[(N[(-4.0 * z), $MachinePrecision] * y), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[t$95$1, 5e-30], N[(t * N[(4.0 * y), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot x - \left(z \cdot z - t\right) \cdot \left(4 \cdot y\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+280}:\\
\;\;\;\;\left(\left(-4 \cdot z\right) \cdot y\right) \cdot z\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-30}:\\
\;\;\;\;t \cdot \left(4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (-.f64 (*.f64 x x) (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t))) < -5.0000000000000002e280Initial program 84.5%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6468.3
Applied rewrites68.3%
Applied rewrites83.7%
if -5.0000000000000002e280 < (-.f64 (*.f64 x x) (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t))) < 4.99999999999999972e-30Initial program 99.8%
Taylor expanded in t around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6467.6
Applied rewrites67.6%
if 4.99999999999999972e-30 < (-.f64 (*.f64 x x) (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t))) Initial program 89.8%
Taylor expanded in y around 0
unpow2N/A
lower-*.f6462.6
Applied rewrites62.6%
Final simplification66.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* x x) (* (- (* z z) t) (* 4.0 y)))))
(if (<= t_1 -5e+280)
(* (* (* z z) y) -4.0)
(if (<= t_1 5e-30) (* t (* 4.0 y)) (* x x)))))
double code(double x, double y, double z, double t) {
double t_1 = (x * x) - (((z * z) - t) * (4.0 * y));
double tmp;
if (t_1 <= -5e+280) {
tmp = ((z * z) * y) * -4.0;
} else if (t_1 <= 5e-30) {
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) :: t_1
real(8) :: tmp
t_1 = (x * x) - (((z * z) - t) * (4.0d0 * y))
if (t_1 <= (-5d+280)) then
tmp = ((z * z) * y) * (-4.0d0)
else if (t_1 <= 5d-30) 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 t_1 = (x * x) - (((z * z) - t) * (4.0 * y));
double tmp;
if (t_1 <= -5e+280) {
tmp = ((z * z) * y) * -4.0;
} else if (t_1 <= 5e-30) {
tmp = t * (4.0 * y);
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): t_1 = (x * x) - (((z * z) - t) * (4.0 * y)) tmp = 0 if t_1 <= -5e+280: tmp = ((z * z) * y) * -4.0 elif t_1 <= 5e-30: tmp = t * (4.0 * y) else: tmp = x * x return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x * x) - Float64(Float64(Float64(z * z) - t) * Float64(4.0 * y))) tmp = 0.0 if (t_1 <= -5e+280) tmp = Float64(Float64(Float64(z * z) * y) * -4.0); elseif (t_1 <= 5e-30) tmp = Float64(t * Float64(4.0 * y)); else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x * x) - (((z * z) - t) * (4.0 * y)); tmp = 0.0; if (t_1 <= -5e+280) tmp = ((z * z) * y) * -4.0; elseif (t_1 <= 5e-30) tmp = t * (4.0 * y); else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] - N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(4.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+280], N[(N[(N[(z * z), $MachinePrecision] * y), $MachinePrecision] * -4.0), $MachinePrecision], If[LessEqual[t$95$1, 5e-30], N[(t * N[(4.0 * y), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot x - \left(z \cdot z - t\right) \cdot \left(4 \cdot y\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+280}:\\
\;\;\;\;\left(\left(z \cdot z\right) \cdot y\right) \cdot -4\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-30}:\\
\;\;\;\;t \cdot \left(4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (-.f64 (*.f64 x x) (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t))) < -5.0000000000000002e280Initial program 84.5%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6468.3
Applied rewrites68.3%
if -5.0000000000000002e280 < (-.f64 (*.f64 x x) (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t))) < 4.99999999999999972e-30Initial program 99.8%
Taylor expanded in t around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6467.6
Applied rewrites67.6%
if 4.99999999999999972e-30 < (-.f64 (*.f64 x x) (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t))) Initial program 89.8%
Taylor expanded in y around 0
unpow2N/A
lower-*.f6462.6
Applied rewrites62.6%
Final simplification64.4%
(FPCore (x y z t)
:precision binary64
(if (<= (* z z) 2e+60)
(fma (* t y) 4.0 (* x x))
(if (<= (* z z) 4e+295)
(fma (* -4.0 (* z z)) y (* x x))
(* (* (* -4.0 z) y) z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 2e+60) {
tmp = fma((t * y), 4.0, (x * x));
} else if ((z * z) <= 4e+295) {
tmp = fma((-4.0 * (z * z)), y, (x * x));
} else {
tmp = ((-4.0 * z) * y) * z;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 2e+60) tmp = fma(Float64(t * y), 4.0, Float64(x * x)); elseif (Float64(z * z) <= 4e+295) tmp = fma(Float64(-4.0 * Float64(z * z)), y, Float64(x * x)); else tmp = Float64(Float64(Float64(-4.0 * z) * y) * z); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+60], N[(N[(t * y), $MachinePrecision] * 4.0 + N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 4e+295], N[(N[(-4.0 * N[(z * z), $MachinePrecision]), $MachinePrecision] * y + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-4.0 * z), $MachinePrecision] * y), $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+60}:\\
\;\;\;\;\mathsf{fma}\left(t \cdot y, 4, x \cdot x\right)\\
\mathbf{elif}\;z \cdot z \leq 4 \cdot 10^{+295}:\\
\;\;\;\;\mathsf{fma}\left(-4 \cdot \left(z \cdot z\right), y, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-4 \cdot z\right) \cdot y\right) \cdot z\\
\end{array}
\end{array}
if (*.f64 z z) < 1.9999999999999999e60Initial program 98.6%
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-*.f6492.9
Applied rewrites92.9%
if 1.9999999999999999e60 < (*.f64 z z) < 3.9999999999999999e295Initial program 89.5%
Taylor expanded in t around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6478.3
Applied rewrites78.3%
if 3.9999999999999999e295 < (*.f64 z z) Initial program 74.2%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6481.9
Applied rewrites81.9%
Applied rewrites94.6%
Final simplification89.9%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 4e+295) (- (* x x) (* (- (* z z) t) (* 4.0 y))) (* (* (* -4.0 z) y) z)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 4e+295) {
tmp = (x * x) - (((z * z) - t) * (4.0 * y));
} else {
tmp = ((-4.0 * z) * 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) :: tmp
if ((z * z) <= 4d+295) then
tmp = (x * x) - (((z * z) - t) * (4.0d0 * y))
else
tmp = (((-4.0d0) * z) * y) * z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 4e+295) {
tmp = (x * x) - (((z * z) - t) * (4.0 * y));
} else {
tmp = ((-4.0 * z) * y) * z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z * z) <= 4e+295: tmp = (x * x) - (((z * z) - t) * (4.0 * y)) else: tmp = ((-4.0 * z) * y) * z return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 4e+295) tmp = Float64(Float64(x * x) - Float64(Float64(Float64(z * z) - t) * Float64(4.0 * y))); else tmp = Float64(Float64(Float64(-4.0 * z) * y) * z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z * z) <= 4e+295) tmp = (x * x) - (((z * z) - t) * (4.0 * y)); else tmp = ((-4.0 * z) * y) * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 4e+295], N[(N[(x * x), $MachinePrecision] - N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(4.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-4.0 * z), $MachinePrecision] * y), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 4 \cdot 10^{+295}:\\
\;\;\;\;x \cdot x - \left(z \cdot z - t\right) \cdot \left(4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-4 \cdot z\right) \cdot y\right) \cdot z\\
\end{array}
\end{array}
if (*.f64 z z) < 3.9999999999999999e295Initial program 96.0%
if 3.9999999999999999e295 < (*.f64 z z) Initial program 74.2%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6481.9
Applied rewrites81.9%
Applied rewrites94.6%
Final simplification95.7%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 2e+60) (fma (* t y) 4.0 (* x x)) (fma (* (* -4.0 y) z) z (* x x))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 2e+60) {
tmp = fma((t * y), 4.0, (x * x));
} else {
tmp = fma(((-4.0 * y) * z), z, (x * x));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 2e+60) tmp = fma(Float64(t * y), 4.0, Float64(x * x)); else tmp = fma(Float64(Float64(-4.0 * y) * z), z, Float64(x * x)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+60], N[(N[(t * y), $MachinePrecision] * 4.0 + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-4.0 * y), $MachinePrecision] * z), $MachinePrecision] * z + N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+60}:\\
\;\;\;\;\mathsf{fma}\left(t \cdot y, 4, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(-4 \cdot y\right) \cdot z, z, x \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 1.9999999999999999e60Initial program 98.6%
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-*.f6492.9
Applied rewrites92.9%
if 1.9999999999999999e60 < (*.f64 z z) Initial program 82.3%
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 t around 0
unpow2N/A
lower-*.f6483.1
Applied rewrites83.1%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 5e+223) (fma (* t y) 4.0 (* x x)) (* (* (* -4.0 z) y) z)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 5e+223) {
tmp = fma((t * y), 4.0, (x * x));
} else {
tmp = ((-4.0 * z) * y) * z;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 5e+223) tmp = fma(Float64(t * y), 4.0, Float64(x * x)); else tmp = Float64(Float64(Float64(-4.0 * z) * y) * z); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e+223], N[(N[(t * y), $MachinePrecision] * 4.0 + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-4.0 * z), $MachinePrecision] * y), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+223}:\\
\;\;\;\;\mathsf{fma}\left(t \cdot y, 4, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-4 \cdot z\right) \cdot y\right) \cdot z\\
\end{array}
\end{array}
if (*.f64 z z) < 4.99999999999999985e223Initial program 96.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-*.f6485.4
Applied rewrites85.4%
if 4.99999999999999985e223 < (*.f64 z z) Initial program 77.8%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6478.0
Applied rewrites78.0%
Applied rewrites88.2%
Final simplification86.1%
(FPCore (x y z t) :precision binary64 (if (<= (* x x) 8.5e+73) (* t (* 4.0 y)) (* x x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 8.5e+73) {
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 * x) <= 8.5d+73) 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 * x) <= 8.5e+73) {
tmp = t * (4.0 * y);
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x * x) <= 8.5e+73: tmp = t * (4.0 * y) else: tmp = x * x return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x * x) <= 8.5e+73) 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 * x) <= 8.5e+73) tmp = t * (4.0 * y); else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x * x), $MachinePrecision], 8.5e+73], N[(t * N[(4.0 * y), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 8.5 \cdot 10^{+73}:\\
\;\;\;\;t \cdot \left(4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 8.4999999999999998e73Initial program 94.3%
Taylor expanded in t around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6449.5
Applied rewrites49.5%
if 8.4999999999999998e73 < (*.f64 x x) Initial program 88.5%
Taylor expanded in y around 0
unpow2N/A
lower-*.f6477.0
Applied rewrites77.0%
Final simplification62.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 91.6%
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 2024249
(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))))