
(FPCore (x y) :precision binary64 (* (cos x) (/ (sinh y) y)))
double code(double x, double y) {
return cos(x) * (sinh(y) / 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 = cos(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.cos(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.cos(x) * (math.sinh(y) / y)
function code(x, y) return Float64(cos(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = cos(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Cos[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot \frac{\sinh y}{y}
\end{array}
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (* (cos x) (/ (sinh y) y)))
double code(double x, double y) {
return cos(x) * (sinh(y) / 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 = cos(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.cos(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.cos(x) * (math.sinh(y) / y)
function code(x, y) return Float64(cos(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = cos(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Cos[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot \frac{\sinh y}{y}
\end{array}
(FPCore (x y) :precision binary64 (* (cos x) (/ (sinh y) y)))
double code(double x, double y) {
return cos(x) * (sinh(y) / 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 = cos(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.cos(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.cos(x) * (math.sinh(y) / y)
function code(x, y) return Float64(cos(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = cos(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Cos[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot \frac{\sinh y}{y}
\end{array}
Initial program 100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (sinh y) y)) (t_1 (* (cos x) t_0)))
(if (<= t_1 (- INFINITY))
(* 0.5 (* (/ (expm1 (+ y y)) y) (- 1.0 y)))
(if (<= t_1 0.9999996849910348) (* (cos x) (/ y y)) (* 1.0 t_0)))))
double code(double x, double y) {
double t_0 = sinh(y) / y;
double t_1 = cos(x) * t_0;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = 0.5 * ((expm1((y + y)) / y) * (1.0 - y));
} else if (t_1 <= 0.9999996849910348) {
tmp = cos(x) * (y / y);
} else {
tmp = 1.0 * t_0;
}
return tmp;
}
public static double code(double x, double y) {
double t_0 = Math.sinh(y) / y;
double t_1 = Math.cos(x) * t_0;
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = 0.5 * ((Math.expm1((y + y)) / y) * (1.0 - y));
} else if (t_1 <= 0.9999996849910348) {
tmp = Math.cos(x) * (y / y);
} else {
tmp = 1.0 * t_0;
}
return tmp;
}
def code(x, y): t_0 = math.sinh(y) / y t_1 = math.cos(x) * t_0 tmp = 0 if t_1 <= -math.inf: tmp = 0.5 * ((math.expm1((y + y)) / y) * (1.0 - y)) elif t_1 <= 0.9999996849910348: tmp = math.cos(x) * (y / y) else: tmp = 1.0 * t_0 return tmp
function code(x, y) t_0 = Float64(sinh(y) / y) t_1 = Float64(cos(x) * t_0) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(0.5 * Float64(Float64(expm1(Float64(y + y)) / y) * Float64(1.0 - y))); elseif (t_1 <= 0.9999996849910348) tmp = Float64(cos(x) * Float64(y / y)); else tmp = Float64(1.0 * t_0); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[x], $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(0.5 * N[(N[(N[(Exp[N[(y + y), $MachinePrecision]] - 1), $MachinePrecision] / y), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.9999996849910348], N[(N[Cos[x], $MachinePrecision] * N[(y / y), $MachinePrecision]), $MachinePrecision], N[(1.0 * t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sinh y}{y}\\
t_1 := \cos x \cdot t\_0\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;0.5 \cdot \left(\frac{\mathsf{expm1}\left(y + y\right)}{y} \cdot \left(1 - y\right)\right)\\
\mathbf{elif}\;t\_1 \leq 0.9999996849910348:\\
\;\;\;\;\cos x \cdot \frac{y}{y}\\
\mathbf{else}:\\
\;\;\;\;1 \cdot t\_0\\
\end{array}
\end{array}
if (*.f64 (cos.f64 x) (/.f64 (sinh.f64 y) y)) < -inf.0Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites39.6%
Applied rewrites46.3%
Taylor expanded in y around 0
Applied rewrites34.5%
Applied rewrites34.5%
if -inf.0 < (*.f64 (cos.f64 x) (/.f64 (sinh.f64 y) y)) < 0.999999684991034754Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites51.4%
if 0.999999684991034754 < (*.f64 (cos.f64 x) (/.f64 (sinh.f64 y) y)) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites65.1%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ (sinh y) y))) (if (<= (* (cos x) t_0) -0.04) (* (fma (* x x) -0.5 1.0) t_0) (* 1.0 t_0))))
double code(double x, double y) {
double t_0 = sinh(y) / y;
double tmp;
if ((cos(x) * t_0) <= -0.04) {
tmp = fma((x * x), -0.5, 1.0) * t_0;
} else {
tmp = 1.0 * t_0;
}
return tmp;
}
function code(x, y) t_0 = Float64(sinh(y) / y) tmp = 0.0 if (Float64(cos(x) * t_0) <= -0.04) tmp = Float64(fma(Float64(x * x), -0.5, 1.0) * t_0); else tmp = Float64(1.0 * t_0); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[N[(N[Cos[x], $MachinePrecision] * t$95$0), $MachinePrecision], -0.04], N[(N[(N[(x * x), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision], N[(1.0 * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sinh y}{y}\\
\mathbf{if}\;\cos x \cdot t\_0 \leq -0.04:\\
\;\;\;\;\mathsf{fma}\left(x \cdot x, -0.5, 1\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;1 \cdot t\_0\\
\end{array}
\end{array}
if (*.f64 (cos.f64 x) (/.f64 (sinh.f64 y) y)) < -0.0400000000000000008Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites63.3%
Applied rewrites63.3%
if -0.0400000000000000008 < (*.f64 (cos.f64 x) (/.f64 (sinh.f64 y) y)) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites65.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (sinh y) y)))
(if (<= (* (cos x) t_0) 0.65)
(* 0.5 (* (/ (expm1 (+ y y)) y) (- 1.0 y)))
(* 1.0 t_0))))
double code(double x, double y) {
double t_0 = sinh(y) / y;
double tmp;
if ((cos(x) * t_0) <= 0.65) {
tmp = 0.5 * ((expm1((y + y)) / y) * (1.0 - y));
} else {
tmp = 1.0 * t_0;
}
return tmp;
}
public static double code(double x, double y) {
double t_0 = Math.sinh(y) / y;
double tmp;
if ((Math.cos(x) * t_0) <= 0.65) {
tmp = 0.5 * ((Math.expm1((y + y)) / y) * (1.0 - y));
} else {
tmp = 1.0 * t_0;
}
return tmp;
}
def code(x, y): t_0 = math.sinh(y) / y tmp = 0 if (math.cos(x) * t_0) <= 0.65: tmp = 0.5 * ((math.expm1((y + y)) / y) * (1.0 - y)) else: tmp = 1.0 * t_0 return tmp
function code(x, y) t_0 = Float64(sinh(y) / y) tmp = 0.0 if (Float64(cos(x) * t_0) <= 0.65) tmp = Float64(0.5 * Float64(Float64(expm1(Float64(y + y)) / y) * Float64(1.0 - y))); else tmp = Float64(1.0 * t_0); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[N[(N[Cos[x], $MachinePrecision] * t$95$0), $MachinePrecision], 0.65], N[(0.5 * N[(N[(N[(Exp[N[(y + y), $MachinePrecision]] - 1), $MachinePrecision] / y), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sinh y}{y}\\
\mathbf{if}\;\cos x \cdot t\_0 \leq 0.65:\\
\;\;\;\;0.5 \cdot \left(\frac{\mathsf{expm1}\left(y + y\right)}{y} \cdot \left(1 - y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 \cdot t\_0\\
\end{array}
\end{array}
if (*.f64 (cos.f64 x) (/.f64 (sinh.f64 y) y)) < 0.650000000000000022Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites39.6%
Applied rewrites46.3%
Taylor expanded in y around 0
Applied rewrites34.5%
Applied rewrites34.5%
if 0.650000000000000022 < (*.f64 (cos.f64 x) (/.f64 (sinh.f64 y) y)) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites65.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (sinh y) y)))
(if (<= (* (cos x) t_0) -0.04)
(* (fma (* x x) -0.5 1.0) (/ y y))
(* 1.0 t_0))))
double code(double x, double y) {
double t_0 = sinh(y) / y;
double tmp;
if ((cos(x) * t_0) <= -0.04) {
tmp = fma((x * x), -0.5, 1.0) * (y / y);
} else {
tmp = 1.0 * t_0;
}
return tmp;
}
function code(x, y) t_0 = Float64(sinh(y) / y) tmp = 0.0 if (Float64(cos(x) * t_0) <= -0.04) tmp = Float64(fma(Float64(x * x), -0.5, 1.0) * Float64(y / y)); else tmp = Float64(1.0 * t_0); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[N[(N[Cos[x], $MachinePrecision] * t$95$0), $MachinePrecision], -0.04], N[(N[(N[(x * x), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[(y / y), $MachinePrecision]), $MachinePrecision], N[(1.0 * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sinh y}{y}\\
\mathbf{if}\;\cos x \cdot t\_0 \leq -0.04:\\
\;\;\;\;\mathsf{fma}\left(x \cdot x, -0.5, 1\right) \cdot \frac{y}{y}\\
\mathbf{else}:\\
\;\;\;\;1 \cdot t\_0\\
\end{array}
\end{array}
if (*.f64 (cos.f64 x) (/.f64 (sinh.f64 y) y)) < -0.0400000000000000008Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites51.4%
Taylor expanded in x around 0
Applied rewrites33.2%
Applied rewrites33.2%
if -0.0400000000000000008 < (*.f64 (cos.f64 x) (/.f64 (sinh.f64 y) y)) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites65.1%
(FPCore (x y) :precision binary64 (if (<= x 2.5e+188) (* 0.5 (* (+ 2.0 (* 2.0 y)) (+ 1.0 (* -1.0 y)))) (* (fma (* x x) -0.5 1.0) (/ y y))))
double code(double x, double y) {
double tmp;
if (x <= 2.5e+188) {
tmp = 0.5 * ((2.0 + (2.0 * y)) * (1.0 + (-1.0 * y)));
} else {
tmp = fma((x * x), -0.5, 1.0) * (y / y);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= 2.5e+188) tmp = Float64(0.5 * Float64(Float64(2.0 + Float64(2.0 * y)) * Float64(1.0 + Float64(-1.0 * y)))); else tmp = Float64(fma(Float64(x * x), -0.5, 1.0) * Float64(y / y)); end return tmp end
code[x_, y_] := If[LessEqual[x, 2.5e+188], N[(0.5 * N[(N[(2.0 + N[(2.0 * y), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-1.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * x), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[(y / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.5 \cdot 10^{+188}:\\
\;\;\;\;0.5 \cdot \left(\left(2 + 2 \cdot y\right) \cdot \left(1 + -1 \cdot y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x \cdot x, -0.5, 1\right) \cdot \frac{y}{y}\\
\end{array}
\end{array}
if x < 2.5000000000000001e188Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites39.6%
Applied rewrites46.3%
Taylor expanded in y around 0
Applied rewrites34.3%
Taylor expanded in y around 0
Applied rewrites34.5%
if 2.5000000000000001e188 < x Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites51.4%
Taylor expanded in x around 0
Applied rewrites33.2%
Applied rewrites33.2%
(FPCore (x y) :precision binary64 (if (<= (* (cos x) (/ (sinh y) y)) -0.04) (* (fma (* x x) -0.5 1.0) (/ y y)) (* 0.5 2.0)))
double code(double x, double y) {
double tmp;
if ((cos(x) * (sinh(y) / y)) <= -0.04) {
tmp = fma((x * x), -0.5, 1.0) * (y / y);
} else {
tmp = 0.5 * 2.0;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (Float64(cos(x) * Float64(sinh(y) / y)) <= -0.04) tmp = Float64(fma(Float64(x * x), -0.5, 1.0) * Float64(y / y)); else tmp = Float64(0.5 * 2.0); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[Cos[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], -0.04], N[(N[(N[(x * x), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[(y / y), $MachinePrecision]), $MachinePrecision], N[(0.5 * 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos x \cdot \frac{\sinh y}{y} \leq -0.04:\\
\;\;\;\;\mathsf{fma}\left(x \cdot x, -0.5, 1\right) \cdot \frac{y}{y}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot 2\\
\end{array}
\end{array}
if (*.f64 (cos.f64 x) (/.f64 (sinh.f64 y) y)) < -0.0400000000000000008Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites51.4%
Taylor expanded in x around 0
Applied rewrites33.2%
Applied rewrites33.2%
if -0.0400000000000000008 < (*.f64 (cos.f64 x) (/.f64 (sinh.f64 y) y)) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites39.6%
Taylor expanded in y around 0
Applied rewrites29.0%
(FPCore (x y) :precision binary64 (* 0.5 2.0))
double code(double x, double y) {
return 0.5 * 2.0;
}
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 = 0.5d0 * 2.0d0
end function
public static double code(double x, double y) {
return 0.5 * 2.0;
}
def code(x, y): return 0.5 * 2.0
function code(x, y) return Float64(0.5 * 2.0) end
function tmp = code(x, y) tmp = 0.5 * 2.0; end
code[x_, y_] := N[(0.5 * 2.0), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot 2
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites39.6%
Taylor expanded in y around 0
Applied rewrites29.0%
herbie shell --seed 2025153
(FPCore (x y)
:name "Linear.Quaternion:$csin from linear-1.19.1.3"
:precision binary64
(* (cos x) (/ (sinh y) y)))