
(FPCore (x y z) :precision binary64 (+ (+ (+ (* x y) (* z z)) (* z z)) (* z z)))
double code(double x, double y, double z) {
return (((x * y) + (z * z)) + (z * z)) + (z * z);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((x * y) + (z * z)) + (z * z)) + (z * z)
end function
public static double code(double x, double y, double z) {
return (((x * y) + (z * z)) + (z * z)) + (z * z);
}
def code(x, y, z): return (((x * y) + (z * z)) + (z * z)) + (z * z)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * y) + Float64(z * z)) + Float64(z * z)) + Float64(z * z)) end
function tmp = code(x, y, z) tmp = (((x * y) + (z * z)) + (z * z)) + (z * z); end
code[x_, y_, z_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
\end{array}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (+ (+ (* x y) (* z z)) (* z z)) (* z z)))
double code(double x, double y, double z) {
return (((x * y) + (z * z)) + (z * z)) + (z * z);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((x * y) + (z * z)) + (z * z)) + (z * z)
end function
public static double code(double x, double y, double z) {
return (((x * y) + (z * z)) + (z * z)) + (z * z);
}
def code(x, y, z): return (((x * y) + (z * z)) + (z * z)) + (z * z)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * y) + Float64(z * z)) + Float64(z * z)) + Float64(z * z)) end
function tmp = code(x, y, z) tmp = (((x * y) + (z * z)) + (z * z)) + (z * z); end
code[x_, y_, z_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
\end{array}
z_m = (fabs.f64 z) (FPCore (x y z_m) :precision binary64 (if (<= z_m 5e+153) (fma (* 3.0 z_m) z_m (* y x)) (* z_m z_m)))
z_m = fabs(z);
double code(double x, double y, double z_m) {
double tmp;
if (z_m <= 5e+153) {
tmp = fma((3.0 * z_m), z_m, (y * x));
} else {
tmp = z_m * z_m;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m) tmp = 0.0 if (z_m <= 5e+153) tmp = fma(Float64(3.0 * z_m), z_m, Float64(y * x)); else tmp = Float64(z_m * z_m); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 5e+153], N[(N[(3.0 * z$95$m), $MachinePrecision] * z$95$m + N[(y * x), $MachinePrecision]), $MachinePrecision], N[(z$95$m * z$95$m), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 5 \cdot 10^{+153}:\\
\;\;\;\;\mathsf{fma}\left(3 \cdot z\_m, z\_m, y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;z\_m \cdot z\_m\\
\end{array}
\end{array}
if z < 5.00000000000000018e153Initial program 98.4%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
associate-+l+N/A
count-2-revN/A
pow2N/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
pow2N/A
distribute-lft1-inN/A
metadata-evalN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites99.0%
if 5.00000000000000018e153 < z Initial program 98.4%
Taylor expanded in x around 0
pow2N/A
pow2N/A
distribute-lft1-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-*.f6453.3
Applied rewrites53.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6453.3
Applied rewrites53.3%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
distribute-lft1-inN/A
count-2-revN/A
associate-+l+N/A
flip-+N/A
pow2N/A
pow2N/A
+-inversesN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
+-inversesN/A
metadata-evalN/A
flip-+N/A
metadata-evalN/A
lower-+.f6429.4
Applied rewrites29.4%
Taylor expanded in z around inf
Applied rewrites33.0%
z_m = (fabs.f64 z) (FPCore (x y z_m) :precision binary64 (if (<= z_m 6.3e-24) (fma z_m z_m (* x y)) (fma z_m (+ z_m z_m) (* z_m z_m))))
z_m = fabs(z);
double code(double x, double y, double z_m) {
double tmp;
if (z_m <= 6.3e-24) {
tmp = fma(z_m, z_m, (x * y));
} else {
tmp = fma(z_m, (z_m + z_m), (z_m * z_m));
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m) tmp = 0.0 if (z_m <= 6.3e-24) tmp = fma(z_m, z_m, Float64(x * y)); else tmp = fma(z_m, Float64(z_m + z_m), Float64(z_m * z_m)); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 6.3e-24], N[(z$95$m * z$95$m + N[(x * y), $MachinePrecision]), $MachinePrecision], N[(z$95$m * N[(z$95$m + z$95$m), $MachinePrecision] + N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 6.3 \cdot 10^{-24}:\\
\;\;\;\;\mathsf{fma}\left(z\_m, z\_m, x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z\_m, z\_m + z\_m, z\_m \cdot z\_m\right)\\
\end{array}
\end{array}
if z < 6.29999999999999979e-24Initial program 98.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6477.4
Applied rewrites77.4%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-fma.f6478.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.0
Applied rewrites78.0%
if 6.29999999999999979e-24 < z Initial program 98.4%
Taylor expanded in x around 0
pow2N/A
pow2N/A
distribute-lft1-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-*.f6453.3
Applied rewrites53.3%
lift-*.f64N/A
lift-*.f64N/A
metadata-evalN/A
distribute-lft1-inN/A
count-2-revN/A
distribute-rgt-outN/A
lower-fma.f64N/A
lower-+.f64N/A
lift-*.f6453.3
Applied rewrites53.3%
z_m = (fabs.f64 z) (FPCore (x y z_m) :precision binary64 (if (<= z_m 6.3e-24) (fma z_m z_m (* x y)) (* (* z_m 3.0) z_m)))
z_m = fabs(z);
double code(double x, double y, double z_m) {
double tmp;
if (z_m <= 6.3e-24) {
tmp = fma(z_m, z_m, (x * y));
} else {
tmp = (z_m * 3.0) * z_m;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m) tmp = 0.0 if (z_m <= 6.3e-24) tmp = fma(z_m, z_m, Float64(x * y)); else tmp = Float64(Float64(z_m * 3.0) * z_m); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 6.3e-24], N[(z$95$m * z$95$m + N[(x * y), $MachinePrecision]), $MachinePrecision], N[(N[(z$95$m * 3.0), $MachinePrecision] * z$95$m), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 6.3 \cdot 10^{-24}:\\
\;\;\;\;\mathsf{fma}\left(z\_m, z\_m, x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z\_m \cdot 3\right) \cdot z\_m\\
\end{array}
\end{array}
if z < 6.29999999999999979e-24Initial program 98.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6477.4
Applied rewrites77.4%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-fma.f6478.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.0
Applied rewrites78.0%
if 6.29999999999999979e-24 < z Initial program 98.4%
Taylor expanded in x around 0
pow2N/A
pow2N/A
distribute-lft1-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-*.f6453.3
Applied rewrites53.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6453.3
Applied rewrites53.3%
z_m = (fabs.f64 z) (FPCore (x y z_m) :precision binary64 (if (<= z_m 6.3e-24) (* y x) (* (* z_m 3.0) z_m)))
z_m = fabs(z);
double code(double x, double y, double z_m) {
double tmp;
if (z_m <= 6.3e-24) {
tmp = y * x;
} else {
tmp = (z_m * 3.0) * z_m;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (z_m <= 6.3d-24) then
tmp = y * x
else
tmp = (z_m * 3.0d0) * z_m
end if
code = tmp
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m) {
double tmp;
if (z_m <= 6.3e-24) {
tmp = y * x;
} else {
tmp = (z_m * 3.0) * z_m;
}
return tmp;
}
z_m = math.fabs(z) def code(x, y, z_m): tmp = 0 if z_m <= 6.3e-24: tmp = y * x else: tmp = (z_m * 3.0) * z_m return tmp
z_m = abs(z) function code(x, y, z_m) tmp = 0.0 if (z_m <= 6.3e-24) tmp = Float64(y * x); else tmp = Float64(Float64(z_m * 3.0) * z_m); end return tmp end
z_m = abs(z); function tmp_2 = code(x, y, z_m) tmp = 0.0; if (z_m <= 6.3e-24) tmp = y * x; else tmp = (z_m * 3.0) * z_m; end tmp_2 = tmp; end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 6.3e-24], N[(y * x), $MachinePrecision], N[(N[(z$95$m * 3.0), $MachinePrecision] * z$95$m), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 6.3 \cdot 10^{-24}:\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(z\_m \cdot 3\right) \cdot z\_m\\
\end{array}
\end{array}
if z < 6.29999999999999979e-24Initial program 98.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6453.5
Applied rewrites53.5%
if 6.29999999999999979e-24 < z Initial program 98.4%
Taylor expanded in x around 0
pow2N/A
pow2N/A
distribute-lft1-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-*.f6453.3
Applied rewrites53.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6453.3
Applied rewrites53.3%
z_m = (fabs.f64 z) (FPCore (x y z_m) :precision binary64 (if (<= z_m 6.3e-24) (* y x) (* 3.0 (* z_m z_m))))
z_m = fabs(z);
double code(double x, double y, double z_m) {
double tmp;
if (z_m <= 6.3e-24) {
tmp = y * x;
} else {
tmp = 3.0 * (z_m * z_m);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (z_m <= 6.3d-24) then
tmp = y * x
else
tmp = 3.0d0 * (z_m * z_m)
end if
code = tmp
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m) {
double tmp;
if (z_m <= 6.3e-24) {
tmp = y * x;
} else {
tmp = 3.0 * (z_m * z_m);
}
return tmp;
}
z_m = math.fabs(z) def code(x, y, z_m): tmp = 0 if z_m <= 6.3e-24: tmp = y * x else: tmp = 3.0 * (z_m * z_m) return tmp
z_m = abs(z) function code(x, y, z_m) tmp = 0.0 if (z_m <= 6.3e-24) tmp = Float64(y * x); else tmp = Float64(3.0 * Float64(z_m * z_m)); end return tmp end
z_m = abs(z); function tmp_2 = code(x, y, z_m) tmp = 0.0; if (z_m <= 6.3e-24) tmp = y * x; else tmp = 3.0 * (z_m * z_m); end tmp_2 = tmp; end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 6.3e-24], N[(y * x), $MachinePrecision], N[(3.0 * N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 6.3 \cdot 10^{-24}:\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;3 \cdot \left(z\_m \cdot z\_m\right)\\
\end{array}
\end{array}
if z < 6.29999999999999979e-24Initial program 98.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6453.5
Applied rewrites53.5%
if 6.29999999999999979e-24 < z Initial program 98.4%
Taylor expanded in x around 0
pow2N/A
pow2N/A
distribute-lft1-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-*.f6453.3
Applied rewrites53.3%
z_m = (fabs.f64 z) (FPCore (x y z_m) :precision binary64 (if (<= z_m 9.6e+91) (* y x) (* z_m (+ z_m z_m))))
z_m = fabs(z);
double code(double x, double y, double z_m) {
double tmp;
if (z_m <= 9.6e+91) {
tmp = y * x;
} else {
tmp = z_m * (z_m + z_m);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (z_m <= 9.6d+91) then
tmp = y * x
else
tmp = z_m * (z_m + z_m)
end if
code = tmp
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m) {
double tmp;
if (z_m <= 9.6e+91) {
tmp = y * x;
} else {
tmp = z_m * (z_m + z_m);
}
return tmp;
}
z_m = math.fabs(z) def code(x, y, z_m): tmp = 0 if z_m <= 9.6e+91: tmp = y * x else: tmp = z_m * (z_m + z_m) return tmp
z_m = abs(z) function code(x, y, z_m) tmp = 0.0 if (z_m <= 9.6e+91) tmp = Float64(y * x); else tmp = Float64(z_m * Float64(z_m + z_m)); end return tmp end
z_m = abs(z); function tmp_2 = code(x, y, z_m) tmp = 0.0; if (z_m <= 9.6e+91) tmp = y * x; else tmp = z_m * (z_m + z_m); end tmp_2 = tmp; end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 9.6e+91], N[(y * x), $MachinePrecision], N[(z$95$m * N[(z$95$m + z$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 9.6 \cdot 10^{+91}:\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;z\_m \cdot \left(z\_m + z\_m\right)\\
\end{array}
\end{array}
if z < 9.59999999999999932e91Initial program 98.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6453.5
Applied rewrites53.5%
if 9.59999999999999932e91 < z Initial program 98.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6477.4
Applied rewrites77.4%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-fma.f6478.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.0
Applied rewrites78.0%
lift-fma.f64N/A
pow2N/A
+-commutativeN/A
pow2N/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
pow2N/A
*-lft-identityN/A
metadata-evalN/A
associate-*l/N/A
Applied rewrites36.5%
Taylor expanded in z around inf
count-2-revN/A
pow2N/A
pow2N/A
distribute-rgt-outN/A
count-2-revN/A
lower-*.f64N/A
count-2-revN/A
lower-+.f6433.6
Applied rewrites33.6%
z_m = (fabs.f64 z) (FPCore (x y z_m) :precision binary64 (if (<= z_m 9.6e+91) (* y x) (* z_m z_m)))
z_m = fabs(z);
double code(double x, double y, double z_m) {
double tmp;
if (z_m <= 9.6e+91) {
tmp = y * x;
} else {
tmp = z_m * z_m;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (z_m <= 9.6d+91) then
tmp = y * x
else
tmp = z_m * z_m
end if
code = tmp
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m) {
double tmp;
if (z_m <= 9.6e+91) {
tmp = y * x;
} else {
tmp = z_m * z_m;
}
return tmp;
}
z_m = math.fabs(z) def code(x, y, z_m): tmp = 0 if z_m <= 9.6e+91: tmp = y * x else: tmp = z_m * z_m return tmp
z_m = abs(z) function code(x, y, z_m) tmp = 0.0 if (z_m <= 9.6e+91) tmp = Float64(y * x); else tmp = Float64(z_m * z_m); end return tmp end
z_m = abs(z); function tmp_2 = code(x, y, z_m) tmp = 0.0; if (z_m <= 9.6e+91) tmp = y * x; else tmp = z_m * z_m; end tmp_2 = tmp; end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 9.6e+91], N[(y * x), $MachinePrecision], N[(z$95$m * z$95$m), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 9.6 \cdot 10^{+91}:\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;z\_m \cdot z\_m\\
\end{array}
\end{array}
if z < 9.59999999999999932e91Initial program 98.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6453.5
Applied rewrites53.5%
if 9.59999999999999932e91 < z Initial program 98.4%
Taylor expanded in x around 0
pow2N/A
pow2N/A
distribute-lft1-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-*.f6453.3
Applied rewrites53.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6453.3
Applied rewrites53.3%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
distribute-lft1-inN/A
count-2-revN/A
associate-+l+N/A
flip-+N/A
pow2N/A
pow2N/A
+-inversesN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
+-inversesN/A
metadata-evalN/A
flip-+N/A
metadata-evalN/A
lower-+.f6429.4
Applied rewrites29.4%
Taylor expanded in z around inf
Applied rewrites33.0%
z_m = (fabs.f64 z) (FPCore (x y z_m) :precision binary64 (* y x))
z_m = fabs(z);
double code(double x, double y, double z_m) {
return y * 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
code = y * x
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m) {
return y * x;
}
z_m = math.fabs(z) def code(x, y, z_m): return y * x
z_m = abs(z) function code(x, y, z_m) return Float64(y * x) end
z_m = abs(z); function tmp = code(x, y, z_m) tmp = y * x; end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_] := N[(y * x), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
y \cdot x
\end{array}
Initial program 98.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6453.5
Applied rewrites53.5%
z_m = (fabs.f64 z) (FPCore (x y z_m) :precision binary64 (+ z_m z_m))
z_m = fabs(z);
double code(double x, double y, double z_m) {
return z_m + z_m;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
code = z_m + z_m
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m) {
return z_m + z_m;
}
z_m = math.fabs(z) def code(x, y, z_m): return z_m + z_m
z_m = abs(z) function code(x, y, z_m) return Float64(z_m + z_m) end
z_m = abs(z); function tmp = code(x, y, z_m) tmp = z_m + z_m; end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_] := N[(z$95$m + z$95$m), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
z\_m + z\_m
\end{array}
Initial program 98.4%
Taylor expanded in x around 0
pow2N/A
pow2N/A
distribute-lft1-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-*.f6453.3
Applied rewrites53.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6453.3
Applied rewrites53.3%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
distribute-lft1-inN/A
count-2-revN/A
associate-+l+N/A
flip-+N/A
pow2N/A
pow2N/A
+-inversesN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
+-inversesN/A
metadata-evalN/A
flip-+N/A
metadata-evalN/A
lower-+.f6429.4
Applied rewrites29.4%
Taylor expanded in z around 0
count-2-revN/A
lower-+.f645.2
Applied rewrites5.2%
z_m = (fabs.f64 z) (FPCore (x y z_m) :precision binary64 3.0)
z_m = fabs(z);
double code(double x, double y, double z_m) {
return 3.0;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
code = 3.0d0
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m) {
return 3.0;
}
z_m = math.fabs(z) def code(x, y, z_m): return 3.0
z_m = abs(z) function code(x, y, z_m) return 3.0 end
z_m = abs(z); function tmp = code(x, y, z_m) tmp = 3.0; end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_] := 3.0
\begin{array}{l}
z_m = \left|z\right|
\\
3
\end{array}
Initial program 98.4%
Taylor expanded in x around 0
pow2N/A
pow2N/A
distribute-lft1-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-*.f6453.3
Applied rewrites53.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6453.3
Applied rewrites53.3%
Taylor expanded in z around 0
*-lft-identityN/A
metadata-evalN/A
associate-*l/N/A
Applied rewrites3.7%
herbie shell --seed 2025123
(FPCore (x y z)
:name "Linear.Quaternion:$c/ from linear-1.19.1.3, A"
:precision binary64
(+ (+ (+ (* x y) (* z z)) (* z z)) (* z z)))