
(FPCore (x y z t) :precision binary64 :pre TRUE (- (* 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)
use fmin_fmax_functions
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]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = (x * x) - ((y * (4)) * ((z * z) - t)) END code
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 :pre TRUE (- (* 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)
use fmin_fmax_functions
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]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = (x * x) - ((y * (4)) * ((z * z) - t)) END code
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
(FPCore (x y z t) :precision binary64 :pre TRUE (if (<= (* y 4.0) 5e-13) (fma z (* (* z y) -4.0) (fma (* t 4.0) y (* x x))) (fma x x (* (- t (* z z)) (* 4.0 y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y * 4.0) <= 5e-13) {
tmp = fma(z, ((z * y) * -4.0), fma((t * 4.0), y, (x * x)));
} else {
tmp = fma(x, x, ((t - (z * z)) * (4.0 * y)));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(y * 4.0) <= 5e-13) tmp = fma(z, Float64(Float64(z * y) * -4.0), fma(Float64(t * 4.0), y, Float64(x * x))); else tmp = fma(x, x, Float64(Float64(t - Float64(z * z)) * Float64(4.0 * y))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(y * 4.0), $MachinePrecision], 5e-13], N[(z * N[(N[(z * y), $MachinePrecision] * -4.0), $MachinePrecision] + N[(N[(t * 4.0), $MachinePrecision] * y + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * x + N[(N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision] * N[(4.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = LET tmp = IF ((y * (4)) <= (499999999999999989943323814627807683626421753064761333007481880486011505126953125e-93)) THEN ((z * ((z * y) * (-4))) + (((t * (4)) * y) + (x * x))) ELSE ((x * x) + ((t - (z * z)) * ((4) * y))) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;y \cdot 4 \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(z, \left(z \cdot y\right) \cdot -4, \mathsf{fma}\left(t \cdot 4, y, x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(t - z \cdot z\right) \cdot \left(4 \cdot y\right)\right)\\
\end{array}
if (*.f64 y #s(literal 4 binary64)) < 4.9999999999999999e-13Initial program 90.6%
Applied rewrites95.8%
if 4.9999999999999999e-13 < (*.f64 y #s(literal 4 binary64)) Initial program 90.6%
Applied rewrites92.7%
(FPCore (x y z t) :precision binary64 :pre TRUE (if (<= (fabs z) 4.553313464441803e+204) (fma (* -4.0 y) (- (* (fabs z) (fabs z)) t) (* x x)) (fma (fabs z) (* (* (fabs z) y) -4.0) (* 4.0 (* t y)))))
double code(double x, double y, double z, double t) {
double tmp;
if (fabs(z) <= 4.553313464441803e+204) {
tmp = fma((-4.0 * y), ((fabs(z) * fabs(z)) - t), (x * x));
} else {
tmp = fma(fabs(z), ((fabs(z) * y) * -4.0), (4.0 * (t * y)));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (abs(z) <= 4.553313464441803e+204) tmp = fma(Float64(-4.0 * y), Float64(Float64(abs(z) * abs(z)) - t), Float64(x * x)); else tmp = fma(abs(z), Float64(Float64(abs(z) * y) * -4.0), Float64(4.0 * Float64(t * y))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[Abs[z], $MachinePrecision], 4.553313464441803e+204], N[(N[(-4.0 * y), $MachinePrecision] * N[(N[(N[Abs[z], $MachinePrecision] * N[Abs[z], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[Abs[z], $MachinePrecision] * N[(N[(N[Abs[z], $MachinePrecision] * y), $MachinePrecision] * -4.0), $MachinePrecision] + N[(4.0 * N[(t * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = LET tmp = IF ((abs(z)) <= (4553313464441803095702017080874442897530261790610683880936152257060862062836227398642403794392205383831373657791293678248013195343041934433486540824526049739045745406568539878196053709330357813653270429696)) THEN ((((-4) * y) * (((abs(z)) * (abs(z))) - t)) + (x * x)) ELSE (((abs(z)) * (((abs(z)) * y) * (-4))) + ((4) * (t * y))) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;\left|z\right| \leq 4.553313464441803 \cdot 10^{+204}:\\
\;\;\;\;\mathsf{fma}\left(-4 \cdot y, \left|z\right| \cdot \left|z\right| - t, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left|z\right|, \left(\left|z\right| \cdot y\right) \cdot -4, 4 \cdot \left(t \cdot y\right)\right)\\
\end{array}
if z < 4.5533134644418031e204Initial program 90.6%
Applied rewrites91.6%
if 4.5533134644418031e204 < z Initial program 90.6%
Applied rewrites95.8%
Taylor expanded in x around 0
Applied rewrites63.1%
(FPCore (x y z t) :precision binary64 :pre TRUE (if (<= (* z z) 3.459163940415505e+267) (fma (* -4.0 y) (- (* z z) t) (* x x)) (fma x x (* (- t (* z z)) (* 4.0 y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 3.459163940415505e+267) {
tmp = fma((-4.0 * y), ((z * z) - t), (x * x));
} else {
tmp = fma(x, x, ((t - (z * z)) * (4.0 * y)));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 3.459163940415505e+267) tmp = fma(Float64(-4.0 * y), Float64(Float64(z * z) - t), Float64(x * x)); else tmp = fma(x, x, Float64(Float64(t - Float64(z * z)) * Float64(4.0 * y))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 3.459163940415505e+267], N[(N[(-4.0 * y), $MachinePrecision] * N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(x * x + N[(N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision] * N[(4.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = LET tmp = IF ((z * z) <= (3459163940415505154807243167145246733638957054914899056796149349151503158639401562216956921212260941731586295517881620060871458325638565914945780935367462669091573565733790389311719644459867358991729700294134409948470761764934080832587912644085449904199498676924579840)) THEN ((((-4) * y) * ((z * z) - t)) + (x * x)) ELSE ((x * x) + ((t - (z * z)) * ((4) * y))) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 3.459163940415505 \cdot 10^{+267}:\\
\;\;\;\;\mathsf{fma}\left(-4 \cdot y, z \cdot z - t, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(t - z \cdot z\right) \cdot \left(4 \cdot y\right)\right)\\
\end{array}
if (*.f64 z z) < 3.4591639404155052e267Initial program 90.6%
Applied rewrites91.6%
if 3.4591639404155052e267 < (*.f64 z z) Initial program 90.6%
Applied rewrites92.7%
(FPCore (x y z t) :precision binary64 :pre TRUE (fma x x (* (- t (* z z)) (* 4.0 y))))
double code(double x, double y, double z, double t) {
return fma(x, x, ((t - (z * z)) * (4.0 * y)));
}
function code(x, y, z, t) return fma(x, x, Float64(Float64(t - Float64(z * z)) * Float64(4.0 * y))) end
code[x_, y_, z_, t_] := N[(x * x + N[(N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision] * N[(4.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = (x * x) + ((t - (z * z)) * ((4) * y)) END code
\mathsf{fma}\left(x, x, \left(t - z \cdot z\right) \cdot \left(4 \cdot y\right)\right)
Initial program 90.6%
Applied rewrites92.7%
(FPCore (x y z t) :precision binary64 :pre TRUE (fma t (* 4.0 y) (* x x)))
double code(double x, double y, double z, double t) {
return fma(t, (4.0 * y), (x * x));
}
function code(x, y, z, t) return fma(t, Float64(4.0 * y), Float64(x * x)) end
code[x_, y_, z_, t_] := N[(t * N[(4.0 * y), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = (t * ((4) * y)) + (x * x) END code
\mathsf{fma}\left(t, 4 \cdot y, x \cdot x\right)
Initial program 90.6%
Applied rewrites92.7%
Taylor expanded in z around 0
Applied rewrites67.2%
Applied rewrites67.5%
(FPCore (x y z t) :precision binary64 :pre TRUE (fma x x (* t (* 4.0 y))))
double code(double x, double y, double z, double t) {
return fma(x, x, (t * (4.0 * y)));
}
function code(x, y, z, t) return fma(x, x, Float64(t * Float64(4.0 * y))) end
code[x_, y_, z_, t_] := N[(x * x + N[(t * N[(4.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = (x * x) + (t * ((4) * y)) END code
\mathsf{fma}\left(x, x, t \cdot \left(4 \cdot y\right)\right)
Initial program 90.6%
Applied rewrites92.7%
Taylor expanded in z around 0
Applied rewrites67.2%
(FPCore (x y z t) :precision binary64 :pre TRUE (* t (* 4.0 y)))
double code(double x, double y, double z, double t) {
return t * (4.0 * y);
}
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = t * (4.0d0 * y)
end function
public static double code(double x, double y, double z, double t) {
return t * (4.0 * y);
}
def code(x, y, z, t): return t * (4.0 * y)
function code(x, y, z, t) return Float64(t * Float64(4.0 * y)) end
function tmp = code(x, y, z, t) tmp = t * (4.0 * y); end
code[x_, y_, z_, t_] := N[(t * N[(4.0 * y), $MachinePrecision]), $MachinePrecision]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = t * ((4) * y) END code
t \cdot \left(4 \cdot y\right)
Initial program 90.6%
Taylor expanded in t around inf
Applied rewrites31.1%
Applied rewrites31.1%
(FPCore (x y z t) :precision binary64 :pre TRUE (* 4.0 (* t y)))
double code(double x, double y, double z, double t) {
return 4.0 * (t * y);
}
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = 4.0d0 * (t * y)
end function
public static double code(double x, double y, double z, double t) {
return 4.0 * (t * y);
}
def code(x, y, z, t): return 4.0 * (t * y)
function code(x, y, z, t) return Float64(4.0 * Float64(t * y)) end
function tmp = code(x, y, z, t) tmp = 4.0 * (t * y); end
code[x_, y_, z_, t_] := N[(4.0 * N[(t * y), $MachinePrecision]), $MachinePrecision]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = (4) * (t * y) END code
4 \cdot \left(t \cdot y\right)
Initial program 90.6%
Taylor expanded in t around inf
Applied rewrites31.1%
herbie shell --seed 2026092
(FPCore (x y z t)
:name "Graphics.Rasterific.Shading:$sradialGradientWithFocusShader from Rasterific-0.6.1, B"
:precision binary64
(- (* x x) (* (* y 4.0) (- (* z z) t))))