
(FPCore (x y) :precision binary64 (fmax (- (+ (pow y 2.0) (pow x 2.0)) 0.5) (fmax x y)))
double code(double x, double y) {
return fmax(((pow(y, 2.0) + pow(x, 2.0)) - 0.5), fmax(x, 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = fmax((((y ** 2.0d0) + (x ** 2.0d0)) - 0.5d0), fmax(x, y))
end function
public static double code(double x, double y) {
return fmax(((Math.pow(y, 2.0) + Math.pow(x, 2.0)) - 0.5), fmax(x, y));
}
def code(x, y): return fmax(((math.pow(y, 2.0) + math.pow(x, 2.0)) - 0.5), fmax(x, y))
function code(x, y) return fmax(Float64(Float64((y ^ 2.0) + (x ^ 2.0)) - 0.5), fmax(x, y)) end
function tmp = code(x, y) tmp = max((((y ^ 2.0) + (x ^ 2.0)) - 0.5), max(x, y)); end
code[x_, y_] := N[Max[N[(N[(N[Power[y, 2.0], $MachinePrecision] + N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision], N[Max[x, y], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{max}\left(\left({y}^{2} + {x}^{2}\right) - 0.5, \mathsf{max}\left(x, y\right)\right)
\end{array}
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (fmax (- (+ (pow y 2.0) (pow x 2.0)) 0.5) (fmax x y)))
double code(double x, double y) {
return fmax(((pow(y, 2.0) + pow(x, 2.0)) - 0.5), fmax(x, 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = fmax((((y ** 2.0d0) + (x ** 2.0d0)) - 0.5d0), fmax(x, y))
end function
public static double code(double x, double y) {
return fmax(((Math.pow(y, 2.0) + Math.pow(x, 2.0)) - 0.5), fmax(x, y));
}
def code(x, y): return fmax(((math.pow(y, 2.0) + math.pow(x, 2.0)) - 0.5), fmax(x, y))
function code(x, y) return fmax(Float64(Float64((y ^ 2.0) + (x ^ 2.0)) - 0.5), fmax(x, y)) end
function tmp = code(x, y) tmp = max((((y ^ 2.0) + (x ^ 2.0)) - 0.5), max(x, y)); end
code[x_, y_] := N[Max[N[(N[(N[Power[y, 2.0], $MachinePrecision] + N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision], N[Max[x, y], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{max}\left(\left({y}^{2} + {x}^{2}\right) - 0.5, \mathsf{max}\left(x, y\right)\right)
\end{array}
(FPCore (x y) :precision binary64 (fmax (- (+ (pow y 2.0) (* x x)) 0.5) (fmax x y)))
double code(double x, double y) {
return fmax(((pow(y, 2.0) + (x * x)) - 0.5), fmax(x, 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = fmax((((y ** 2.0d0) + (x * x)) - 0.5d0), fmax(x, y))
end function
public static double code(double x, double y) {
return fmax(((Math.pow(y, 2.0) + (x * x)) - 0.5), fmax(x, y));
}
def code(x, y): return fmax(((math.pow(y, 2.0) + (x * x)) - 0.5), fmax(x, y))
function code(x, y) return fmax(Float64(Float64((y ^ 2.0) + Float64(x * x)) - 0.5), fmax(x, y)) end
function tmp = code(x, y) tmp = max((((y ^ 2.0) + (x * x)) - 0.5), max(x, y)); end
code[x_, y_] := N[Max[N[(N[(N[Power[y, 2.0], $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision], N[Max[x, y], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{max}\left(\left({y}^{2} + x \cdot x\right) - 0.5, \mathsf{max}\left(x, y\right)\right)
\end{array}
Initial program 100.0%
Applied rewrites100.0%
(FPCore (x y) :precision binary64 (fmax (- (* (+ y x) (+ y x)) 0.5) (fmax x y)))
double code(double x, double y) {
return fmax((((y + x) * (y + x)) - 0.5), fmax(x, 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = fmax((((y + x) * (y + x)) - 0.5d0), fmax(x, y))
end function
public static double code(double x, double y) {
return fmax((((y + x) * (y + x)) - 0.5), fmax(x, y));
}
def code(x, y): return fmax((((y + x) * (y + x)) - 0.5), fmax(x, y))
function code(x, y) return fmax(Float64(Float64(Float64(y + x) * Float64(y + x)) - 0.5), fmax(x, y)) end
function tmp = code(x, y) tmp = max((((y + x) * (y + x)) - 0.5), max(x, y)); end
code[x_, y_] := N[Max[N[(N[(N[(y + x), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision], N[Max[x, y], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{max}\left(\left(y + x\right) \cdot \left(y + x\right) - 0.5, \mathsf{max}\left(x, y\right)\right)
\end{array}
Initial program 100.0%
Applied rewrites99.4%
(FPCore (x y)
:precision binary64
(if (<= y -9.6e+21)
(fmax -0.5 (fmax x (* y y)))
(if (<= y 2.9)
(fmax (- (* x x) 0.5) (fmax x y))
(fmax (- (* y y) 0.5) (fmax x y)))))
double code(double x, double y) {
double tmp;
if (y <= -9.6e+21) {
tmp = fmax(-0.5, fmax(x, (y * y)));
} else if (y <= 2.9) {
tmp = fmax(((x * x) - 0.5), fmax(x, y));
} else {
tmp = fmax(((y * y) - 0.5), fmax(x, y));
}
return tmp;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-9.6d+21)) then
tmp = fmax((-0.5d0), fmax(x, (y * y)))
else if (y <= 2.9d0) then
tmp = fmax(((x * x) - 0.5d0), fmax(x, y))
else
tmp = fmax(((y * y) - 0.5d0), fmax(x, y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -9.6e+21) {
tmp = fmax(-0.5, fmax(x, (y * y)));
} else if (y <= 2.9) {
tmp = fmax(((x * x) - 0.5), fmax(x, y));
} else {
tmp = fmax(((y * y) - 0.5), fmax(x, y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -9.6e+21: tmp = fmax(-0.5, fmax(x, (y * y))) elif y <= 2.9: tmp = fmax(((x * x) - 0.5), fmax(x, y)) else: tmp = fmax(((y * y) - 0.5), fmax(x, y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -9.6e+21) tmp = fmax(-0.5, fmax(x, Float64(y * y))); elseif (y <= 2.9) tmp = fmax(Float64(Float64(x * x) - 0.5), fmax(x, y)); else tmp = fmax(Float64(Float64(y * y) - 0.5), fmax(x, y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -9.6e+21) tmp = max(-0.5, max(x, (y * y))); elseif (y <= 2.9) tmp = max(((x * x) - 0.5), max(x, y)); else tmp = max(((y * y) - 0.5), max(x, y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -9.6e+21], N[Max[-0.5, N[Max[x, N[(y * y), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], If[LessEqual[y, 2.9], N[Max[N[(N[(x * x), $MachinePrecision] - 0.5), $MachinePrecision], N[Max[x, y], $MachinePrecision]], $MachinePrecision], N[Max[N[(N[(y * y), $MachinePrecision] - 0.5), $MachinePrecision], N[Max[x, y], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.6 \cdot 10^{+21}:\\
\;\;\;\;\mathsf{max}\left(-0.5, \mathsf{max}\left(x, y \cdot y\right)\right)\\
\mathbf{elif}\;y \leq 2.9:\\
\;\;\;\;\mathsf{max}\left(x \cdot x - 0.5, \mathsf{max}\left(x, y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(y \cdot y - 0.5, \mathsf{max}\left(x, y\right)\right)\\
\end{array}
\end{array}
if y < -9.6e21Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites67.0%
Taylor expanded in x around 0
Applied rewrites29.0%
Applied rewrites51.4%
if -9.6e21 < y < 2.89999999999999991Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites67.0%
Applied rewrites67.0%
if 2.89999999999999991 < y Initial program 100.0%
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites68.0%
Taylor expanded in x around 0
Applied rewrites68.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (fmax -0.5 (fmax x (* y y)))))
(if (<= y -9.6e+21)
t_0
(if (<= y 10500.0) (fmax (- (* x x) 0.5) (fmax x y)) t_0))))
double code(double x, double y) {
double t_0 = fmax(-0.5, fmax(x, (y * y)));
double tmp;
if (y <= -9.6e+21) {
tmp = t_0;
} else if (y <= 10500.0) {
tmp = fmax(((x * x) - 0.5), fmax(x, y));
} else {
tmp = t_0;
}
return tmp;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = fmax((-0.5d0), fmax(x, (y * y)))
if (y <= (-9.6d+21)) then
tmp = t_0
else if (y <= 10500.0d0) then
tmp = fmax(((x * x) - 0.5d0), fmax(x, y))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = fmax(-0.5, fmax(x, (y * y)));
double tmp;
if (y <= -9.6e+21) {
tmp = t_0;
} else if (y <= 10500.0) {
tmp = fmax(((x * x) - 0.5), fmax(x, y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = fmax(-0.5, fmax(x, (y * y))) tmp = 0 if y <= -9.6e+21: tmp = t_0 elif y <= 10500.0: tmp = fmax(((x * x) - 0.5), fmax(x, y)) else: tmp = t_0 return tmp
function code(x, y) t_0 = fmax(-0.5, fmax(x, Float64(y * y))) tmp = 0.0 if (y <= -9.6e+21) tmp = t_0; elseif (y <= 10500.0) tmp = fmax(Float64(Float64(x * x) - 0.5), fmax(x, y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = max(-0.5, max(x, (y * y))); tmp = 0.0; if (y <= -9.6e+21) tmp = t_0; elseif (y <= 10500.0) tmp = max(((x * x) - 0.5), max(x, y)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[Max[-0.5, N[Max[x, N[(y * y), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, -9.6e+21], t$95$0, If[LessEqual[y, 10500.0], N[Max[N[(N[(x * x), $MachinePrecision] - 0.5), $MachinePrecision], N[Max[x, y], $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{max}\left(-0.5, \mathsf{max}\left(x, y \cdot y\right)\right)\\
\mathbf{if}\;y \leq -9.6 \cdot 10^{+21}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 10500:\\
\;\;\;\;\mathsf{max}\left(x \cdot x - 0.5, \mathsf{max}\left(x, y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -9.6e21 or 10500 < y Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites67.0%
Taylor expanded in x around 0
Applied rewrites29.0%
Applied rewrites51.4%
if -9.6e21 < y < 10500Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites67.0%
Applied rewrites67.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (fmax -0.5 (fmax x (* y y)))) (t_1 (fmax -0.5 (fmax (* x x) y))))
(if (<= y -9.6e+21)
t_0
(if (<= y -4.5e-44)
t_1
(if (<= y -2.85e-210)
(fmax (- (fabs x) 0.5) (fmax x y))
(if (<= y 10500.0) t_1 t_0))))))
double code(double x, double y) {
double t_0 = fmax(-0.5, fmax(x, (y * y)));
double t_1 = fmax(-0.5, fmax((x * x), y));
double tmp;
if (y <= -9.6e+21) {
tmp = t_0;
} else if (y <= -4.5e-44) {
tmp = t_1;
} else if (y <= -2.85e-210) {
tmp = fmax((fabs(x) - 0.5), fmax(x, y));
} else if (y <= 10500.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = fmax((-0.5d0), fmax(x, (y * y)))
t_1 = fmax((-0.5d0), fmax((x * x), y))
if (y <= (-9.6d+21)) then
tmp = t_0
else if (y <= (-4.5d-44)) then
tmp = t_1
else if (y <= (-2.85d-210)) then
tmp = fmax((abs(x) - 0.5d0), fmax(x, y))
else if (y <= 10500.0d0) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = fmax(-0.5, fmax(x, (y * y)));
double t_1 = fmax(-0.5, fmax((x * x), y));
double tmp;
if (y <= -9.6e+21) {
tmp = t_0;
} else if (y <= -4.5e-44) {
tmp = t_1;
} else if (y <= -2.85e-210) {
tmp = fmax((Math.abs(x) - 0.5), fmax(x, y));
} else if (y <= 10500.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = fmax(-0.5, fmax(x, (y * y))) t_1 = fmax(-0.5, fmax((x * x), y)) tmp = 0 if y <= -9.6e+21: tmp = t_0 elif y <= -4.5e-44: tmp = t_1 elif y <= -2.85e-210: tmp = fmax((math.fabs(x) - 0.5), fmax(x, y)) elif y <= 10500.0: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = fmax(-0.5, fmax(x, Float64(y * y))) t_1 = fmax(-0.5, fmax(Float64(x * x), y)) tmp = 0.0 if (y <= -9.6e+21) tmp = t_0; elseif (y <= -4.5e-44) tmp = t_1; elseif (y <= -2.85e-210) tmp = fmax(Float64(abs(x) - 0.5), fmax(x, y)); elseif (y <= 10500.0) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = max(-0.5, max(x, (y * y))); t_1 = max(-0.5, max((x * x), y)); tmp = 0.0; if (y <= -9.6e+21) tmp = t_0; elseif (y <= -4.5e-44) tmp = t_1; elseif (y <= -2.85e-210) tmp = max((abs(x) - 0.5), max(x, y)); elseif (y <= 10500.0) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[Max[-0.5, N[Max[x, N[(y * y), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Max[-0.5, N[Max[N[(x * x), $MachinePrecision], y], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, -9.6e+21], t$95$0, If[LessEqual[y, -4.5e-44], t$95$1, If[LessEqual[y, -2.85e-210], N[Max[N[(N[Abs[x], $MachinePrecision] - 0.5), $MachinePrecision], N[Max[x, y], $MachinePrecision]], $MachinePrecision], If[LessEqual[y, 10500.0], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{max}\left(-0.5, \mathsf{max}\left(x, y \cdot y\right)\right)\\
t_1 := \mathsf{max}\left(-0.5, \mathsf{max}\left(x \cdot x, y\right)\right)\\
\mathbf{if}\;y \leq -9.6 \cdot 10^{+21}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -4.5 \cdot 10^{-44}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -2.85 \cdot 10^{-210}:\\
\;\;\;\;\mathsf{max}\left(\left|x\right| - 0.5, \mathsf{max}\left(x, y\right)\right)\\
\mathbf{elif}\;y \leq 10500:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -9.6e21 or 10500 < y Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites67.0%
Taylor expanded in x around 0
Applied rewrites29.0%
Applied rewrites51.4%
if -9.6e21 < y < -4.4999999999999999e-44 or -2.84999999999999985e-210 < y < 10500Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites67.0%
Taylor expanded in x around 0
Applied rewrites29.0%
Applied rewrites50.3%
if -4.4999999999999999e-44 < y < -2.84999999999999985e-210Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites67.0%
Applied rewrites30.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (fmax -0.5 (fmax x (* y y)))) (t_1 (fmax -0.5 (fmax (* x x) y))))
(if (<= y -9.6e+21)
t_0
(if (<= y -6.2e-47)
t_1
(if (<= y -1.25e-208)
(fmax -0.5 (fmax x y))
(if (<= y 10500.0) t_1 t_0))))))
double code(double x, double y) {
double t_0 = fmax(-0.5, fmax(x, (y * y)));
double t_1 = fmax(-0.5, fmax((x * x), y));
double tmp;
if (y <= -9.6e+21) {
tmp = t_0;
} else if (y <= -6.2e-47) {
tmp = t_1;
} else if (y <= -1.25e-208) {
tmp = fmax(-0.5, fmax(x, y));
} else if (y <= 10500.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = fmax((-0.5d0), fmax(x, (y * y)))
t_1 = fmax((-0.5d0), fmax((x * x), y))
if (y <= (-9.6d+21)) then
tmp = t_0
else if (y <= (-6.2d-47)) then
tmp = t_1
else if (y <= (-1.25d-208)) then
tmp = fmax((-0.5d0), fmax(x, y))
else if (y <= 10500.0d0) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = fmax(-0.5, fmax(x, (y * y)));
double t_1 = fmax(-0.5, fmax((x * x), y));
double tmp;
if (y <= -9.6e+21) {
tmp = t_0;
} else if (y <= -6.2e-47) {
tmp = t_1;
} else if (y <= -1.25e-208) {
tmp = fmax(-0.5, fmax(x, y));
} else if (y <= 10500.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = fmax(-0.5, fmax(x, (y * y))) t_1 = fmax(-0.5, fmax((x * x), y)) tmp = 0 if y <= -9.6e+21: tmp = t_0 elif y <= -6.2e-47: tmp = t_1 elif y <= -1.25e-208: tmp = fmax(-0.5, fmax(x, y)) elif y <= 10500.0: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = fmax(-0.5, fmax(x, Float64(y * y))) t_1 = fmax(-0.5, fmax(Float64(x * x), y)) tmp = 0.0 if (y <= -9.6e+21) tmp = t_0; elseif (y <= -6.2e-47) tmp = t_1; elseif (y <= -1.25e-208) tmp = fmax(-0.5, fmax(x, y)); elseif (y <= 10500.0) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = max(-0.5, max(x, (y * y))); t_1 = max(-0.5, max((x * x), y)); tmp = 0.0; if (y <= -9.6e+21) tmp = t_0; elseif (y <= -6.2e-47) tmp = t_1; elseif (y <= -1.25e-208) tmp = max(-0.5, max(x, y)); elseif (y <= 10500.0) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[Max[-0.5, N[Max[x, N[(y * y), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Max[-0.5, N[Max[N[(x * x), $MachinePrecision], y], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, -9.6e+21], t$95$0, If[LessEqual[y, -6.2e-47], t$95$1, If[LessEqual[y, -1.25e-208], N[Max[-0.5, N[Max[x, y], $MachinePrecision]], $MachinePrecision], If[LessEqual[y, 10500.0], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{max}\left(-0.5, \mathsf{max}\left(x, y \cdot y\right)\right)\\
t_1 := \mathsf{max}\left(-0.5, \mathsf{max}\left(x \cdot x, y\right)\right)\\
\mathbf{if}\;y \leq -9.6 \cdot 10^{+21}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -6.2 \cdot 10^{-47}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -1.25 \cdot 10^{-208}:\\
\;\;\;\;\mathsf{max}\left(-0.5, \mathsf{max}\left(x, y\right)\right)\\
\mathbf{elif}\;y \leq 10500:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -9.6e21 or 10500 < y Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites67.0%
Taylor expanded in x around 0
Applied rewrites29.0%
Applied rewrites51.4%
if -9.6e21 < y < -6.1999999999999996e-47 or -1.24999999999999991e-208 < y < 10500Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites67.0%
Taylor expanded in x around 0
Applied rewrites29.0%
Applied rewrites50.3%
if -6.1999999999999996e-47 < y < -1.24999999999999991e-208Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites67.0%
Taylor expanded in x around 0
Applied rewrites29.0%
(FPCore (x y) :precision binary64 (if (<= (fmax (- (+ (pow y 2.0) (pow x 2.0)) 0.5) (fmax x y)) 2e-33) (fmax -0.5 (fmax x y)) (fmax -0.5 (fmax x (* y y)))))
double code(double x, double y) {
double tmp;
if (fmax(((pow(y, 2.0) + pow(x, 2.0)) - 0.5), fmax(x, y)) <= 2e-33) {
tmp = fmax(-0.5, fmax(x, y));
} else {
tmp = fmax(-0.5, fmax(x, (y * y)));
}
return tmp;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (fmax((((y ** 2.0d0) + (x ** 2.0d0)) - 0.5d0), fmax(x, y)) <= 2d-33) then
tmp = fmax((-0.5d0), fmax(x, y))
else
tmp = fmax((-0.5d0), fmax(x, (y * y)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (fmax(((Math.pow(y, 2.0) + Math.pow(x, 2.0)) - 0.5), fmax(x, y)) <= 2e-33) {
tmp = fmax(-0.5, fmax(x, y));
} else {
tmp = fmax(-0.5, fmax(x, (y * y)));
}
return tmp;
}
def code(x, y): tmp = 0 if fmax(((math.pow(y, 2.0) + math.pow(x, 2.0)) - 0.5), fmax(x, y)) <= 2e-33: tmp = fmax(-0.5, fmax(x, y)) else: tmp = fmax(-0.5, fmax(x, (y * y))) return tmp
function code(x, y) tmp = 0.0 if (fmax(Float64(Float64((y ^ 2.0) + (x ^ 2.0)) - 0.5), fmax(x, y)) <= 2e-33) tmp = fmax(-0.5, fmax(x, y)); else tmp = fmax(-0.5, fmax(x, Float64(y * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (max((((y ^ 2.0) + (x ^ 2.0)) - 0.5), max(x, y)) <= 2e-33) tmp = max(-0.5, max(x, y)); else tmp = max(-0.5, max(x, (y * y))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Max[N[(N[(N[Power[y, 2.0], $MachinePrecision] + N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision], N[Max[x, y], $MachinePrecision]], $MachinePrecision], 2e-33], N[Max[-0.5, N[Max[x, y], $MachinePrecision]], $MachinePrecision], N[Max[-0.5, N[Max[x, N[(y * y), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\mathsf{max}\left(\left({y}^{2} + {x}^{2}\right) - 0.5, \mathsf{max}\left(x, y\right)\right) \leq 2 \cdot 10^{-33}:\\
\;\;\;\;\mathsf{max}\left(-0.5, \mathsf{max}\left(x, y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(-0.5, \mathsf{max}\left(x, y \cdot y\right)\right)\\
\end{array}
\end{array}
if (fmax.f64 (-.f64 (+.f64 (pow.f64 y #s(literal 2 binary64)) (pow.f64 x #s(literal 2 binary64))) #s(literal 1/2 binary64)) (fmax.f64 x y)) < 2.0000000000000001e-33Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites67.0%
Taylor expanded in x around 0
Applied rewrites29.0%
if 2.0000000000000001e-33 < (fmax.f64 (-.f64 (+.f64 (pow.f64 y #s(literal 2 binary64)) (pow.f64 x #s(literal 2 binary64))) #s(literal 1/2 binary64)) (fmax.f64 x y)) Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites67.0%
Taylor expanded in x around 0
Applied rewrites29.0%
Applied rewrites51.4%
(FPCore (x y) :precision binary64 (fmax -0.5 (fmax x y)))
double code(double x, double y) {
return fmax(-0.5, fmax(x, 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = fmax((-0.5d0), fmax(x, y))
end function
public static double code(double x, double y) {
return fmax(-0.5, fmax(x, y));
}
def code(x, y): return fmax(-0.5, fmax(x, y))
function code(x, y) return fmax(-0.5, fmax(x, y)) end
function tmp = code(x, y) tmp = max(-0.5, max(x, y)); end
code[x_, y_] := N[Max[-0.5, N[Max[x, y], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{max}\left(-0.5, \mathsf{max}\left(x, y\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites67.0%
Taylor expanded in x around 0
Applied rewrites29.0%
(FPCore (x y) :precision binary64 (fmax 1.5 (fmax x y)))
double code(double x, double y) {
return fmax(1.5, fmax(x, 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = fmax(1.5d0, fmax(x, y))
end function
public static double code(double x, double y) {
return fmax(1.5, fmax(x, y));
}
def code(x, y): return fmax(1.5, fmax(x, y))
function code(x, y) return fmax(1.5, fmax(x, y)) end
function tmp = code(x, y) tmp = max(1.5, max(x, y)); end
code[x_, y_] := N[Max[1.5, N[Max[x, y], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{max}\left(1.5, \mathsf{max}\left(x, y\right)\right)
\end{array}
Initial program 100.0%
Applied rewrites29.0%
Applied rewrites29.9%
Applied rewrites5.4%
Taylor expanded in x around 0
Applied rewrites5.4%
herbie shell --seed 2025159
(FPCore (x y)
:name "A quarter-circle in the lower-left quadrant"
:precision binary64
(fmax (- (+ (pow y 2.0) (pow x 2.0)) 0.5) (fmax x y)))