
(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 8 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 4.5e+153) (fma (fma z_m z_m (- t)) (* -4.0 y) (* x x)) (- (* x x) (* (* -4.0 (- y (/ (* z_m (* z_m y)) t))) t))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 4.5e+153) {
tmp = fma(fma(z_m, z_m, -t), (-4.0 * y), (x * x));
} else {
tmp = (x * x) - ((-4.0 * (y - ((z_m * (z_m * y)) / t))) * t);
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 4.5e+153) tmp = fma(fma(z_m, z_m, Float64(-t)), Float64(-4.0 * y), Float64(x * x)); else tmp = Float64(Float64(x * x) - Float64(Float64(-4.0 * Float64(y - Float64(Float64(z_m * Float64(z_m * y)) / t))) * t)); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 4.5e+153], N[(N[(z$95$m * z$95$m + (-t)), $MachinePrecision] * N[(-4.0 * y), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] - N[(N[(-4.0 * N[(y - N[(N[(z$95$m * N[(z$95$m * y), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 4.5 \cdot 10^{+153}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(z\_m, z\_m, -t\right), -4 \cdot y, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x - \left(-4 \cdot \left(y - \frac{z\_m \cdot \left(z\_m \cdot y\right)}{t}\right)\right) \cdot t\\
\end{array}
\end{array}
if z < 4.5000000000000001e153Initial program 93.8%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
associate-*r*N/A
pow2N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites95.6%
if 4.5000000000000001e153 < z Initial program 77.6%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6477.6
Applied rewrites77.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6491.6
Applied rewrites91.6%
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
:precision binary64
(let* ((t_1 (* (* 4.0 t) y)))
(if (<= z_m 2.6e-178)
t_1
(if (<= z_m 2.9e-111)
(* x x)
(if (<= z_m 4e+21) t_1 (* (* (* z_m y) z_m) -4.0))))))z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double t_1 = (4.0 * t) * y;
double tmp;
if (z_m <= 2.6e-178) {
tmp = t_1;
} else if (z_m <= 2.9e-111) {
tmp = x * x;
} else if (z_m <= 4e+21) {
tmp = t_1;
} else {
tmp = ((z_m * y) * z_m) * -4.0;
}
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) :: t_1
real(8) :: tmp
t_1 = (4.0d0 * t) * y
if (z_m <= 2.6d-178) then
tmp = t_1
else if (z_m <= 2.9d-111) then
tmp = x * x
else if (z_m <= 4d+21) then
tmp = t_1
else
tmp = ((z_m * y) * 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 * t) * y;
double tmp;
if (z_m <= 2.6e-178) {
tmp = t_1;
} else if (z_m <= 2.9e-111) {
tmp = x * x;
} else if (z_m <= 4e+21) {
tmp = t_1;
} else {
tmp = ((z_m * y) * z_m) * -4.0;
}
return tmp;
}
z_m = math.fabs(z) def code(x, y, z_m, t): t_1 = (4.0 * t) * y tmp = 0 if z_m <= 2.6e-178: tmp = t_1 elif z_m <= 2.9e-111: tmp = x * x elif z_m <= 4e+21: tmp = t_1 else: tmp = ((z_m * y) * z_m) * -4.0 return tmp
z_m = abs(z) function code(x, y, z_m, t) t_1 = Float64(Float64(4.0 * t) * y) tmp = 0.0 if (z_m <= 2.6e-178) tmp = t_1; elseif (z_m <= 2.9e-111) tmp = Float64(x * x); elseif (z_m <= 4e+21) tmp = t_1; else tmp = Float64(Float64(Float64(z_m * y) * 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 * t) * y; tmp = 0.0; if (z_m <= 2.6e-178) tmp = t_1; elseif (z_m <= 2.9e-111) tmp = x * x; elseif (z_m <= 4e+21) tmp = t_1; else tmp = ((z_m * y) * 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 * t), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[z$95$m, 2.6e-178], t$95$1, If[LessEqual[z$95$m, 2.9e-111], N[(x * x), $MachinePrecision], If[LessEqual[z$95$m, 4e+21], t$95$1, 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}
t_1 := \left(4 \cdot t\right) \cdot y\\
\mathbf{if}\;z\_m \leq 2.6 \cdot 10^{-178}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z\_m \leq 2.9 \cdot 10^{-111}:\\
\;\;\;\;x \cdot x\\
\mathbf{elif}\;z\_m \leq 4 \cdot 10^{+21}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(z\_m \cdot y\right) \cdot z\_m\right) \cdot -4\\
\end{array}
\end{array}
if z < 2.59999999999999998e-178 or 2.90000000000000002e-111 < z < 4e21Initial program 92.8%
Taylor expanded in x around inf
pow2N/A
lift-*.f6439.6
Applied rewrites39.6%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6437.6
Applied rewrites37.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6437.6
Applied rewrites37.6%
if 2.59999999999999998e-178 < z < 2.90000000000000002e-111Initial program 100.0%
Taylor expanded in x around inf
pow2N/A
lift-*.f6481.1
Applied rewrites81.1%
if 4e21 < z Initial program 85.0%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6483.3
Applied rewrites83.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6491.6
Applied rewrites91.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f6484.6
Applied rewrites84.6%
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
:precision binary64
(if (<= z_m 7.2e+21)
(fma (* 4.0 t) y (* x x))
(if (<= z_m 2e+151)
(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 <= 7.2e+21) {
tmp = fma((4.0 * t), y, (x * x));
} else if (z_m <= 2e+151) {
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 <= 7.2e+21) tmp = fma(Float64(4.0 * t), y, Float64(x * x)); elseif (z_m <= 2e+151) 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, 7.2e+21], N[(N[(4.0 * t), $MachinePrecision] * y + N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z$95$m, 2e+151], 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 7.2 \cdot 10^{+21}:\\
\;\;\;\;\mathsf{fma}\left(4 \cdot t, y, x \cdot x\right)\\
\mathbf{elif}\;z\_m \leq 2 \cdot 10^{+151}:\\
\;\;\;\;\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 < 7.2e21Initial program 93.6%
Taylor expanded in z around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6472.8
Applied rewrites72.8%
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
pow2N/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6474.8
Applied rewrites74.8%
if 7.2e21 < z < 2.00000000000000003e151Initial program 95.6%
Taylor expanded in t around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6491.4
Applied rewrites91.4%
if 2.00000000000000003e151 < z Initial program 77.6%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6477.6
Applied rewrites77.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6491.6
Applied rewrites91.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f6494.0
Applied rewrites94.0%
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
:precision binary64
(if (<= z_m 8.2e+37)
(fma (* 4.0 t) y (* x x))
(if (<= z_m 5e+126)
(* (* -4.0 y) (fma 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 <= 8.2e+37) {
tmp = fma((4.0 * t), y, (x * x));
} else if (z_m <= 5e+126) {
tmp = (-4.0 * y) * fma(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 <= 8.2e+37) tmp = fma(Float64(4.0 * t), y, Float64(x * x)); elseif (z_m <= 5e+126) tmp = Float64(Float64(-4.0 * y) * fma(z_m, z_m, Float64(-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, 8.2e+37], N[(N[(4.0 * t), $MachinePrecision] * y + N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z$95$m, 5e+126], N[(N[(-4.0 * y), $MachinePrecision] * N[(z$95$m * z$95$m + (-t)), $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 8.2 \cdot 10^{+37}:\\
\;\;\;\;\mathsf{fma}\left(4 \cdot t, y, x \cdot x\right)\\
\mathbf{elif}\;z\_m \leq 5 \cdot 10^{+126}:\\
\;\;\;\;\left(-4 \cdot y\right) \cdot \mathsf{fma}\left(z\_m, z\_m, -t\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(z\_m \cdot y\right) \cdot z\_m\right) \cdot -4\\
\end{array}
\end{array}
if z < 8.1999999999999996e37Initial program 93.1%
Taylor expanded in z around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6472.6
Applied rewrites72.6%
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
pow2N/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6475.1
Applied rewrites75.1%
if 8.1999999999999996e37 < z < 4.99999999999999977e126Initial program 99.8%
Taylor expanded in x around 0
associate-*r*N/A
pow2N/A
lower-*.f64N/A
lower-*.f64N/A
pow2N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
pow2N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f6484.5
Applied rewrites84.5%
if 4.99999999999999977e126 < z Initial program 79.4%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6479.4
Applied rewrites79.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6492.3
Applied rewrites92.3%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f6491.9
Applied rewrites91.9%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= z_m 2e+151) (fma (fma z_m z_m (- t)) (* -4.0 y) (* 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 <= 2e+151) {
tmp = fma(fma(z_m, z_m, -t), (-4.0 * y), (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 <= 2e+151) tmp = fma(fma(z_m, z_m, Float64(-t)), Float64(-4.0 * y), 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, 2e+151], N[(N[(z$95$m * z$95$m + (-t)), $MachinePrecision] * N[(-4.0 * y), $MachinePrecision] + 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 \cdot 10^{+151}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(z\_m, z\_m, -t\right), -4 \cdot y, 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.00000000000000003e151Initial program 93.8%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
associate-*r*N/A
pow2N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites95.6%
if 2.00000000000000003e151 < z Initial program 77.6%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6477.6
Applied rewrites77.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6491.6
Applied rewrites91.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f6494.0
Applied rewrites94.0%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= z_m 1.3e+38) (fma (* 4.0 t) y (* 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 <= 1.3e+38) {
tmp = fma((4.0 * t), y, (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 <= 1.3e+38) tmp = fma(Float64(4.0 * t), y, 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, 1.3e+38], N[(N[(4.0 * t), $MachinePrecision] * y + 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 1.3 \cdot 10^{+38}:\\
\;\;\;\;\mathsf{fma}\left(4 \cdot t, y, 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 < 1.3e38Initial program 93.1%
Taylor expanded in z around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6472.6
Applied rewrites72.6%
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
pow2N/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6475.1
Applied rewrites75.1%
if 1.3e38 < z Initial program 86.3%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6484.5
Applied rewrites84.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6493.0
Applied rewrites93.0%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f6485.8
Applied rewrites85.8%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= x 3700000.0) (* (* 4.0 t) y) (* x x)))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (x <= 3700000.0) {
tmp = (4.0 * t) * y;
} 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 <= 3700000.0d0) then
tmp = (4.0d0 * t) * y
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 <= 3700000.0) {
tmp = (4.0 * t) * y;
} else {
tmp = x * x;
}
return tmp;
}
z_m = math.fabs(z) def code(x, y, z_m, t): tmp = 0 if x <= 3700000.0: tmp = (4.0 * t) * y else: tmp = x * x return tmp
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (x <= 3700000.0) tmp = Float64(Float64(4.0 * t) * y); 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 <= 3700000.0) tmp = (4.0 * t) * y; 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, 3700000.0], N[(N[(4.0 * t), $MachinePrecision] * y), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3700000:\\
\;\;\;\;\left(4 \cdot t\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if x < 3.7e6Initial program 92.2%
Taylor expanded in x around inf
pow2N/A
lift-*.f6429.0
Applied rewrites29.0%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6437.3
Applied rewrites37.3%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6437.3
Applied rewrites37.3%
if 3.7e6 < x Initial program 89.8%
Taylor expanded in x around inf
pow2N/A
lift-*.f6478.4
Applied rewrites78.4%
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.6%
Taylor expanded in x around inf
pow2N/A
lift-*.f6440.2
Applied rewrites40.2%
(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 2025057
(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))))