
(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 13 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 (<= (* 4.0 y) -5e-120)
(fma t_1 (* -4.0 y) (* x x))
(if (<= (* 4.0 y) 5e+81)
(fma (* (* -4.0 y) z) z (fma (* (- t) y) -4.0 (* x x)))
(fma 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 ((4.0 * y) <= -5e-120) {
tmp = fma(t_1, (-4.0 * y), (x * x));
} else if ((4.0 * y) <= 5e+81) {
tmp = fma(((-4.0 * y) * z), z, fma((-t * y), -4.0, (x * x)));
} else {
tmp = fma(x, x, ((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(4.0 * y) <= -5e-120) tmp = fma(t_1, Float64(-4.0 * y), Float64(x * x)); elseif (Float64(4.0 * y) <= 5e+81) 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(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[(4.0 * y), $MachinePrecision], -5e-120], N[(t$95$1 * N[(-4.0 * y), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(4.0 * y), $MachinePrecision], 5e+81], 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[(t$95$1 * y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot z - t\\
\mathbf{if}\;4 \cdot y \leq -5 \cdot 10^{-120}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, -4 \cdot y, x \cdot x\right)\\
\mathbf{elif}\;4 \cdot y \leq 5 \cdot 10^{+81}:\\
\;\;\;\;\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(t\_1 \cdot y\right) \cdot -4\right)\\
\end{array}
\end{array}
if (*.f64 y #s(literal 4 binary64)) < -5.00000000000000007e-120Initial program 97.8%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval98.9
Applied rewrites98.9%
if -5.00000000000000007e-120 < (*.f64 y #s(literal 4 binary64)) < 4.9999999999999998e81Initial program 88.4%
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.9%
if 4.9999999999999998e81 < (*.f64 y #s(literal 4 binary64)) Initial program 83.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-eval95.8
Applied rewrites95.8%
Final simplification98.8%
(FPCore (x y z t)
:precision binary64
(if (<= (* z z) 5e+36)
(fma (- t) (* -4.0 y) (* x x))
(if (<= (* z z) 2e+293)
(fma (* z z) (* -4.0 y) (* x x))
(* (* (* -4.0 z) y) z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 5e+36) {
tmp = fma(-t, (-4.0 * y), (x * x));
} else if ((z * z) <= 2e+293) {
tmp = fma((z * z), (-4.0 * 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) <= 5e+36) tmp = fma(Float64(-t), Float64(-4.0 * y), Float64(x * x)); elseif (Float64(z * z) <= 2e+293) tmp = fma(Float64(z * z), Float64(-4.0 * 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], 5e+36], N[((-t) * N[(-4.0 * y), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 2e+293], N[(N[(z * z), $MachinePrecision] * N[(-4.0 * y), $MachinePrecision] + 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^{+36}:\\
\;\;\;\;\mathsf{fma}\left(-t, -4 \cdot y, x \cdot x\right)\\
\mathbf{elif}\;z \cdot z \leq 2 \cdot 10^{+293}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot z, -4 \cdot 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) < 4.99999999999999977e36Initial program 98.5%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval99.2
Applied rewrites99.2%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6493.3
Applied rewrites93.3%
if 4.99999999999999977e36 < (*.f64 z z) < 1.9999999999999998e293Initial program 92.8%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval96.3
Applied rewrites96.3%
Taylor expanded in t around 0
unpow2N/A
lower-*.f6482.8
Applied rewrites82.8%
if 1.9999999999999998e293 < (*.f64 z z) Initial program 72.7%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6479.0
Applied rewrites79.0%
Applied rewrites90.4%
(FPCore (x y z t)
:precision binary64
(if (<= (* z z) 2e+106)
(fma (- t) (* -4.0 y) (* x x))
(if (<= (* z z) 2e+293)
(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+106) {
tmp = fma(-t, (-4.0 * y), (x * x));
} else if ((z * z) <= 2e+293) {
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+106) tmp = fma(Float64(-t), Float64(-4.0 * y), Float64(x * x)); elseif (Float64(z * z) <= 2e+293) tmp = fma(-4.0, Float64(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+106], N[((-t) * N[(-4.0 * y), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 2e+293], N[(-4.0 * N[(N[(z * z), $MachinePrecision] * y), $MachinePrecision] + 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^{+106}:\\
\;\;\;\;\mathsf{fma}\left(-t, -4 \cdot y, x \cdot x\right)\\
\mathbf{elif}\;z \cdot z \leq 2 \cdot 10^{+293}:\\
\;\;\;\;\mathsf{fma}\left(-4, \left(z \cdot z\right) \cdot 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) < 2.00000000000000018e106Initial program 97.9%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval99.3
Applied rewrites99.3%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6491.8
Applied rewrites91.8%
if 2.00000000000000018e106 < (*.f64 z z) < 1.9999999999999998e293Initial program 93.3%
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-*.f6482.8
Applied rewrites82.8%
if 1.9999999999999998e293 < (*.f64 z z) Initial program 72.7%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6479.0
Applied rewrites79.0%
Applied rewrites90.4%
(FPCore (x y z t) :precision binary64 (if (<= t 2.8e-95) (fma x x (* (fma (* z y) z (* (- t) y)) -4.0)) (fma x x (* (* (- (* z z) t) y) -4.0))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= 2.8e-95) {
tmp = fma(x, x, (fma((z * y), z, (-t * y)) * -4.0));
} else {
tmp = fma(x, x, ((((z * z) - t) * y) * -4.0));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (t <= 2.8e-95) tmp = fma(x, x, Float64(fma(Float64(z * y), z, Float64(Float64(-t) * y)) * -4.0)); 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[t, 2.8e-95], N[(x * x + N[(N[(N[(z * y), $MachinePrecision] * z + N[((-t) * y), $MachinePrecision]), $MachinePrecision] * -4.0), $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}\;t \leq 2.8 \cdot 10^{-95}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \mathsf{fma}\left(z \cdot y, z, \left(-t\right) \cdot y\right) \cdot -4\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 t < 2.7999999999999999e-95Initial program 91.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-eval92.9
Applied rewrites92.9%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-negN/A
distribute-rgt-inN/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-neg.f6497.5
Applied rewrites97.5%
if 2.7999999999999999e-95 < t Initial program 90.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-eval94.7
Applied rewrites94.7%
Final simplification96.5%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 2e+293) (fma (- (* z z) t) (* -4.0 y) (* x x)) (* (* (* -4.0 z) y) z)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 2e+293) {
tmp = fma(((z * z) - t), (-4.0 * 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+293) tmp = fma(Float64(Float64(z * z) - t), Float64(-4.0 * 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+293], N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(-4.0 * y), $MachinePrecision] + 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^{+293}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot z - t, -4 \cdot 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.9999999999999998e293Initial program 96.8%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval98.4
Applied rewrites98.4%
if 1.9999999999999998e293 < (*.f64 z z) Initial program 72.7%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6479.0
Applied rewrites79.0%
Applied rewrites90.4%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 2e+293) (fma x x (* (* (- (* z z) t) y) -4.0)) (* (* (* -4.0 z) y) z)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 2e+293) {
tmp = fma(x, x, ((((z * z) - t) * y) * -4.0));
} else {
tmp = ((-4.0 * z) * y) * z;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 2e+293) tmp = fma(x, x, Float64(Float64(Float64(Float64(z * z) - t) * y) * -4.0)); 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+293], N[(x * x + N[(N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * y), $MachinePrecision] * -4.0), $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^{+293}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(\left(z \cdot z - t\right) \cdot y\right) \cdot -4\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-4 \cdot z\right) \cdot y\right) \cdot z\\
\end{array}
\end{array}
if (*.f64 z z) < 1.9999999999999998e293Initial program 96.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-eval98.4
Applied rewrites98.4%
if 1.9999999999999998e293 < (*.f64 z z) Initial program 72.7%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6479.0
Applied rewrites79.0%
Applied rewrites90.4%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 2e+200) (fma (- t) (* -4.0 y) (* x x)) (* (* (* -4.0 z) y) z)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 2e+200) {
tmp = fma(-t, (-4.0 * 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+200) tmp = fma(Float64(-t), Float64(-4.0 * 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+200], N[((-t) * N[(-4.0 * y), $MachinePrecision] + 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^{+200}:\\
\;\;\;\;\mathsf{fma}\left(-t, -4 \cdot 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.9999999999999999e200Initial program 96.9%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval98.7
Applied rewrites98.7%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6488.2
Applied rewrites88.2%
if 1.9999999999999999e200 < (*.f64 z z) Initial program 79.2%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6476.2
Applied rewrites76.2%
Applied rewrites84.4%
(FPCore (x y z t) :precision binary64 (if (<= x 3.4e-200) (* t (* 4.0 y)) (if (<= x 1.52e+94) (* (* (* -4.0 z) y) z) (* x x))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= 3.4e-200) {
tmp = t * (4.0 * y);
} else if (x <= 1.52e+94) {
tmp = ((-4.0 * z) * y) * z;
} 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.4d-200) then
tmp = t * (4.0d0 * y)
else if (x <= 1.52d+94) then
tmp = (((-4.0d0) * z) * y) * z
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.4e-200) {
tmp = t * (4.0 * y);
} else if (x <= 1.52e+94) {
tmp = ((-4.0 * z) * y) * z;
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= 3.4e-200: tmp = t * (4.0 * y) elif x <= 1.52e+94: tmp = ((-4.0 * z) * y) * z else: tmp = x * x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= 3.4e-200) tmp = Float64(t * Float64(4.0 * y)); elseif (x <= 1.52e+94) tmp = Float64(Float64(Float64(-4.0 * z) * y) * z); else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= 3.4e-200) tmp = t * (4.0 * y); elseif (x <= 1.52e+94) tmp = ((-4.0 * z) * y) * z; else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, 3.4e-200], N[(t * N[(4.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.52e+94], N[(N[(N[(-4.0 * z), $MachinePrecision] * y), $MachinePrecision] * z), $MachinePrecision], N[(x * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.4 \cdot 10^{-200}:\\
\;\;\;\;t \cdot \left(4 \cdot y\right)\\
\mathbf{elif}\;x \leq 1.52 \cdot 10^{+94}:\\
\;\;\;\;\left(\left(-4 \cdot z\right) \cdot y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if x < 3.4000000000000003e-200Initial program 93.0%
Taylor expanded in t around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6437.7
Applied rewrites37.7%
if 3.4000000000000003e-200 < x < 1.5199999999999999e94Initial program 92.2%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6436.9
Applied rewrites36.9%
Applied rewrites44.3%
if 1.5199999999999999e94 < x Initial program 83.6%
Taylor expanded in y around 0
unpow2N/A
lower-*.f6482.5
Applied rewrites82.5%
Final simplification48.9%
(FPCore (x y z t) :precision binary64 (if (<= x 5e-200) (* t (* 4.0 y)) (if (<= x 4.4e+93) (* (* (* z z) y) -4.0) (* x x))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= 5e-200) {
tmp = t * (4.0 * y);
} else if (x <= 4.4e+93) {
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 <= 5d-200) then
tmp = t * (4.0d0 * y)
else if (x <= 4.4d+93) 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 <= 5e-200) {
tmp = t * (4.0 * y);
} else if (x <= 4.4e+93) {
tmp = ((z * z) * y) * -4.0;
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= 5e-200: tmp = t * (4.0 * y) elif x <= 4.4e+93: tmp = ((z * z) * y) * -4.0 else: tmp = x * x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= 5e-200) tmp = Float64(t * Float64(4.0 * y)); elseif (x <= 4.4e+93) 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 <= 5e-200) tmp = t * (4.0 * y); elseif (x <= 4.4e+93) tmp = ((z * z) * y) * -4.0; else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, 5e-200], N[(t * N[(4.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.4e+93], 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 5 \cdot 10^{-200}:\\
\;\;\;\;t \cdot \left(4 \cdot y\right)\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{+93}:\\
\;\;\;\;\left(\left(z \cdot z\right) \cdot y\right) \cdot -4\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if x < 4.99999999999999991e-200Initial program 93.0%
Taylor expanded in t around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6437.7
Applied rewrites37.7%
if 4.99999999999999991e-200 < x < 4.40000000000000042e93Initial program 93.7%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6437.4
Applied rewrites37.4%
if 4.40000000000000042e93 < x Initial program 82.2%
Taylor expanded in y around 0
unpow2N/A
lower-*.f6481.2
Applied rewrites81.2%
Final simplification47.2%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 2e+200) (fma x x (* (* t y) 4.0)) (* (* (* -4.0 z) y) z)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 2e+200) {
tmp = fma(x, x, ((t * y) * 4.0));
} else {
tmp = ((-4.0 * z) * y) * z;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 2e+200) tmp = fma(x, x, Float64(Float64(t * y) * 4.0)); 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+200], N[(x * x + N[(N[(t * y), $MachinePrecision] * 4.0), $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^{+200}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(t \cdot y\right) \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-4 \cdot z\right) \cdot y\right) \cdot z\\
\end{array}
\end{array}
if (*.f64 z z) < 1.9999999999999999e200Initial program 96.9%
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-eval98.1
Applied rewrites98.1%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6488.2
Applied rewrites88.2%
if 1.9999999999999999e200 < (*.f64 z z) Initial program 79.2%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6476.2
Applied rewrites76.2%
Applied rewrites84.4%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 2e+200) (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) <= 2e+200) {
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) <= 2e+200) 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], 2e+200], 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 2 \cdot 10^{+200}:\\
\;\;\;\;\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) < 1.9999999999999999e200Initial program 96.9%
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-*.f6487.0
Applied rewrites87.0%
if 1.9999999999999999e200 < (*.f64 z z) Initial program 79.2%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6476.2
Applied rewrites76.2%
Applied rewrites84.4%
(FPCore (x y z t) :precision binary64 (if (<= x 6.6e-79) (* t (* 4.0 y)) (* x x)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= 6.6e-79) {
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 <= 6.6d-79) 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 <= 6.6e-79) {
tmp = t * (4.0 * y);
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= 6.6e-79: tmp = t * (4.0 * y) else: tmp = x * x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= 6.6e-79) 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 <= 6.6e-79) tmp = t * (4.0 * y); else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, 6.6e-79], N[(t * N[(4.0 * y), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.6 \cdot 10^{-79}:\\
\;\;\;\;t \cdot \left(4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if x < 6.5999999999999996e-79Initial program 92.9%
Taylor expanded in t around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6438.6
Applied rewrites38.6%
if 6.5999999999999996e-79 < x Initial program 87.1%
Taylor expanded in y around 0
unpow2N/A
lower-*.f6463.4
Applied rewrites63.4%
Final simplification47.5%
(FPCore (x y z t) :precision binary64 (* x x))
double code(double x, double y, double z, double t) {
return x * x;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x * x
end function
public static double code(double x, double y, double z, double t) {
return x * x;
}
def code(x, y, z, t): return x * x
function code(x, y, z, t) return Float64(x * x) end
function tmp = code(x, y, z, t) tmp = x * x; end
code[x_, y_, z_, t_] := N[(x * x), $MachinePrecision]
\begin{array}{l}
\\
x \cdot x
\end{array}
Initial program 90.8%
Taylor expanded in y around 0
unpow2N/A
lower-*.f6444.0
Applied rewrites44.0%
(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 2024271
(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))))