
(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]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
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]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
(FPCore (x y z t) :precision binary64 (if (<= (fabs z) 5e+152) (fma (- (* (fabs z) (fabs z)) t) (* -4.0 y) (* x x)) (fma x x (/ (* (- (/ t (fabs z)) (fabs z)) (* -4.0 y)) (/ -1.0 (fabs z))))))
double code(double x, double y, double z, double t) {
double tmp;
if (fabs(z) <= 5e+152) {
tmp = fma(((fabs(z) * fabs(z)) - t), (-4.0 * y), (x * x));
} else {
tmp = fma(x, x, ((((t / fabs(z)) - fabs(z)) * (-4.0 * y)) / (-1.0 / fabs(z))));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (abs(z) <= 5e+152) tmp = fma(Float64(Float64(abs(z) * abs(z)) - t), Float64(-4.0 * y), Float64(x * x)); else tmp = fma(x, x, Float64(Float64(Float64(Float64(t / abs(z)) - abs(z)) * Float64(-4.0 * y)) / Float64(-1.0 / abs(z)))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[Abs[z], $MachinePrecision], 5e+152], N[(N[(N[(N[Abs[z], $MachinePrecision] * N[Abs[z], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision] * N[(-4.0 * y), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(x * x + N[(N[(N[(N[(t / N[Abs[z], $MachinePrecision]), $MachinePrecision] - N[Abs[z], $MachinePrecision]), $MachinePrecision] * N[(-4.0 * y), $MachinePrecision]), $MachinePrecision] / N[(-1.0 / N[Abs[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|z\right| \leq 5 \cdot 10^{+152}:\\
\;\;\;\;\mathsf{fma}\left(\left|z\right| \cdot \left|z\right| - t, -4 \cdot y, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \frac{\left(\frac{t}{\left|z\right|} - \left|z\right|\right) \cdot \left(-4 \cdot y\right)}{\frac{-1}{\left|z\right|}}\right)\\
\end{array}
if z < 5e152Initial program 90.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval91.9
Applied rewrites91.9%
if 5e152 < z Initial program 90.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6493.0
Applied rewrites93.0%
Applied rewrites87.4%
(FPCore (x y z t) :precision binary64 (if (<= (fabs z) 2.5e+153) (fma (- (* (fabs z) (fabs z)) t) (* -4.0 y) (* x x)) (fma 4.0 (- (* t y) (* (* (fabs z) y) (fabs z))) (* x x))))
double code(double x, double y, double z, double t) {
double tmp;
if (fabs(z) <= 2.5e+153) {
tmp = fma(((fabs(z) * fabs(z)) - t), (-4.0 * y), (x * x));
} else {
tmp = fma(4.0, ((t * y) - ((fabs(z) * y) * fabs(z))), (x * x));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (abs(z) <= 2.5e+153) tmp = fma(Float64(Float64(abs(z) * abs(z)) - t), Float64(-4.0 * y), Float64(x * x)); else tmp = fma(4.0, Float64(Float64(t * y) - Float64(Float64(abs(z) * y) * abs(z))), Float64(x * x)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[Abs[z], $MachinePrecision], 2.5e+153], N[(N[(N[(N[Abs[z], $MachinePrecision] * N[Abs[z], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision] * N[(-4.0 * y), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(N[(t * y), $MachinePrecision] - N[(N[(N[Abs[z], $MachinePrecision] * y), $MachinePrecision] * N[Abs[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|z\right| \leq 2.5 \cdot 10^{+153}:\\
\;\;\;\;\mathsf{fma}\left(\left|z\right| \cdot \left|z\right| - t, -4 \cdot y, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(4, t \cdot y - \left(\left|z\right| \cdot y\right) \cdot \left|z\right|, x \cdot x\right)\\
\end{array}
if z < 2.50000000000000009e153Initial program 90.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval91.9
Applied rewrites91.9%
if 2.50000000000000009e153 < z Initial program 90.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lift--.f64N/A
sub-flipN/A
distribute-lft-inN/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
associate-*l*N/A
distribute-lft-neg-outN/A
distribute-lft-neg-outN/A
remove-double-negN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-out--N/A
Applied rewrites93.4%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
remove-double-negN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-neg.f64N/A
lift-*.f64N/A
distribute-lft-neg-outN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f6488.3
Applied rewrites88.3%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
sqr-neg-revN/A
associate-*r*N/A
remove-double-divN/A
metadata-evalN/A
frac-2negN/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
mult-flipN/A
frac-2negN/A
distribute-frac-neg2N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f64N/A
Applied rewrites93.4%
(FPCore (x y z t) :precision binary64 (if (<= (fabs x) 1.35e+191) (fma (fabs x) (fabs x) (* (* (- t (* z z)) y) 4.0)) (fma (* t 4.0) y (* (fabs x) (fabs x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (fabs(x) <= 1.35e+191) {
tmp = fma(fabs(x), fabs(x), (((t - (z * z)) * y) * 4.0));
} else {
tmp = fma((t * 4.0), y, (fabs(x) * fabs(x)));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (abs(x) <= 1.35e+191) tmp = fma(abs(x), abs(x), Float64(Float64(Float64(t - Float64(z * z)) * y) * 4.0)); else tmp = fma(Float64(t * 4.0), y, Float64(abs(x) * abs(x))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[Abs[x], $MachinePrecision], 1.35e+191], N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision] + N[(N[(N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(N[(t * 4.0), $MachinePrecision] * y + N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 1.35 \cdot 10^{+191}:\\
\;\;\;\;\mathsf{fma}\left(\left|x\right|, \left|x\right|, \left(\left(t - z \cdot z\right) \cdot y\right) \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t \cdot 4, y, \left|x\right| \cdot \left|x\right|\right)\\
\end{array}
if x < 1.34999999999999998e191Initial program 90.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6493.0
Applied rewrites93.0%
if 1.34999999999999998e191 < x Initial program 90.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6493.0
Applied rewrites93.0%
Taylor expanded in z around 0
Applied rewrites67.1%
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6467.5
Applied rewrites67.5%
(FPCore (x y z t) :precision binary64 (if (<= (fabs z) 5.5e+24) (fma (* t 4.0) y (* x x)) (fma (fma (fabs z) (fabs z) t) (* -4.0 y) (* x x))))
double code(double x, double y, double z, double t) {
double tmp;
if (fabs(z) <= 5.5e+24) {
tmp = fma((t * 4.0), y, (x * x));
} else {
tmp = fma(fma(fabs(z), fabs(z), t), (-4.0 * y), (x * x));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (abs(z) <= 5.5e+24) tmp = fma(Float64(t * 4.0), y, Float64(x * x)); else tmp = fma(fma(abs(z), abs(z), t), Float64(-4.0 * y), Float64(x * x)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[Abs[z], $MachinePrecision], 5.5e+24], N[(N[(t * 4.0), $MachinePrecision] * y + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[Abs[z], $MachinePrecision] * N[Abs[z], $MachinePrecision] + t), $MachinePrecision] * N[(-4.0 * y), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|z\right| \leq 5.5 \cdot 10^{+24}:\\
\;\;\;\;\mathsf{fma}\left(t \cdot 4, y, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\left|z\right|, \left|z\right|, t\right), -4 \cdot y, x \cdot x\right)\\
\end{array}
if z < 5.5000000000000002e24Initial program 90.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6493.0
Applied rewrites93.0%
Taylor expanded in z around 0
Applied rewrites67.1%
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6467.5
Applied rewrites67.5%
if 5.5000000000000002e24 < z Initial program 90.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lift--.f64N/A
sub-flipN/A
distribute-lft-inN/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
associate-*l*N/A
distribute-lft-neg-outN/A
distribute-lft-neg-outN/A
remove-double-negN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-out--N/A
Applied rewrites93.4%
Applied rewrites67.1%
(FPCore (x y z t) :precision binary64 (if (<= (fabs z) 3.8e+63) (fma (* t 4.0) y (* x x)) (fma x x (* (fma (fabs z) (fabs z) t) (* -4.0 y)))))
double code(double x, double y, double z, double t) {
double tmp;
if (fabs(z) <= 3.8e+63) {
tmp = fma((t * 4.0), y, (x * x));
} else {
tmp = fma(x, x, (fma(fabs(z), fabs(z), t) * (-4.0 * y)));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (abs(z) <= 3.8e+63) tmp = fma(Float64(t * 4.0), y, Float64(x * x)); else tmp = fma(x, x, Float64(fma(abs(z), abs(z), t) * Float64(-4.0 * y))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[Abs[z], $MachinePrecision], 3.8e+63], N[(N[(t * 4.0), $MachinePrecision] * y + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(x * x + N[(N[(N[Abs[z], $MachinePrecision] * N[Abs[z], $MachinePrecision] + t), $MachinePrecision] * N[(-4.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|z\right| \leq 3.8 \cdot 10^{+63}:\\
\;\;\;\;\mathsf{fma}\left(t \cdot 4, y, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \mathsf{fma}\left(\left|z\right|, \left|z\right|, t\right) \cdot \left(-4 \cdot y\right)\right)\\
\end{array}
if z < 3.8000000000000001e63Initial program 90.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6493.0
Applied rewrites93.0%
Taylor expanded in z around 0
Applied rewrites67.1%
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6467.5
Applied rewrites67.5%
if 3.8000000000000001e63 < z Initial program 90.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6493.0
Applied rewrites93.0%
Applied rewrites67.5%
(FPCore (x y z t) :precision binary64 (fma x x (* (* t y) 4.0)))
double code(double x, double y, double z, double t) {
return fma(x, x, ((t * y) * 4.0));
}
function code(x, y, z, t) return fma(x, x, Float64(Float64(t * y) * 4.0)) end
code[x_, y_, z_, t_] := N[(x * x + N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]
\mathsf{fma}\left(x, x, \left(t \cdot y\right) \cdot 4\right)
Initial program 90.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6493.0
Applied rewrites93.0%
Taylor expanded in z around 0
Applied rewrites67.1%
(FPCore (x y z t) :precision binary64 (if (<= (fabs x) 20500000.0) (* 4.0 (* t y)) (fma (fabs x) (fabs x) (* t (* -4.0 y)))))
double code(double x, double y, double z, double t) {
double tmp;
if (fabs(x) <= 20500000.0) {
tmp = 4.0 * (t * y);
} else {
tmp = fma(fabs(x), fabs(x), (t * (-4.0 * y)));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (abs(x) <= 20500000.0) tmp = Float64(4.0 * Float64(t * y)); else tmp = fma(abs(x), abs(x), Float64(t * Float64(-4.0 * y))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[Abs[x], $MachinePrecision], 20500000.0], N[(4.0 * N[(t * y), $MachinePrecision]), $MachinePrecision], N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision] + N[(t * N[(-4.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 20500000:\\
\;\;\;\;4 \cdot \left(t \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left|x\right|, \left|x\right|, t \cdot \left(-4 \cdot y\right)\right)\\
\end{array}
if x < 2.05e7Initial program 90.8%
Taylor expanded in t around inf
lower-*.f64N/A
lower-*.f6430.8
Applied rewrites30.8%
if 2.05e7 < x Initial program 90.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6493.0
Applied rewrites93.0%
Applied rewrites67.5%
Taylor expanded in z around 0
Applied rewrites42.0%
(FPCore (x y z t) :precision binary64 (* 4.0 (* t y)))
double code(double x, double y, double z, double t) {
return 4.0 * (t * y);
}
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 = 4.0d0 * (t * y)
end function
public static double code(double x, double y, double z, double t) {
return 4.0 * (t * y);
}
def code(x, y, z, t): return 4.0 * (t * y)
function code(x, y, z, t) return Float64(4.0 * Float64(t * y)) end
function tmp = code(x, y, z, t) tmp = 4.0 * (t * y); end
code[x_, y_, z_, t_] := N[(4.0 * N[(t * y), $MachinePrecision]), $MachinePrecision]
4 \cdot \left(t \cdot y\right)
Initial program 90.8%
Taylor expanded in t around inf
lower-*.f64N/A
lower-*.f6430.8
Applied rewrites30.8%
(FPCore (x y z t) :precision binary64 (* -4.0 (* t y)))
double code(double x, double y, double z, double t) {
return -4.0 * (t * y);
}
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 = (-4.0d0) * (t * y)
end function
public static double code(double x, double y, double z, double t) {
return -4.0 * (t * y);
}
def code(x, y, z, t): return -4.0 * (t * y)
function code(x, y, z, t) return Float64(-4.0 * Float64(t * y)) end
function tmp = code(x, y, z, t) tmp = -4.0 * (t * y); end
code[x_, y_, z_, t_] := N[(-4.0 * N[(t * y), $MachinePrecision]), $MachinePrecision]
-4 \cdot \left(t \cdot y\right)
Initial program 90.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lift--.f64N/A
sub-flipN/A
distribute-lft-inN/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
associate-*l*N/A
distribute-lft-neg-outN/A
distribute-lft-neg-outN/A
remove-double-negN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-out--N/A
Applied rewrites93.4%
Applied rewrites67.1%
Taylor expanded in t around inf
lower-*.f64N/A
lower-*.f646.2
Applied rewrites6.2%
herbie shell --seed 2025171
(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))))