
(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 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}
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= x_m 5e+273) (fma x_m x_m (fma (* (* z y) -4.0) z (* (* t y) 4.0))) (* x_m x_m)))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (x_m <= 5e+273) {
tmp = fma(x_m, x_m, fma(((z * y) * -4.0), z, ((t * y) * 4.0)));
} else {
tmp = x_m * x_m;
}
return tmp;
}
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (x_m <= 5e+273) tmp = fma(x_m, x_m, fma(Float64(Float64(z * y) * -4.0), z, Float64(Float64(t * y) * 4.0))); else tmp = 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, 5e+273], N[(x$95$m * x$95$m + N[(N[(N[(z * y), $MachinePrecision] * -4.0), $MachinePrecision] * z + N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$95$m * x$95$m), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 5 \cdot 10^{+273}:\\
\;\;\;\;\mathsf{fma}\left(x\_m, x\_m, \mathsf{fma}\left(\left(z \cdot y\right) \cdot -4, z, \left(t \cdot y\right) \cdot 4\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot x\_m\\
\end{array}
\end{array}
if x < 4.99999999999999961e273Initial program 91.5%
Applied rewrites96.9%
Applied rewrites92.1%
Applied rewrites96.1%
Applied rewrites96.4%
if 4.99999999999999961e273 < x Initial program 81.6%
Taylor expanded in x around inf
pow2N/A
lift-*.f6495.7
Applied rewrites95.7%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= z 1e+151) (fma (fma (- z) z t) (* y 4.0) (* x_m x_m)) (fma (* z (* -4.0 y)) z (* x_m x_m))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 1e+151) {
tmp = fma(fma(-z, z, t), (y * 4.0), (x_m * x_m));
} else {
tmp = fma((z * (-4.0 * y)), z, (x_m * x_m));
}
return tmp;
}
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (z <= 1e+151) tmp = fma(fma(Float64(-z), z, t), Float64(y * 4.0), Float64(x_m * x_m)); else tmp = fma(Float64(z * Float64(-4.0 * y)), z, 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, 1e+151], N[(N[((-z) * z + t), $MachinePrecision] * N[(y * 4.0), $MachinePrecision] + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(z * N[(-4.0 * y), $MachinePrecision]), $MachinePrecision] * z + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq 10^{+151}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-z, z, t\right), y \cdot 4, x\_m \cdot x\_m\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot \left(-4 \cdot y\right), z, x\_m \cdot x\_m\right)\\
\end{array}
\end{array}
if z < 1.00000000000000002e151Initial program 93.9%
Applied rewrites97.3%
Applied rewrites95.0%
if 1.00000000000000002e151 < z Initial program 70.4%
Taylor expanded in t around 0
Applied rewrites91.8%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= z 1e+151) (fma (- (* z z) t) (* -4.0 y) (* x_m x_m)) (fma (* z (* -4.0 y)) z (* x_m x_m))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 1e+151) {
tmp = fma(((z * z) - t), (-4.0 * y), (x_m * x_m));
} else {
tmp = fma((z * (-4.0 * y)), z, (x_m * x_m));
}
return tmp;
}
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (z <= 1e+151) tmp = fma(Float64(Float64(z * z) - t), Float64(-4.0 * y), Float64(x_m * x_m)); else tmp = fma(Float64(z * Float64(-4.0 * y)), z, 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, 1e+151], N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(-4.0 * y), $MachinePrecision] + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(z * N[(-4.0 * y), $MachinePrecision]), $MachinePrecision] * z + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq 10^{+151}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot z - t, -4 \cdot y, x\_m \cdot x\_m\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot \left(-4 \cdot y\right), z, x\_m \cdot x\_m\right)\\
\end{array}
\end{array}
if z < 1.00000000000000002e151Initial program 93.9%
Applied rewrites97.3%
Applied rewrites95.0%
if 1.00000000000000002e151 < z Initial program 70.4%
Taylor expanded in t around 0
Applied rewrites91.8%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (fma (* 4.0 y) t (fma (* z (* -4.0 y)) z (* x_m x_m))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
return fma((4.0 * y), t, fma((z * (-4.0 * y)), z, (x_m * x_m)));
}
x_m = abs(x) function code(x_m, y, z, t) return fma(Float64(4.0 * y), t, fma(Float64(z * Float64(-4.0 * y)), z, Float64(x_m * x_m))) end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := N[(N[(4.0 * y), $MachinePrecision] * t + N[(N[(z * N[(-4.0 * y), $MachinePrecision]), $MachinePrecision] * z + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
\mathsf{fma}\left(4 \cdot y, t, \mathsf{fma}\left(z \cdot \left(-4 \cdot y\right), z, x\_m \cdot x\_m\right)\right)
\end{array}
Initial program 90.9%
Applied rewrites96.6%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= z 2.5e-23) (fma x_m x_m (* (* t y) 4.0)) (fma (* z (* -4.0 y)) z (* x_m x_m))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 2.5e-23) {
tmp = fma(x_m, x_m, ((t * y) * 4.0));
} else {
tmp = fma((z * (-4.0 * y)), z, (x_m * x_m));
}
return tmp;
}
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (z <= 2.5e-23) tmp = fma(x_m, x_m, Float64(Float64(t * y) * 4.0)); else tmp = fma(Float64(z * Float64(-4.0 * y)), z, 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.5e-23], N[(x$95$m * x$95$m + N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(N[(z * N[(-4.0 * y), $MachinePrecision]), $MachinePrecision] * z + 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.5 \cdot 10^{-23}:\\
\;\;\;\;\mathsf{fma}\left(x\_m, x\_m, \left(t \cdot y\right) \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot \left(-4 \cdot y\right), z, x\_m \cdot x\_m\right)\\
\end{array}
\end{array}
if z < 2.5000000000000001e-23Initial program 93.3%
Applied rewrites72.3%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f64N/A
lower-*.f6476.3
Applied rewrites76.3%
if 2.5000000000000001e-23 < z Initial program 84.4%
Taylor expanded in t around 0
Applied rewrites86.4%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= x_m 1.65e-12) (* (* (- (* z z) t) y) -4.0) (fma x_m x_m (* (* t y) 4.0))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (x_m <= 1.65e-12) {
tmp = (((z * z) - t) * y) * -4.0;
} else {
tmp = fma(x_m, x_m, ((t * y) * 4.0));
}
return tmp;
}
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (x_m <= 1.65e-12) tmp = Float64(Float64(Float64(Float64(z * z) - t) * y) * -4.0); else tmp = fma(x_m, x_m, Float64(Float64(t * y) * 4.0)); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[x$95$m, 1.65e-12], N[(N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * y), $MachinePrecision] * -4.0), $MachinePrecision], N[(x$95$m * x$95$m + N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 1.65 \cdot 10^{-12}:\\
\;\;\;\;\left(\left(z \cdot z - t\right) \cdot y\right) \cdot -4\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x\_m, x\_m, \left(t \cdot y\right) \cdot 4\right)\\
\end{array}
\end{array}
if x < 1.65e-12Initial program 94.0%
Applied rewrites99.3%
Taylor expanded in x around 0
Applied rewrites87.4%
if 1.65e-12 < x Initial program 88.1%
Applied rewrites69.8%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f64N/A
lower-*.f6478.3
Applied rewrites78.3%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= z 132000000000.0) (fma x_m x_m (* (* t y) 4.0)) (* (* z (* -4.0 y)) z)))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 132000000000.0) {
tmp = fma(x_m, x_m, ((t * y) * 4.0));
} else {
tmp = (z * (-4.0 * y)) * z;
}
return tmp;
}
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (z <= 132000000000.0) tmp = fma(x_m, x_m, Float64(Float64(t * y) * 4.0)); else tmp = Float64(Float64(z * Float64(-4.0 * y)) * z); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[z, 132000000000.0], N[(x$95$m * x$95$m + N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(N[(z * N[(-4.0 * y), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq 132000000000:\\
\;\;\;\;\mathsf{fma}\left(x\_m, x\_m, \left(t \cdot y\right) \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot \left(-4 \cdot y\right)\right) \cdot z\\
\end{array}
\end{array}
if z < 1.32e11Initial program 93.5%
Applied rewrites72.4%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f64N/A
lower-*.f6476.2
Applied rewrites76.2%
if 1.32e11 < z Initial program 82.9%
Taylor expanded in z around inf
Applied rewrites72.4%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= z 2.5e-23) (* (* t y) 4.0) (* (* z (* -4.0 y)) z)))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 2.5e-23) {
tmp = (t * y) * 4.0;
} else {
tmp = (z * (-4.0 * y)) * z;
}
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 <= 2.5d-23) then
tmp = (t * y) * 4.0d0
else
tmp = (z * ((-4.0d0) * y)) * z
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 <= 2.5e-23) {
tmp = (t * y) * 4.0;
} else {
tmp = (z * (-4.0 * y)) * z;
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y, z, t): tmp = 0 if z <= 2.5e-23: tmp = (t * y) * 4.0 else: tmp = (z * (-4.0 * y)) * z return tmp
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (z <= 2.5e-23) tmp = Float64(Float64(t * y) * 4.0); else tmp = Float64(Float64(z * Float64(-4.0 * y)) * z); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y, z, t) tmp = 0.0; if (z <= 2.5e-23) tmp = (t * y) * 4.0; else tmp = (z * (-4.0 * y)) * z; end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[z, 2.5e-23], N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision], N[(N[(z * N[(-4.0 * y), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq 2.5 \cdot 10^{-23}:\\
\;\;\;\;\left(t \cdot y\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot \left(-4 \cdot y\right)\right) \cdot z\\
\end{array}
\end{array}
if z < 2.5000000000000001e-23Initial program 93.3%
Applied rewrites97.6%
Taylor expanded in t around inf
Applied rewrites36.8%
if 2.5000000000000001e-23 < z Initial program 84.4%
Taylor expanded in z around inf
Applied rewrites67.8%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= x_m 4.5e+33) (* (* t y) 4.0) (* 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.5e+33) {
tmp = (t * y) * 4.0;
} else {
tmp = x_m * x_m;
}
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 (x_m <= 4.5d+33) then
tmp = (t * y) * 4.0d0
else
tmp = x_m * x_m
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 (x_m <= 4.5e+33) {
tmp = (t * y) * 4.0;
} else {
tmp = x_m * x_m;
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y, z, t): tmp = 0 if x_m <= 4.5e+33: tmp = (t * y) * 4.0 else: tmp = x_m * x_m return tmp
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (x_m <= 4.5e+33) tmp = Float64(Float64(t * y) * 4.0); else tmp = Float64(x_m * x_m); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y, z, t) tmp = 0.0; if (x_m <= 4.5e+33) tmp = (t * y) * 4.0; else tmp = x_m * x_m; end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[x$95$m, 4.5e+33], N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision], N[(x$95$m * x$95$m), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 4.5 \cdot 10^{+33}:\\
\;\;\;\;\left(t \cdot y\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot x\_m\\
\end{array}
\end{array}
if x < 4.5e33Initial program 93.9%
Applied rewrites99.2%
Taylor expanded in t around inf
Applied rewrites45.7%
if 4.5e33 < x Initial program 87.2%
Taylor expanded in x around inf
pow2N/A
lift-*.f6474.6
Applied rewrites74.6%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (* x_m x_m))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
return x_m * x_m;
}
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 = x_m * x_m
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z, double t) {
return x_m * x_m;
}
x_m = math.fabs(x) def code(x_m, y, z, t): return x_m * x_m
x_m = abs(x) function code(x_m, y, z, t) return Float64(x_m * x_m) end
x_m = abs(x); function tmp = code(x_m, y, z, t) tmp = x_m * x_m; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := N[(x$95$m * x$95$m), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x\_m \cdot x\_m
\end{array}
Initial program 90.9%
Taylor expanded in x around inf
pow2N/A
lift-*.f6441.3
Applied rewrites41.3%
herbie shell --seed 2025130
(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))))