
(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}
Herbie found 9 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}
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= x_m 4.15e+151) (- (* x_m x_m) (fma (* (* 4.0 y) z) z (* (* 4.0 y) (- t)))) (fma (* y 4.0) t (* x_m x_m))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (x_m <= 4.15e+151) {
tmp = (x_m * x_m) - fma(((4.0 * y) * z), z, ((4.0 * y) * -t));
} else {
tmp = fma((y * 4.0), t, (x_m * x_m));
}
return tmp;
}
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (x_m <= 4.15e+151) tmp = Float64(Float64(x_m * x_m) - fma(Float64(Float64(4.0 * y) * z), z, Float64(Float64(4.0 * y) * Float64(-t)))); else tmp = fma(Float64(y * 4.0), t, Float64(x_m * x_m)); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[x$95$m, 4.15e+151], N[(N[(x$95$m * x$95$m), $MachinePrecision] - N[(N[(N[(4.0 * y), $MachinePrecision] * z), $MachinePrecision] * z + N[(N[(4.0 * y), $MachinePrecision] * (-t)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * 4.0), $MachinePrecision] * t + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 4.15 \cdot 10^{+151}:\\
\;\;\;\;x\_m \cdot x\_m - \mathsf{fma}\left(\left(4 \cdot y\right) \cdot z, z, \left(4 \cdot y\right) \cdot \left(-t\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot 4, t, x\_m \cdot x\_m\right)\\
\end{array}
\end{array}
if x < 4.14999999999999995e151Initial program 90.4%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
pow2N/A
sub-flipN/A
mul-1-negN/A
distribute-lft-inN/A
pow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6493.5
Applied rewrites93.5%
if 4.14999999999999995e151 < x Initial program 90.4%
Taylor expanded in z around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6465.9
Applied rewrites65.9%
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
pow2N/A
add-flipN/A
*-commutativeN/A
sub-flipN/A
*-commutativeN/A
associate-*l*N/A
mul-1-negN/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6467.2
Applied rewrites67.2%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= z 1.15e+139) (- (* x_m x_m) (* (* y 4.0) (fma z z (- t)))) (fma (* (* z y) z) -4.0 (* x_m x_m))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 1.15e+139) {
tmp = (x_m * x_m) - ((y * 4.0) * fma(z, z, -t));
} else {
tmp = fma(((z * y) * z), -4.0, (x_m * x_m));
}
return tmp;
}
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (z <= 1.15e+139) tmp = Float64(Float64(x_m * x_m) - Float64(Float64(y * 4.0) * fma(z, z, Float64(-t)))); else tmp = fma(Float64(Float64(z * y) * z), -4.0, Float64(x_m * x_m)); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[z, 1.15e+139], N[(N[(x$95$m * x$95$m), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * N[(z * z + (-t)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z * y), $MachinePrecision] * z), $MachinePrecision] * -4.0 + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.15 \cdot 10^{+139}:\\
\;\;\;\;x\_m \cdot x\_m - \left(y \cdot 4\right) \cdot \mathsf{fma}\left(z, z, -t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(z \cdot y\right) \cdot z, -4, x\_m \cdot x\_m\right)\\
\end{array}
\end{array}
if z < 1.15e139Initial program 90.4%
lift-*.f64N/A
lift--.f64N/A
pow2N/A
sub-flipN/A
pow2N/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f6490.4
Applied rewrites90.4%
if 1.15e139 < z Initial program 90.4%
Taylor expanded in t around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
*-commutativeN/A
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6466.7
Applied rewrites66.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6471.7
Applied rewrites71.7%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= z 1.15e+139) (- (* x_m x_m) (* (* y 4.0) (- (* z z) t))) (fma (* (* z y) z) -4.0 (* x_m x_m))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 1.15e+139) {
tmp = (x_m * x_m) - ((y * 4.0) * ((z * z) - t));
} else {
tmp = fma(((z * y) * z), -4.0, (x_m * x_m));
}
return tmp;
}
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (z <= 1.15e+139) tmp = Float64(Float64(x_m * x_m) - Float64(Float64(y * 4.0) * Float64(Float64(z * z) - t))); else tmp = fma(Float64(Float64(z * y) * z), -4.0, Float64(x_m * x_m)); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[z, 1.15e+139], N[(N[(x$95$m * x$95$m), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z * y), $MachinePrecision] * z), $MachinePrecision] * -4.0 + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.15 \cdot 10^{+139}:\\
\;\;\;\;x\_m \cdot x\_m - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(z \cdot y\right) \cdot z, -4, x\_m \cdot x\_m\right)\\
\end{array}
\end{array}
if z < 1.15e139Initial program 90.4%
if 1.15e139 < z Initial program 90.4%
Taylor expanded in t around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
*-commutativeN/A
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6466.7
Applied rewrites66.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6471.7
Applied rewrites71.7%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= z 2.8e-21) (fma (* y 4.0) t (* x_m x_m)) (fma (* (* z y) z) -4.0 (* x_m x_m))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 2.8e-21) {
tmp = fma((y * 4.0), t, (x_m * x_m));
} else {
tmp = fma(((z * y) * z), -4.0, (x_m * x_m));
}
return tmp;
}
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (z <= 2.8e-21) tmp = fma(Float64(y * 4.0), t, Float64(x_m * x_m)); else tmp = fma(Float64(Float64(z * y) * z), -4.0, Float64(x_m * x_m)); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[z, 2.8e-21], N[(N[(y * 4.0), $MachinePrecision] * t + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z * y), $MachinePrecision] * z), $MachinePrecision] * -4.0 + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq 2.8 \cdot 10^{-21}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot 4, t, x\_m \cdot x\_m\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(z \cdot y\right) \cdot z, -4, x\_m \cdot x\_m\right)\\
\end{array}
\end{array}
if z < 2.80000000000000004e-21Initial program 90.4%
Taylor expanded in z around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6465.9
Applied rewrites65.9%
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
pow2N/A
add-flipN/A
*-commutativeN/A
sub-flipN/A
*-commutativeN/A
associate-*l*N/A
mul-1-negN/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6467.2
Applied rewrites67.2%
if 2.80000000000000004e-21 < z Initial program 90.4%
Taylor expanded in t around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
*-commutativeN/A
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6466.7
Applied rewrites66.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6471.7
Applied rewrites71.7%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= z 1.9e-35) (fma (* y 4.0) t (* x_m x_m)) (if (<= z 1.15e+139) (* (- t (* z z)) (* 4.0 y)) (* (* (* z y) z) -4.0))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 1.9e-35) {
tmp = fma((y * 4.0), t, (x_m * x_m));
} else if (z <= 1.15e+139) {
tmp = (t - (z * z)) * (4.0 * y);
} else {
tmp = ((z * y) * z) * -4.0;
}
return tmp;
}
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (z <= 1.9e-35) tmp = fma(Float64(y * 4.0), t, Float64(x_m * x_m)); elseif (z <= 1.15e+139) tmp = Float64(Float64(t - Float64(z * z)) * Float64(4.0 * y)); else tmp = Float64(Float64(Float64(z * y) * z) * -4.0); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[z, 1.9e-35], N[(N[(y * 4.0), $MachinePrecision] * t + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.15e+139], N[(N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision] * N[(4.0 * y), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z * y), $MachinePrecision] * z), $MachinePrecision] * -4.0), $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.9 \cdot 10^{-35}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot 4, t, x\_m \cdot x\_m\right)\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{+139}:\\
\;\;\;\;\left(t - z \cdot z\right) \cdot \left(4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(z \cdot y\right) \cdot z\right) \cdot -4\\
\end{array}
\end{array}
if z < 1.9000000000000001e-35Initial program 90.4%
Taylor expanded in z around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6465.9
Applied rewrites65.9%
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
pow2N/A
add-flipN/A
*-commutativeN/A
sub-flipN/A
*-commutativeN/A
associate-*l*N/A
mul-1-negN/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6467.2
Applied rewrites67.2%
if 1.9000000000000001e-35 < z < 1.15e139Initial program 90.4%
Taylor expanded in x around 0
associate-*r*N/A
pow2N/A
*-commutativeN/A
metadata-evalN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
pow2N/A
sub-negate-revN/A
lower-*.f64N/A
lower--.f64N/A
pow2N/A
lift-*.f64N/A
lower-*.f6462.9
Applied rewrites62.9%
if 1.15e139 < z Initial program 90.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6437.4
Applied rewrites37.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6440.2
Applied rewrites40.2%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= z 3.25e+62) (fma (* y 4.0) t (* x_m x_m)) (* (* (* z y) z) -4.0)))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 3.25e+62) {
tmp = fma((y * 4.0), t, (x_m * x_m));
} else {
tmp = ((z * y) * z) * -4.0;
}
return tmp;
}
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (z <= 3.25e+62) tmp = fma(Float64(y * 4.0), t, Float64(x_m * x_m)); else tmp = Float64(Float64(Float64(z * y) * z) * -4.0); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[z, 3.25e+62], N[(N[(y * 4.0), $MachinePrecision] * t + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z * y), $MachinePrecision] * z), $MachinePrecision] * -4.0), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq 3.25 \cdot 10^{+62}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot 4, t, x\_m \cdot x\_m\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(z \cdot y\right) \cdot z\right) \cdot -4\\
\end{array}
\end{array}
if z < 3.2500000000000001e62Initial program 90.4%
Taylor expanded in z around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6465.9
Applied rewrites65.9%
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
pow2N/A
add-flipN/A
*-commutativeN/A
sub-flipN/A
*-commutativeN/A
associate-*l*N/A
mul-1-negN/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6467.2
Applied rewrites67.2%
if 3.2500000000000001e62 < z Initial program 90.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6437.4
Applied rewrites37.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6440.2
Applied rewrites40.2%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= z 3.25e+62) (fma (* t y) 4.0 (* x_m x_m)) (* (* (* z y) z) -4.0)))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 3.25e+62) {
tmp = fma((t * y), 4.0, (x_m * x_m));
} else {
tmp = ((z * y) * z) * -4.0;
}
return tmp;
}
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (z <= 3.25e+62) tmp = fma(Float64(t * y), 4.0, Float64(x_m * x_m)); else tmp = Float64(Float64(Float64(z * y) * z) * -4.0); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[z, 3.25e+62], N[(N[(t * y), $MachinePrecision] * 4.0 + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z * y), $MachinePrecision] * z), $MachinePrecision] * -4.0), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq 3.25 \cdot 10^{+62}:\\
\;\;\;\;\mathsf{fma}\left(t \cdot y, 4, x\_m \cdot x\_m\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(z \cdot y\right) \cdot z\right) \cdot -4\\
\end{array}
\end{array}
if z < 3.2500000000000001e62Initial program 90.4%
Taylor expanded in z around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6465.9
Applied rewrites65.9%
if 3.2500000000000001e62 < z Initial program 90.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6437.4
Applied rewrites37.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6440.2
Applied rewrites40.2%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= z 380000.0) (* (* t y) 4.0) (* (* (* z y) z) -4.0)))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 380000.0) {
tmp = (t * y) * 4.0;
} else {
tmp = ((z * y) * z) * -4.0;
}
return tmp;
}
x_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_m, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= 380000.0d0) then
tmp = (t * y) * 4.0d0
else
tmp = ((z * y) * z) * (-4.0d0)
end if
code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 380000.0) {
tmp = (t * y) * 4.0;
} else {
tmp = ((z * y) * z) * -4.0;
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y, z, t): tmp = 0 if z <= 380000.0: tmp = (t * y) * 4.0 else: tmp = ((z * y) * z) * -4.0 return tmp
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (z <= 380000.0) tmp = Float64(Float64(t * y) * 4.0); else tmp = Float64(Float64(Float64(z * y) * z) * -4.0); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y, z, t) tmp = 0.0; if (z <= 380000.0) tmp = (t * y) * 4.0; else tmp = ((z * y) * z) * -4.0; end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[z, 380000.0], N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision], N[(N[(N[(z * y), $MachinePrecision] * z), $MachinePrecision] * -4.0), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq 380000:\\
\;\;\;\;\left(t \cdot y\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;\left(\left(z \cdot y\right) \cdot z\right) \cdot -4\\
\end{array}
\end{array}
if z < 3.8e5Initial program 90.4%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6431.5
Applied rewrites31.5%
if 3.8e5 < z Initial program 90.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6437.4
Applied rewrites37.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6440.2
Applied rewrites40.2%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (* (* t y) 4.0))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
return (t * y) * 4.0;
}
x_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_m, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (t * y) * 4.0d0
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z, double t) {
return (t * y) * 4.0;
}
x_m = math.fabs(x) def code(x_m, y, z, t): return (t * y) * 4.0
x_m = abs(x) function code(x_m, y, z, t) return Float64(Float64(t * y) * 4.0) end
x_m = abs(x); function tmp = code(x_m, y, z, t) tmp = (t * y) * 4.0; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
\left(t \cdot y\right) \cdot 4
\end{array}
Initial program 90.4%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6431.5
Applied rewrites31.5%
herbie shell --seed 2025135
(FPCore (x y z t)
:name "Graphics.Rasterific.Shading:$sradialGradientWithFocusShader from Rasterific-0.6.1, B"
:precision binary64
(- (* x x) (* (* y 4.0) (- (* z z) t))))