
(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 12 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}
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
:precision binary64
(if (<= z_m 3.6e+138)
(fma x x (* -4.0 (* y (- (* z_m z_m) t))))
(if (<= z_m 2.8e+197)
(fma (* (* -4.0 y) z_m) z_m (* x x))
(/ 1.0 (/ (/ -0.25 z_m) (* y z_m))))))z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 3.6e+138) {
tmp = fma(x, x, (-4.0 * (y * ((z_m * z_m) - t))));
} else if (z_m <= 2.8e+197) {
tmp = fma(((-4.0 * y) * z_m), z_m, (x * x));
} else {
tmp = 1.0 / ((-0.25 / z_m) / (y * z_m));
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 3.6e+138) tmp = fma(x, x, Float64(-4.0 * Float64(y * Float64(Float64(z_m * z_m) - t)))); elseif (z_m <= 2.8e+197) tmp = fma(Float64(Float64(-4.0 * y) * z_m), z_m, Float64(x * x)); else tmp = Float64(1.0 / Float64(Float64(-0.25 / z_m) / Float64(y * z_m))); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 3.6e+138], N[(x * x + N[(-4.0 * N[(y * N[(N[(z$95$m * z$95$m), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z$95$m, 2.8e+197], N[(N[(N[(-4.0 * y), $MachinePrecision] * z$95$m), $MachinePrecision] * z$95$m + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(-0.25 / z$95$m), $MachinePrecision] / N[(y * z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 3.6 \cdot 10^{+138}:\\
\;\;\;\;\mathsf{fma}\left(x, x, -4 \cdot \left(y \cdot \left(z\_m \cdot z\_m - t\right)\right)\right)\\
\mathbf{elif}\;z\_m \leq 2.8 \cdot 10^{+197}:\\
\;\;\;\;\mathsf{fma}\left(\left(-4 \cdot y\right) \cdot z\_m, z\_m, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\frac{-0.25}{z\_m}}{y \cdot z\_m}}\\
\end{array}
\end{array}
if z < 3.6000000000000001e138Initial program 92.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-eval95.6
Applied rewrites95.6%
if 3.6000000000000001e138 < z < 2.7999999999999999e197Initial program 67.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 rewrites100.0%
Taylor expanded in t around 0
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
if 2.7999999999999999e197 < z 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-eval95.8
Applied rewrites95.8%
Applied rewrites95.8%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6495.8
Applied rewrites95.8%
Applied rewrites95.8%
Final simplification95.8%
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
:precision binary64
(if (<= (* z_m z_m) 1e-6)
(fma x x (* 4.0 (* y t)))
(if (<= (* z_m z_m) 5e+261)
(fma -4.0 (* y (* z_m z_m)) (* x x))
(* (* (* -4.0 y) z_m) z_m))))z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if ((z_m * z_m) <= 1e-6) {
tmp = fma(x, x, (4.0 * (y * t)));
} else if ((z_m * z_m) <= 5e+261) {
tmp = fma(-4.0, (y * (z_m * z_m)), (x * x));
} else {
tmp = ((-4.0 * y) * z_m) * z_m;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (Float64(z_m * z_m) <= 1e-6) tmp = fma(x, x, Float64(4.0 * Float64(y * t))); elseif (Float64(z_m * z_m) <= 5e+261) tmp = fma(-4.0, Float64(y * Float64(z_m * z_m)), Float64(x * x)); else tmp = Float64(Float64(Float64(-4.0 * y) * z_m) * z_m); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[N[(z$95$m * z$95$m), $MachinePrecision], 1e-6], N[(x * x + N[(4.0 * N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z$95$m * z$95$m), $MachinePrecision], 5e+261], N[(-4.0 * N[(y * N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-4.0 * y), $MachinePrecision] * z$95$m), $MachinePrecision] * z$95$m), $MachinePrecision]]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \cdot z\_m \leq 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(x, x, 4 \cdot \left(y \cdot t\right)\right)\\
\mathbf{elif}\;z\_m \cdot z\_m \leq 5 \cdot 10^{+261}:\\
\;\;\;\;\mathsf{fma}\left(-4, y \cdot \left(z\_m \cdot z\_m\right), x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-4 \cdot y\right) \cdot z\_m\right) \cdot z\_m\\
\end{array}
\end{array}
if (*.f64 z z) < 9.99999999999999955e-7Initial 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.2
Applied rewrites99.2%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6496.4
Applied rewrites96.4%
if 9.99999999999999955e-7 < (*.f64 z z) < 5.0000000000000001e261Initial program 99.9%
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-*.f6488.2
Applied rewrites88.2%
if 5.0000000000000001e261 < (*.f64 z z) Initial program 74.0%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6480.7
Applied rewrites80.7%
Applied rewrites86.9%
Final simplification91.6%
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
:precision binary64
(if (<= (* z_m z_m) 1e-12)
(fma x x (* 4.0 (* y t)))
(if (<= (* z_m z_m) 5e+261)
(* (* 4.0 y) (- t (* z_m z_m)))
(* (* (* -4.0 y) z_m) z_m))))z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if ((z_m * z_m) <= 1e-12) {
tmp = fma(x, x, (4.0 * (y * t)));
} else if ((z_m * z_m) <= 5e+261) {
tmp = (4.0 * y) * (t - (z_m * z_m));
} else {
tmp = ((-4.0 * y) * z_m) * z_m;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (Float64(z_m * z_m) <= 1e-12) tmp = fma(x, x, Float64(4.0 * Float64(y * t))); elseif (Float64(z_m * z_m) <= 5e+261) tmp = Float64(Float64(4.0 * y) * Float64(t - Float64(z_m * z_m))); else tmp = Float64(Float64(Float64(-4.0 * y) * z_m) * z_m); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[N[(z$95$m * z$95$m), $MachinePrecision], 1e-12], N[(x * x + N[(4.0 * N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z$95$m * z$95$m), $MachinePrecision], 5e+261], N[(N[(4.0 * y), $MachinePrecision] * N[(t - N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-4.0 * y), $MachinePrecision] * z$95$m), $MachinePrecision] * z$95$m), $MachinePrecision]]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \cdot z\_m \leq 10^{-12}:\\
\;\;\;\;\mathsf{fma}\left(x, x, 4 \cdot \left(y \cdot t\right)\right)\\
\mathbf{elif}\;z\_m \cdot z\_m \leq 5 \cdot 10^{+261}:\\
\;\;\;\;\left(4 \cdot y\right) \cdot \left(t - z\_m \cdot z\_m\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-4 \cdot y\right) \cdot z\_m\right) \cdot z\_m\\
\end{array}
\end{array}
if (*.f64 z z) < 9.9999999999999998e-13Initial 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.1
Applied rewrites99.1%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6496.3
Applied rewrites96.3%
if 9.9999999999999998e-13 < (*.f64 z z) < 5.0000000000000001e261Initial program 99.9%
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.f6474.2
Applied rewrites74.2%
Applied rewrites74.2%
if 5.0000000000000001e261 < (*.f64 z z) Initial program 74.0%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6480.7
Applied rewrites80.7%
Applied rewrites86.9%
Final simplification88.1%
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
:precision binary64
(if (<= (* z_m z_m) 1e-12)
(fma x x (* 4.0 (* y t)))
(if (<= (* z_m z_m) 5e+261)
(* (* (fma z_m z_m (- t)) y) -4.0)
(* (* (* -4.0 y) z_m) z_m))))z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if ((z_m * z_m) <= 1e-12) {
tmp = fma(x, x, (4.0 * (y * t)));
} else if ((z_m * z_m) <= 5e+261) {
tmp = (fma(z_m, z_m, -t) * y) * -4.0;
} else {
tmp = ((-4.0 * y) * z_m) * z_m;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (Float64(z_m * z_m) <= 1e-12) tmp = fma(x, x, Float64(4.0 * Float64(y * t))); elseif (Float64(z_m * z_m) <= 5e+261) tmp = Float64(Float64(fma(z_m, z_m, Float64(-t)) * y) * -4.0); else tmp = Float64(Float64(Float64(-4.0 * y) * z_m) * z_m); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[N[(z$95$m * z$95$m), $MachinePrecision], 1e-12], N[(x * x + N[(4.0 * N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z$95$m * z$95$m), $MachinePrecision], 5e+261], N[(N[(N[(z$95$m * z$95$m + (-t)), $MachinePrecision] * y), $MachinePrecision] * -4.0), $MachinePrecision], N[(N[(N[(-4.0 * y), $MachinePrecision] * z$95$m), $MachinePrecision] * z$95$m), $MachinePrecision]]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \cdot z\_m \leq 10^{-12}:\\
\;\;\;\;\mathsf{fma}\left(x, x, 4 \cdot \left(y \cdot t\right)\right)\\
\mathbf{elif}\;z\_m \cdot z\_m \leq 5 \cdot 10^{+261}:\\
\;\;\;\;\left(\mathsf{fma}\left(z\_m, z\_m, -t\right) \cdot y\right) \cdot -4\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-4 \cdot y\right) \cdot z\_m\right) \cdot z\_m\\
\end{array}
\end{array}
if (*.f64 z z) < 9.9999999999999998e-13Initial 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.1
Applied rewrites99.1%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6496.3
Applied rewrites96.3%
if 9.9999999999999998e-13 < (*.f64 z z) < 5.0000000000000001e261Initial program 99.9%
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.f6474.2
Applied rewrites74.2%
if 5.0000000000000001e261 < (*.f64 z z) Initial program 74.0%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6480.7
Applied rewrites80.7%
Applied rewrites86.9%
Final simplification88.1%
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
:precision binary64
(let* ((t_1 (* (* 4.0 y) t)))
(if (<= z_m 4e-234)
t_1
(if (<= z_m 2.1e-26)
(* x x)
(if (<= z_m 0.0015) t_1 (* (* (* -4.0 y) z_m) z_m))))))z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double t_1 = (4.0 * y) * t;
double tmp;
if (z_m <= 4e-234) {
tmp = t_1;
} else if (z_m <= 2.1e-26) {
tmp = x * x;
} else if (z_m <= 0.0015) {
tmp = t_1;
} else {
tmp = ((-4.0 * y) * z_m) * z_m;
}
return tmp;
}
z_m = abs(z)
real(8) function code(x, y, z_m, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = (4.0d0 * y) * t
if (z_m <= 4d-234) then
tmp = t_1
else if (z_m <= 2.1d-26) then
tmp = x * x
else if (z_m <= 0.0015d0) then
tmp = t_1
else
tmp = (((-4.0d0) * y) * z_m) * z_m
end if
code = tmp
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m, double t) {
double t_1 = (4.0 * y) * t;
double tmp;
if (z_m <= 4e-234) {
tmp = t_1;
} else if (z_m <= 2.1e-26) {
tmp = x * x;
} else if (z_m <= 0.0015) {
tmp = t_1;
} else {
tmp = ((-4.0 * y) * z_m) * z_m;
}
return tmp;
}
z_m = math.fabs(z) def code(x, y, z_m, t): t_1 = (4.0 * y) * t tmp = 0 if z_m <= 4e-234: tmp = t_1 elif z_m <= 2.1e-26: tmp = x * x elif z_m <= 0.0015: tmp = t_1 else: tmp = ((-4.0 * y) * z_m) * z_m return tmp
z_m = abs(z) function code(x, y, z_m, t) t_1 = Float64(Float64(4.0 * y) * t) tmp = 0.0 if (z_m <= 4e-234) tmp = t_1; elseif (z_m <= 2.1e-26) tmp = Float64(x * x); elseif (z_m <= 0.0015) tmp = t_1; else tmp = Float64(Float64(Float64(-4.0 * y) * z_m) * z_m); end return tmp end
z_m = abs(z); function tmp_2 = code(x, y, z_m, t) t_1 = (4.0 * y) * t; tmp = 0.0; if (z_m <= 4e-234) tmp = t_1; elseif (z_m <= 2.1e-26) tmp = x * x; elseif (z_m <= 0.0015) tmp = t_1; else tmp = ((-4.0 * y) * z_m) * z_m; end tmp_2 = tmp; end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_, t_] := Block[{t$95$1 = N[(N[(4.0 * y), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[z$95$m, 4e-234], t$95$1, If[LessEqual[z$95$m, 2.1e-26], N[(x * x), $MachinePrecision], If[LessEqual[z$95$m, 0.0015], t$95$1, N[(N[(N[(-4.0 * y), $MachinePrecision] * z$95$m), $MachinePrecision] * z$95$m), $MachinePrecision]]]]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
t_1 := \left(4 \cdot y\right) \cdot t\\
\mathbf{if}\;z\_m \leq 4 \cdot 10^{-234}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z\_m \leq 2.1 \cdot 10^{-26}:\\
\;\;\;\;x \cdot x\\
\mathbf{elif}\;z\_m \leq 0.0015:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-4 \cdot y\right) \cdot z\_m\right) \cdot z\_m\\
\end{array}
\end{array}
if z < 3.9999999999999998e-234 or 2.10000000000000008e-26 < z < 0.0015Initial program 89.7%
Taylor expanded in t around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6433.9
Applied rewrites33.9%
if 3.9999999999999998e-234 < z < 2.10000000000000008e-26Initial program 100.0%
Taylor expanded in y around 0
unpow2N/A
lower-*.f6466.0
Applied rewrites66.0%
if 0.0015 < z Initial program 90.8%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6474.6
Applied rewrites74.6%
Applied rewrites76.1%
Final simplification49.4%
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
:precision binary64
(let* ((t_1 (* (* 4.0 y) t)))
(if (<= z_m 4e-234)
t_1
(if (<= z_m 2.1e-26)
(* x x)
(if (<= z_m 0.0015) t_1 (* (* y (* z_m z_m)) -4.0))))))z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double t_1 = (4.0 * y) * t;
double tmp;
if (z_m <= 4e-234) {
tmp = t_1;
} else if (z_m <= 2.1e-26) {
tmp = x * x;
} else if (z_m <= 0.0015) {
tmp = t_1;
} else {
tmp = (y * (z_m * z_m)) * -4.0;
}
return tmp;
}
z_m = abs(z)
real(8) function code(x, y, z_m, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = (4.0d0 * y) * t
if (z_m <= 4d-234) then
tmp = t_1
else if (z_m <= 2.1d-26) then
tmp = x * x
else if (z_m <= 0.0015d0) then
tmp = t_1
else
tmp = (y * (z_m * z_m)) * (-4.0d0)
end if
code = tmp
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m, double t) {
double t_1 = (4.0 * y) * t;
double tmp;
if (z_m <= 4e-234) {
tmp = t_1;
} else if (z_m <= 2.1e-26) {
tmp = x * x;
} else if (z_m <= 0.0015) {
tmp = t_1;
} else {
tmp = (y * (z_m * z_m)) * -4.0;
}
return tmp;
}
z_m = math.fabs(z) def code(x, y, z_m, t): t_1 = (4.0 * y) * t tmp = 0 if z_m <= 4e-234: tmp = t_1 elif z_m <= 2.1e-26: tmp = x * x elif z_m <= 0.0015: tmp = t_1 else: tmp = (y * (z_m * z_m)) * -4.0 return tmp
z_m = abs(z) function code(x, y, z_m, t) t_1 = Float64(Float64(4.0 * y) * t) tmp = 0.0 if (z_m <= 4e-234) tmp = t_1; elseif (z_m <= 2.1e-26) tmp = Float64(x * x); elseif (z_m <= 0.0015) tmp = t_1; else tmp = Float64(Float64(y * Float64(z_m * z_m)) * -4.0); end return tmp end
z_m = abs(z); function tmp_2 = code(x, y, z_m, t) t_1 = (4.0 * y) * t; tmp = 0.0; if (z_m <= 4e-234) tmp = t_1; elseif (z_m <= 2.1e-26) tmp = x * x; elseif (z_m <= 0.0015) tmp = t_1; else tmp = (y * (z_m * z_m)) * -4.0; end tmp_2 = tmp; end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_, t_] := Block[{t$95$1 = N[(N[(4.0 * y), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[z$95$m, 4e-234], t$95$1, If[LessEqual[z$95$m, 2.1e-26], N[(x * x), $MachinePrecision], If[LessEqual[z$95$m, 0.0015], t$95$1, N[(N[(y * N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]]]]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
t_1 := \left(4 \cdot y\right) \cdot t\\
\mathbf{if}\;z\_m \leq 4 \cdot 10^{-234}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z\_m \leq 2.1 \cdot 10^{-26}:\\
\;\;\;\;x \cdot x\\
\mathbf{elif}\;z\_m \leq 0.0015:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot \left(z\_m \cdot z\_m\right)\right) \cdot -4\\
\end{array}
\end{array}
if z < 3.9999999999999998e-234 or 2.10000000000000008e-26 < z < 0.0015Initial program 89.7%
Taylor expanded in t around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6433.9
Applied rewrites33.9%
if 3.9999999999999998e-234 < z < 2.10000000000000008e-26Initial program 100.0%
Taylor expanded in y around 0
unpow2N/A
lower-*.f6466.0
Applied rewrites66.0%
if 0.0015 < z Initial program 90.8%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6474.6
Applied rewrites74.6%
Final simplification49.1%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= (* z_m z_m) 1e-6) (fma x x (* 4.0 (* y t))) (fma (* (* -4.0 y) z_m) z_m (* x x))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if ((z_m * z_m) <= 1e-6) {
tmp = fma(x, x, (4.0 * (y * t)));
} else {
tmp = fma(((-4.0 * y) * z_m), z_m, (x * x));
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (Float64(z_m * z_m) <= 1e-6) tmp = fma(x, x, Float64(4.0 * Float64(y * t))); else tmp = fma(Float64(Float64(-4.0 * y) * z_m), z_m, Float64(x * x)); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[N[(z$95$m * z$95$m), $MachinePrecision], 1e-6], N[(x * x + N[(4.0 * N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-4.0 * y), $MachinePrecision] * z$95$m), $MachinePrecision] * z$95$m + N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \cdot z\_m \leq 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(x, x, 4 \cdot \left(y \cdot t\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(-4 \cdot y\right) \cdot z\_m, z\_m, x \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 9.99999999999999955e-7Initial 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.2
Applied rewrites99.2%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6496.4
Applied rewrites96.4%
if 9.99999999999999955e-7 < (*.f64 z z) Initial program 85.6%
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 rewrites88.1%
Taylor expanded in t around 0
unpow2N/A
lower-*.f6489.5
Applied rewrites89.5%
Final simplification92.7%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= z_m 3.6e+138) (fma x x (* -4.0 (* y (- (* z_m z_m) t)))) (fma (* (* -4.0 y) z_m) z_m (* x x))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 3.6e+138) {
tmp = fma(x, x, (-4.0 * (y * ((z_m * z_m) - t))));
} else {
tmp = fma(((-4.0 * y) * z_m), z_m, (x * x));
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 3.6e+138) tmp = fma(x, x, Float64(-4.0 * Float64(y * Float64(Float64(z_m * z_m) - t)))); else tmp = fma(Float64(Float64(-4.0 * y) * z_m), z_m, Float64(x * x)); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 3.6e+138], N[(x * x + N[(-4.0 * N[(y * N[(N[(z$95$m * z$95$m), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-4.0 * y), $MachinePrecision] * z$95$m), $MachinePrecision] * z$95$m + N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 3.6 \cdot 10^{+138}:\\
\;\;\;\;\mathsf{fma}\left(x, x, -4 \cdot \left(y \cdot \left(z\_m \cdot z\_m - t\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(-4 \cdot y\right) \cdot z\_m, z\_m, x \cdot x\right)\\
\end{array}
\end{array}
if z < 3.6000000000000001e138Initial program 92.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-eval95.6
Applied rewrites95.6%
if 3.6000000000000001e138 < z Initial program 83.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 rewrites88.9%
Taylor expanded in t around 0
unpow2N/A
lower-*.f6497.2
Applied rewrites97.2%
Final simplification95.8%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= z_m 9.2e+62) (fma x x (* 4.0 (* y t))) (* (* (* -4.0 y) z_m) z_m)))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 9.2e+62) {
tmp = fma(x, x, (4.0 * (y * t)));
} else {
tmp = ((-4.0 * y) * z_m) * z_m;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 9.2e+62) tmp = fma(x, x, Float64(4.0 * Float64(y * t))); else tmp = Float64(Float64(Float64(-4.0 * y) * z_m) * z_m); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 9.2e+62], N[(x * x + N[(4.0 * N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-4.0 * y), $MachinePrecision] * z$95$m), $MachinePrecision] * z$95$m), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 9.2 \cdot 10^{+62}:\\
\;\;\;\;\mathsf{fma}\left(x, x, 4 \cdot \left(y \cdot t\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-4 \cdot y\right) \cdot z\_m\right) \cdot z\_m\\
\end{array}
\end{array}
if z < 9.19999999999999936e62Initial program 92.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.2
Applied rewrites95.2%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6473.5
Applied rewrites73.5%
if 9.19999999999999936e62 < z Initial program 88.6%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6481.1
Applied rewrites81.1%
Applied rewrites83.0%
Final simplification75.5%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= z_m 9.2e+62) (fma (* y t) 4.0 (* x x)) (* (* (* -4.0 y) z_m) z_m)))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 9.2e+62) {
tmp = fma((y * t), 4.0, (x * x));
} else {
tmp = ((-4.0 * y) * z_m) * z_m;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 9.2e+62) tmp = fma(Float64(y * t), 4.0, Float64(x * x)); else tmp = Float64(Float64(Float64(-4.0 * y) * z_m) * z_m); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 9.2e+62], N[(N[(y * t), $MachinePrecision] * 4.0 + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-4.0 * y), $MachinePrecision] * z$95$m), $MachinePrecision] * z$95$m), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 9.2 \cdot 10^{+62}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot t, 4, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-4 \cdot y\right) \cdot z\_m\right) \cdot z\_m\\
\end{array}
\end{array}
if z < 9.19999999999999936e62Initial program 92.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-*.f6472.5
Applied rewrites72.5%
if 9.19999999999999936e62 < z Initial program 88.6%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6481.1
Applied rewrites81.1%
Applied rewrites83.0%
Final simplification74.7%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= (* x x) 0.34) (* (* 4.0 y) t) (* x x)))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if ((x * x) <= 0.34) {
tmp = (4.0 * y) * t;
} else {
tmp = x * x;
}
return tmp;
}
z_m = abs(z)
real(8) function code(x, y, z_m, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
real(8) :: tmp
if ((x * x) <= 0.34d0) then
tmp = (4.0d0 * y) * t
else
tmp = x * x
end if
code = tmp
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m, double t) {
double tmp;
if ((x * x) <= 0.34) {
tmp = (4.0 * y) * t;
} else {
tmp = x * x;
}
return tmp;
}
z_m = math.fabs(z) def code(x, y, z_m, t): tmp = 0 if (x * x) <= 0.34: tmp = (4.0 * y) * t else: tmp = x * x return tmp
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (Float64(x * x) <= 0.34) tmp = Float64(Float64(4.0 * y) * t); else tmp = Float64(x * x); end return tmp end
z_m = abs(z); function tmp_2 = code(x, y, z_m, t) tmp = 0.0; if ((x * x) <= 0.34) tmp = (4.0 * y) * t; else tmp = x * x; end tmp_2 = tmp; end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[N[(x * x), $MachinePrecision], 0.34], N[(N[(4.0 * y), $MachinePrecision] * t), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 0.34:\\
\;\;\;\;\left(4 \cdot y\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 0.340000000000000024Initial program 97.7%
Taylor expanded in t around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6446.6
Applied rewrites46.6%
if 0.340000000000000024 < (*.f64 x x) Initial program 85.5%
Taylor expanded in y around 0
unpow2N/A
lower-*.f6468.9
Applied rewrites68.9%
Final simplification57.8%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (* x x))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
return x * x;
}
z_m = abs(z)
real(8) function code(x, y, z_m, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
code = x * x
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m, double t) {
return x * x;
}
z_m = math.fabs(z) def code(x, y, z_m, t): return x * x
z_m = abs(z) function code(x, y, z_m, t) return Float64(x * x) end
z_m = abs(z); function tmp = code(x, y, z_m, t) tmp = x * x; end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := N[(x * x), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
x \cdot x
\end{array}
Initial program 91.5%
Taylor expanded in y around 0
unpow2N/A
lower-*.f6439.8
Applied rewrites39.8%
(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 2024243
(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))))