
(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));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
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]
\begin{array}{l}
\\
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (- (* x x) (* (* y 4.0) (- (* z z) t))))
double code(double x, double y, double z, double t) {
return (x * x) - ((y * 4.0) * ((z * z) - t));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
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]
\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 5.5e+175) (fma x x (* (* -4.0 y) (- (* z_m z_m) t))) (* (* (* z_m y) z_m) -4.0)))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 5.5e+175) {
tmp = fma(x, x, ((-4.0 * y) * ((z_m * z_m) - t)));
} else {
tmp = ((z_m * y) * z_m) * -4.0;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 5.5e+175) tmp = fma(x, x, Float64(Float64(-4.0 * y) * Float64(Float64(z_m * z_m) - t))); else tmp = Float64(Float64(Float64(z_m * y) * z_m) * -4.0); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 5.5e+175], N[(x * x + N[(N[(-4.0 * y), $MachinePrecision] * N[(N[(z$95$m * z$95$m), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z$95$m * y), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 5.5 \cdot 10^{+175}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(-4 \cdot y\right) \cdot \left(z\_m \cdot z\_m - t\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(z\_m \cdot y\right) \cdot z\_m\right) \cdot -4\\
\end{array}
\end{array}
if z < 5.50000000000000018e175Initial program 94.5%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval95.3
Applied rewrites95.3%
if 5.50000000000000018e175 < z Initial program 60.8%
Taylor expanded in z around inf
Applied rewrites69.1%
Applied rewrites83.6%
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
:precision binary64
(if (<= z_m 4.4e-8)
(fma x x (* (* t y) 4.0))
(if (<= z_m 5.5e+175)
(fma x x (* (* -4.0 y) (* z_m z_m)))
(* (* (* z_m y) z_m) -4.0))))z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 4.4e-8) {
tmp = fma(x, x, ((t * y) * 4.0));
} else if (z_m <= 5.5e+175) {
tmp = fma(x, x, ((-4.0 * y) * (z_m * z_m)));
} else {
tmp = ((z_m * y) * z_m) * -4.0;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 4.4e-8) tmp = fma(x, x, Float64(Float64(t * y) * 4.0)); elseif (z_m <= 5.5e+175) tmp = fma(x, x, Float64(Float64(-4.0 * y) * Float64(z_m * z_m))); else tmp = Float64(Float64(Float64(z_m * y) * z_m) * -4.0); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 4.4e-8], N[(x * x + N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z$95$m, 5.5e+175], N[(x * x + N[(N[(-4.0 * y), $MachinePrecision] * N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z$95$m * y), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0), $MachinePrecision]]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 4.4 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(t \cdot y\right) \cdot 4\right)\\
\mathbf{elif}\;z\_m \leq 5.5 \cdot 10^{+175}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(-4 \cdot y\right) \cdot \left(z\_m \cdot z\_m\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(z\_m \cdot y\right) \cdot z\_m\right) \cdot -4\\
\end{array}
\end{array}
if z < 4.3999999999999997e-8Initial program 94.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval95.8
Applied rewrites95.8%
Taylor expanded in z around 0
Applied rewrites75.3%
if 4.3999999999999997e-8 < z < 5.50000000000000018e175Initial program 93.1%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval93.1
Applied rewrites93.1%
Taylor expanded in z around inf
Applied rewrites88.9%
if 5.50000000000000018e175 < z Initial program 60.8%
Taylor expanded in z around inf
Applied rewrites69.1%
Applied rewrites83.6%
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
:precision binary64
(if (<= z_m 4.4e-8)
(fma x x (* (* t y) 4.0))
(if (<= z_m 5.5e+175)
(fma (* (* z_m z_m) y) -4.0 (* x x))
(* (* (* z_m y) z_m) -4.0))))z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 4.4e-8) {
tmp = fma(x, x, ((t * y) * 4.0));
} else if (z_m <= 5.5e+175) {
tmp = fma(((z_m * z_m) * y), -4.0, (x * x));
} else {
tmp = ((z_m * y) * z_m) * -4.0;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 4.4e-8) tmp = fma(x, x, Float64(Float64(t * y) * 4.0)); elseif (z_m <= 5.5e+175) tmp = fma(Float64(Float64(z_m * z_m) * y), -4.0, Float64(x * x)); else tmp = Float64(Float64(Float64(z_m * y) * z_m) * -4.0); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 4.4e-8], N[(x * x + N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z$95$m, 5.5e+175], N[(N[(N[(z$95$m * z$95$m), $MachinePrecision] * y), $MachinePrecision] * -4.0 + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z$95$m * y), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0), $MachinePrecision]]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 4.4 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(t \cdot y\right) \cdot 4\right)\\
\mathbf{elif}\;z\_m \leq 5.5 \cdot 10^{+175}:\\
\;\;\;\;\mathsf{fma}\left(\left(z\_m \cdot z\_m\right) \cdot y, -4, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(z\_m \cdot y\right) \cdot z\_m\right) \cdot -4\\
\end{array}
\end{array}
if z < 4.3999999999999997e-8Initial program 94.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval95.8
Applied rewrites95.8%
Taylor expanded in z around 0
Applied rewrites75.3%
if 4.3999999999999997e-8 < z < 5.50000000000000018e175Initial program 93.1%
Taylor expanded in t around 0
Applied rewrites88.9%
if 5.50000000000000018e175 < z Initial program 60.8%
Taylor expanded in z around inf
Applied rewrites69.1%
Applied rewrites83.6%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= x 2.2e-256) (* (* 4.0 y) t) (if (<= x 1450000000000.0) (* (* (* z_m y) z_m) -4.0) (* x x))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (x <= 2.2e-256) {
tmp = (4.0 * y) * t;
} else if (x <= 1450000000000.0) {
tmp = ((z_m * y) * z_m) * -4.0;
} else {
tmp = x * x;
}
return tmp;
}
z_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z_m, t)
use fmin_fmax_functions
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 <= 2.2d-256) then
tmp = (4.0d0 * y) * t
else if (x <= 1450000000000.0d0) then
tmp = ((z_m * y) * z_m) * (-4.0d0)
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 <= 2.2e-256) {
tmp = (4.0 * y) * t;
} else if (x <= 1450000000000.0) {
tmp = ((z_m * y) * z_m) * -4.0;
} else {
tmp = x * x;
}
return tmp;
}
z_m = math.fabs(z) def code(x, y, z_m, t): tmp = 0 if x <= 2.2e-256: tmp = (4.0 * y) * t elif x <= 1450000000000.0: tmp = ((z_m * y) * z_m) * -4.0 else: tmp = x * x return tmp
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (x <= 2.2e-256) tmp = Float64(Float64(4.0 * y) * t); elseif (x <= 1450000000000.0) tmp = Float64(Float64(Float64(z_m * y) * z_m) * -4.0); 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 <= 2.2e-256) tmp = (4.0 * y) * t; elseif (x <= 1450000000000.0) tmp = ((z_m * y) * z_m) * -4.0; else tmp = x * x; end tmp_2 = tmp; end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[x, 2.2e-256], N[(N[(4.0 * y), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[x, 1450000000000.0], N[(N[(N[(z$95$m * y), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0), $MachinePrecision], N[(x * x), $MachinePrecision]]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.2 \cdot 10^{-256}:\\
\;\;\;\;\left(4 \cdot y\right) \cdot t\\
\mathbf{elif}\;x \leq 1450000000000:\\
\;\;\;\;\left(\left(z\_m \cdot y\right) \cdot z\_m\right) \cdot -4\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if x < 2.2000000000000001e-256Initial program 92.9%
Taylor expanded in x around 0
Applied rewrites61.6%
Taylor expanded in z around 0
Applied rewrites31.9%
Applied rewrites31.9%
if 2.2000000000000001e-256 < x < 1.45e12Initial program 92.9%
Taylor expanded in z around inf
Applied rewrites50.5%
Applied rewrites57.4%
if 1.45e12 < x Initial program 86.7%
Taylor expanded in x around inf
Applied rewrites76.4%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= x 2.2e-10) (* (fma (- z_m) z_m t) (* 4.0 y)) (fma x x (* (* t y) 4.0))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (x <= 2.2e-10) {
tmp = fma(-z_m, z_m, t) * (4.0 * y);
} else {
tmp = fma(x, x, ((t * y) * 4.0));
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (x <= 2.2e-10) tmp = Float64(fma(Float64(-z_m), z_m, t) * Float64(4.0 * y)); else tmp = fma(x, x, Float64(Float64(t * y) * 4.0)); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[x, 2.2e-10], N[(N[((-z$95$m) * z$95$m + t), $MachinePrecision] * N[(4.0 * y), $MachinePrecision]), $MachinePrecision], N[(x * x + N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.2 \cdot 10^{-10}:\\
\;\;\;\;\mathsf{fma}\left(-z\_m, z\_m, t\right) \cdot \left(4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(t \cdot y\right) \cdot 4\right)\\
\end{array}
\end{array}
if x < 2.1999999999999999e-10Initial program 93.1%
Taylor expanded in x around 0
Applied rewrites68.7%
Applied rewrites68.7%
if 2.1999999999999999e-10 < x Initial program 86.6%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval90.8
Applied rewrites90.8%
Taylor expanded in z around 0
Applied rewrites82.3%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= x 2.2e-10) (* (* (fma (- z_m) z_m t) y) 4.0) (fma x x (* (* t y) 4.0))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (x <= 2.2e-10) {
tmp = (fma(-z_m, z_m, t) * y) * 4.0;
} else {
tmp = fma(x, x, ((t * y) * 4.0));
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (x <= 2.2e-10) tmp = Float64(Float64(fma(Float64(-z_m), z_m, t) * y) * 4.0); else tmp = fma(x, x, Float64(Float64(t * y) * 4.0)); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[x, 2.2e-10], N[(N[(N[((-z$95$m) * z$95$m + t), $MachinePrecision] * y), $MachinePrecision] * 4.0), $MachinePrecision], N[(x * x + N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.2 \cdot 10^{-10}:\\
\;\;\;\;\left(\mathsf{fma}\left(-z\_m, z\_m, t\right) \cdot y\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(t \cdot y\right) \cdot 4\right)\\
\end{array}
\end{array}
if x < 2.1999999999999999e-10Initial program 93.1%
Taylor expanded in x around 0
Applied rewrites68.7%
if 2.1999999999999999e-10 < x Initial program 86.6%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval90.8
Applied rewrites90.8%
Taylor expanded in z around 0
Applied rewrites82.3%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= z_m 2.8e+43) (fma x x (* (* t y) 4.0)) (* (* (* z_m y) z_m) -4.0)))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 2.8e+43) {
tmp = fma(x, x, ((t * y) * 4.0));
} else {
tmp = ((z_m * y) * z_m) * -4.0;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 2.8e+43) tmp = fma(x, x, Float64(Float64(t * y) * 4.0)); else tmp = Float64(Float64(Float64(z_m * y) * z_m) * -4.0); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 2.8e+43], N[(x * x + N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z$95$m * y), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 2.8 \cdot 10^{+43}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(t \cdot y\right) \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(z\_m \cdot y\right) \cdot z\_m\right) \cdot -4\\
\end{array}
\end{array}
if z < 2.80000000000000019e43Initial program 95.1%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval96.1
Applied rewrites96.1%
Taylor expanded in z around 0
Applied rewrites75.0%
if 2.80000000000000019e43 < z Initial program 77.4%
Taylor expanded in z around inf
Applied rewrites70.5%
Applied rewrites71.6%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= z_m 2.8e+43) (fma (* t y) 4.0 (* x x)) (* (* (* z_m y) z_m) -4.0)))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 2.8e+43) {
tmp = fma((t * y), 4.0, (x * x));
} else {
tmp = ((z_m * y) * z_m) * -4.0;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 2.8e+43) tmp = fma(Float64(t * y), 4.0, Float64(x * x)); else tmp = Float64(Float64(Float64(z_m * y) * z_m) * -4.0); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 2.8e+43], N[(N[(t * y), $MachinePrecision] * 4.0 + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z$95$m * y), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 2.8 \cdot 10^{+43}:\\
\;\;\;\;\mathsf{fma}\left(t \cdot y, 4, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(z\_m \cdot y\right) \cdot z\_m\right) \cdot -4\\
\end{array}
\end{array}
if z < 2.80000000000000019e43Initial program 95.1%
Taylor expanded in z around 0
Applied rewrites75.0%
if 2.80000000000000019e43 < z Initial program 77.4%
Taylor expanded in z around inf
Applied rewrites70.5%
Applied rewrites71.6%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= x 3e-7) (* (* 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 <= 3e-7) {
tmp = (4.0 * y) * t;
} else {
tmp = x * x;
}
return tmp;
}
z_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z_m, t)
use fmin_fmax_functions
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 <= 3d-7) 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 <= 3e-7) {
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 <= 3e-7: 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 (x <= 3e-7) 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 <= 3e-7) 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[x, 3e-7], 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 \leq 3 \cdot 10^{-7}:\\
\;\;\;\;\left(4 \cdot y\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if x < 2.9999999999999999e-7Initial program 93.2%
Taylor expanded in x around 0
Applied rewrites68.9%
Taylor expanded in z around 0
Applied rewrites34.3%
Applied rewrites34.8%
if 2.9999999999999999e-7 < x Initial program 86.4%
Taylor expanded in x around inf
Applied rewrites73.9%
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 = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z_m, t)
use fmin_fmax_functions
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.3%
Taylor expanded in x around inf
Applied rewrites44.5%
(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)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
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) - (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 2025018
(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))))