
(FPCore (x y) :precision binary64 (/ (* (sin x) (sinh y)) x))
double code(double x, double y) {
return (sin(x) * sinh(y)) / x;
}
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 = (sin(x) * sinh(y)) / x
end function
public static double code(double x, double y) {
return (Math.sin(x) * Math.sinh(y)) / x;
}
def code(x, y): return (math.sin(x) * math.sinh(y)) / x
function code(x, y) return Float64(Float64(sin(x) * sinh(y)) / x) end
function tmp = code(x, y) tmp = (sin(x) * sinh(y)) / x; end
code[x_, y_] := N[(N[(N[Sin[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin x \cdot \sinh y}{x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* (sin x) (sinh y)) x))
double code(double x, double y) {
return (sin(x) * sinh(y)) / x;
}
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 = (sin(x) * sinh(y)) / x
end function
public static double code(double x, double y) {
return (Math.sin(x) * Math.sinh(y)) / x;
}
def code(x, y): return (math.sin(x) * math.sinh(y)) / x
function code(x, y) return Float64(Float64(sin(x) * sinh(y)) / x) end
function tmp = code(x, y) tmp = (sin(x) * sinh(y)) / x; end
code[x_, y_] := N[(N[(N[Sin[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin x \cdot \sinh y}{x}
\end{array}
(FPCore (x y) :precision binary64 (* (/ (sinh y) x) (sin x)))
double code(double x, double y) {
return (sinh(y) / x) * sin(x);
}
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 = (sinh(y) / x) * sin(x)
end function
public static double code(double x, double y) {
return (Math.sinh(y) / x) * Math.sin(x);
}
def code(x, y): return (math.sinh(y) / x) * math.sin(x)
function code(x, y) return Float64(Float64(sinh(y) / x) * sin(x)) end
function tmp = code(x, y) tmp = (sinh(y) / x) * sin(x); end
code[x_, y_] := N[(N[(N[Sinh[y], $MachinePrecision] / x), $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sinh y}{x} \cdot \sin x
\end{array}
Initial program 92.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* (sin x) (sinh y)) x))
(t_1
(fma
(fma (* y y) 0.008333333333333333 0.16666666666666666)
(* y y)
1.0)))
(if (<= t_0 -2e-7)
(*
(*
(fma
(fma
(fma -0.0001984126984126984 (* x x) 0.008333333333333333)
(* x x)
-0.16666666666666666)
(* x x)
1.0)
t_1)
y)
(if (<= t_0 2e-50) (* (/ (sin x) x) y) (/ (* (* t_1 x) y) x)))))
double code(double x, double y) {
double t_0 = (sin(x) * sinh(y)) / x;
double t_1 = fma(fma((y * y), 0.008333333333333333, 0.16666666666666666), (y * y), 1.0);
double tmp;
if (t_0 <= -2e-7) {
tmp = (fma(fma(fma(-0.0001984126984126984, (x * x), 0.008333333333333333), (x * x), -0.16666666666666666), (x * x), 1.0) * t_1) * y;
} else if (t_0 <= 2e-50) {
tmp = (sin(x) / x) * y;
} else {
tmp = ((t_1 * x) * y) / x;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(sin(x) * sinh(y)) / x) t_1 = fma(fma(Float64(y * y), 0.008333333333333333, 0.16666666666666666), Float64(y * y), 1.0) tmp = 0.0 if (t_0 <= -2e-7) tmp = Float64(Float64(fma(fma(fma(-0.0001984126984126984, Float64(x * x), 0.008333333333333333), Float64(x * x), -0.16666666666666666), Float64(x * x), 1.0) * t_1) * y); elseif (t_0 <= 2e-50) tmp = Float64(Float64(sin(x) / x) * y); else tmp = Float64(Float64(Float64(t_1 * x) * y) / x); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[Sin[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(y * y), $MachinePrecision] * 0.008333333333333333 + 0.16666666666666666), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[t$95$0, -2e-7], N[(N[(N[(N[(N[(-0.0001984126984126984 * N[(x * x), $MachinePrecision] + 0.008333333333333333), $MachinePrecision] * N[(x * x), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$0, 2e-50], N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision], N[(N[(N[(t$95$1 * x), $MachinePrecision] * y), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin x \cdot \sinh y}{x}\\
t_1 := \mathsf{fma}\left(\mathsf{fma}\left(y \cdot y, 0.008333333333333333, 0.16666666666666666\right), y \cdot y, 1\right)\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-7}:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.0001984126984126984, x \cdot x, 0.008333333333333333\right), x \cdot x, -0.16666666666666666\right), x \cdot x, 1\right) \cdot t\_1\right) \cdot y\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-50}:\\
\;\;\;\;\frac{\sin x}{x} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(t\_1 \cdot x\right) \cdot y}{x}\\
\end{array}
\end{array}
if (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < -1.9999999999999999e-7Initial program 100.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites74.8%
Taylor expanded in x around 0
Applied rewrites63.5%
if -1.9999999999999999e-7 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < 2.00000000000000002e-50Initial program 84.1%
Taylor expanded in y around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f6498.6
Applied rewrites98.6%
if 2.00000000000000002e-50 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) Initial program 100.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites82.1%
Taylor expanded in x around 0
Applied rewrites71.2%
(FPCore (x y)
:precision binary64
(if (<= y 0.225)
(*
(*
(/
(fma (fma (* y y) 0.008333333333333333 0.16666666666666666) (* y y) 1.0)
x)
y)
(sin x))
(if (<= y 5e+59)
(* (- (exp y) (exp (- y))) 0.5)
(/
(*
(fma (fma 0.008333333333333333 (* y y) 0.16666666666666666) (* y y) 1.0)
(* (sin x) y))
x))))
double code(double x, double y) {
double tmp;
if (y <= 0.225) {
tmp = ((fma(fma((y * y), 0.008333333333333333, 0.16666666666666666), (y * y), 1.0) / x) * y) * sin(x);
} else if (y <= 5e+59) {
tmp = (exp(y) - exp(-y)) * 0.5;
} else {
tmp = (fma(fma(0.008333333333333333, (y * y), 0.16666666666666666), (y * y), 1.0) * (sin(x) * y)) / x;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (y <= 0.225) tmp = Float64(Float64(Float64(fma(fma(Float64(y * y), 0.008333333333333333, 0.16666666666666666), Float64(y * y), 1.0) / x) * y) * sin(x)); elseif (y <= 5e+59) tmp = Float64(Float64(exp(y) - exp(Float64(-y))) * 0.5); else tmp = Float64(Float64(fma(fma(0.008333333333333333, Float64(y * y), 0.16666666666666666), Float64(y * y), 1.0) * Float64(sin(x) * y)) / x); end return tmp end
code[x_, y_] := If[LessEqual[y, 0.225], N[(N[(N[(N[(N[(N[(y * y), $MachinePrecision] * 0.008333333333333333 + 0.16666666666666666), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5e+59], N[(N[(N[Exp[y], $MachinePrecision] - N[Exp[(-y)], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(0.008333333333333333 * N[(y * y), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.225:\\
\;\;\;\;\left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(y \cdot y, 0.008333333333333333, 0.16666666666666666\right), y \cdot y, 1\right)}{x} \cdot y\right) \cdot \sin x\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+59}:\\
\;\;\;\;\left(e^{y} - e^{-y}\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333, y \cdot y, 0.16666666666666666\right), y \cdot y, 1\right) \cdot \left(\sin x \cdot y\right)}{x}\\
\end{array}
\end{array}
if y < 0.225000000000000006Initial program 88.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Taylor expanded in y around 0
Applied rewrites95.4%
if 0.225000000000000006 < y < 4.9999999999999997e59Initial program 99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6476.7
Applied rewrites76.7%
if 4.9999999999999997e59 < y Initial program 100.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.3%
Applied rewrites98.3%
(FPCore (x y)
:precision binary64
(*
(*
(/
(fma (fma (* y y) 0.008333333333333333 0.16666666666666666) (* y y) 1.0)
x)
y)
(sin x)))
double code(double x, double y) {
return ((fma(fma((y * y), 0.008333333333333333, 0.16666666666666666), (y * y), 1.0) / x) * y) * sin(x);
}
function code(x, y) return Float64(Float64(Float64(fma(fma(Float64(y * y), 0.008333333333333333, 0.16666666666666666), Float64(y * y), 1.0) / x) * y) * sin(x)) end
code[x_, y_] := N[(N[(N[(N[(N[(N[(y * y), $MachinePrecision] * 0.008333333333333333 + 0.16666666666666666), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(y \cdot y, 0.008333333333333333, 0.16666666666666666\right), y \cdot y, 1\right)}{x} \cdot y\right) \cdot \sin x
\end{array}
Initial program 92.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
Applied rewrites90.9%
(FPCore (x y) :precision binary64 (* (* (/ (sin x) x) (fma (fma (* y y) 0.008333333333333333 0.16666666666666666) (* y y) 1.0)) y))
double code(double x, double y) {
return ((sin(x) / x) * fma(fma((y * y), 0.008333333333333333, 0.16666666666666666), (y * y), 1.0)) * y;
}
function code(x, y) return Float64(Float64(Float64(sin(x) / x) * fma(fma(Float64(y * y), 0.008333333333333333, 0.16666666666666666), Float64(y * y), 1.0)) * y) end
code[x_, y_] := N[(N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * N[(N[(N[(y * y), $MachinePrecision] * 0.008333333333333333 + 0.16666666666666666), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{\sin x}{x} \cdot \mathsf{fma}\left(\mathsf{fma}\left(y \cdot y, 0.008333333333333333, 0.16666666666666666\right), y \cdot y, 1\right)\right) \cdot y
\end{array}
Initial program 92.2%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites88.4%
(FPCore (x y) :precision binary64 (* (* (/ (sin x) x) (fma (* (* y y) 0.008333333333333333) (* y y) 1.0)) y))
double code(double x, double y) {
return ((sin(x) / x) * fma(((y * y) * 0.008333333333333333), (y * y), 1.0)) * y;
}
function code(x, y) return Float64(Float64(Float64(sin(x) / x) * fma(Float64(Float64(y * y) * 0.008333333333333333), Float64(y * y), 1.0)) * y) end
code[x_, y_] := N[(N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * N[(N[(N[(y * y), $MachinePrecision] * 0.008333333333333333), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{\sin x}{x} \cdot \mathsf{fma}\left(\left(y \cdot y\right) \cdot 0.008333333333333333, y \cdot y, 1\right)\right) \cdot y
\end{array}
Initial program 92.2%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites88.4%
Taylor expanded in y around inf
Applied rewrites87.9%
(FPCore (x y) :precision binary64 (if (<= x 2.4e-11) (fma (pow y 3.0) (fma (* y y) 0.008333333333333333 0.16666666666666666) y) (/ (* (* (fma (* y y) 0.16666666666666666 1.0) (sin x)) y) x)))
double code(double x, double y) {
double tmp;
if (x <= 2.4e-11) {
tmp = fma(pow(y, 3.0), fma((y * y), 0.008333333333333333, 0.16666666666666666), y);
} else {
tmp = ((fma((y * y), 0.16666666666666666, 1.0) * sin(x)) * y) / x;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= 2.4e-11) tmp = fma((y ^ 3.0), fma(Float64(y * y), 0.008333333333333333, 0.16666666666666666), y); else tmp = Float64(Float64(Float64(fma(Float64(y * y), 0.16666666666666666, 1.0) * sin(x)) * y) / x); end return tmp end
code[x_, y_] := If[LessEqual[x, 2.4e-11], N[(N[Power[y, 3.0], $MachinePrecision] * N[(N[(y * y), $MachinePrecision] * 0.008333333333333333 + 0.16666666666666666), $MachinePrecision] + y), $MachinePrecision], N[(N[(N[(N[(N[(y * y), $MachinePrecision] * 0.16666666666666666 + 1.0), $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.4 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{fma}\left({y}^{3}, \mathsf{fma}\left(y \cdot y, 0.008333333333333333, 0.16666666666666666\right), y\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\mathsf{fma}\left(y \cdot y, 0.16666666666666666, 1\right) \cdot \sin x\right) \cdot y}{x}\\
\end{array}
\end{array}
if x < 2.4000000000000001e-11Initial program 89.5%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites88.8%
Taylor expanded in x around 0
Applied rewrites61.7%
if 2.4000000000000001e-11 < x Initial program 99.9%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f6458.8
Applied rewrites58.8%
Taylor expanded in y around 0
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites82.7%
(FPCore (x y)
:precision binary64
(if (<= x 1.75e+63)
(*
(fma (fma (* y y) 0.008333333333333333 0.16666666666666666) (* y y) 1.0)
y)
(if (<= x 7.4e+119)
(* (* (* (fma -0.027777777777777776 (* x x) 0.16666666666666666) y) y) y)
(/ (* (* (/ y x) x) x) x))))
double code(double x, double y) {
double tmp;
if (x <= 1.75e+63) {
tmp = fma(fma((y * y), 0.008333333333333333, 0.16666666666666666), (y * y), 1.0) * y;
} else if (x <= 7.4e+119) {
tmp = ((fma(-0.027777777777777776, (x * x), 0.16666666666666666) * y) * y) * y;
} else {
tmp = (((y / x) * x) * x) / x;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= 1.75e+63) tmp = Float64(fma(fma(Float64(y * y), 0.008333333333333333, 0.16666666666666666), Float64(y * y), 1.0) * y); elseif (x <= 7.4e+119) tmp = Float64(Float64(Float64(fma(-0.027777777777777776, Float64(x * x), 0.16666666666666666) * y) * y) * y); else tmp = Float64(Float64(Float64(Float64(y / x) * x) * x) / x); end return tmp end
code[x_, y_] := If[LessEqual[x, 1.75e+63], N[(N[(N[(N[(y * y), $MachinePrecision] * 0.008333333333333333 + 0.16666666666666666), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[x, 7.4e+119], N[(N[(N[(N[(-0.027777777777777776 * N[(x * x), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * y), $MachinePrecision] * y), $MachinePrecision] * y), $MachinePrecision], N[(N[(N[(N[(y / x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.75 \cdot 10^{+63}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(y \cdot y, 0.008333333333333333, 0.16666666666666666\right), y \cdot y, 1\right) \cdot y\\
\mathbf{elif}\;x \leq 7.4 \cdot 10^{+119}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(-0.027777777777777776, x \cdot x, 0.16666666666666666\right) \cdot y\right) \cdot y\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{y}{x} \cdot x\right) \cdot x}{x}\\
\end{array}
\end{array}
if x < 1.75000000000000015e63Initial program 90.2%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.5%
Taylor expanded in x around 0
Applied rewrites60.9%
if 1.75000000000000015e63 < x < 7.3999999999999999e119Initial program 99.9%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites85.0%
Taylor expanded in x around 0
Applied rewrites2.2%
Taylor expanded in y around 0
Applied rewrites17.6%
Taylor expanded in y around inf
Applied rewrites48.6%
if 7.3999999999999999e119 < x Initial program 100.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f6458.3
Applied rewrites58.3%
Taylor expanded in x around 0
Applied rewrites13.8%
Taylor expanded in x around inf
Applied rewrites13.9%
Taylor expanded in x around 0
Applied rewrites60.1%
(FPCore (x y)
:precision binary64
(if (<= x 1.75e+63)
(*
(fma (fma (* y y) 0.008333333333333333 0.16666666666666666) (* y y) 1.0)
y)
(if (<= x 7.4e+119)
(* (* (* (fma -0.027777777777777776 (* x x) 0.16666666666666666) y) y) y)
(*
(fma (fma 0.008333333333333333 (* x x) -0.16666666666666666) (* x x) 1.0)
y))))
double code(double x, double y) {
double tmp;
if (x <= 1.75e+63) {
tmp = fma(fma((y * y), 0.008333333333333333, 0.16666666666666666), (y * y), 1.0) * y;
} else if (x <= 7.4e+119) {
tmp = ((fma(-0.027777777777777776, (x * x), 0.16666666666666666) * y) * y) * y;
} else {
tmp = fma(fma(0.008333333333333333, (x * x), -0.16666666666666666), (x * x), 1.0) * y;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= 1.75e+63) tmp = Float64(fma(fma(Float64(y * y), 0.008333333333333333, 0.16666666666666666), Float64(y * y), 1.0) * y); elseif (x <= 7.4e+119) tmp = Float64(Float64(Float64(fma(-0.027777777777777776, Float64(x * x), 0.16666666666666666) * y) * y) * y); else tmp = Float64(fma(fma(0.008333333333333333, Float64(x * x), -0.16666666666666666), Float64(x * x), 1.0) * y); end return tmp end
code[x_, y_] := If[LessEqual[x, 1.75e+63], N[(N[(N[(N[(y * y), $MachinePrecision] * 0.008333333333333333 + 0.16666666666666666), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[x, 7.4e+119], N[(N[(N[(N[(-0.027777777777777776 * N[(x * x), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * y), $MachinePrecision] * y), $MachinePrecision] * y), $MachinePrecision], N[(N[(N[(0.008333333333333333 * N[(x * x), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.75 \cdot 10^{+63}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(y \cdot y, 0.008333333333333333, 0.16666666666666666\right), y \cdot y, 1\right) \cdot y\\
\mathbf{elif}\;x \leq 7.4 \cdot 10^{+119}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(-0.027777777777777776, x \cdot x, 0.16666666666666666\right) \cdot y\right) \cdot y\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333, x \cdot x, -0.16666666666666666\right), x \cdot x, 1\right) \cdot y\\
\end{array}
\end{array}
if x < 1.75000000000000015e63Initial program 90.2%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.5%
Taylor expanded in x around 0
Applied rewrites60.9%
if 1.75000000000000015e63 < x < 7.3999999999999999e119Initial program 99.9%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites85.0%
Taylor expanded in x around 0
Applied rewrites2.2%
Taylor expanded in y around 0
Applied rewrites17.6%
Taylor expanded in y around inf
Applied rewrites48.6%
if 7.3999999999999999e119 < x Initial program 100.0%
Taylor expanded in y around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f6458.3
Applied rewrites58.3%
Taylor expanded in x around 0
Applied rewrites29.1%
(FPCore (x y)
:precision binary64
(if (<= x 1.75e+63)
(*
(fma (fma (* y y) 0.008333333333333333 0.16666666666666666) (* y y) 1.0)
y)
(if (<= x 7.4e+119)
(* (* (* (fma -0.027777777777777776 (* x x) 0.16666666666666666) y) y) y)
(* (fma -0.16666666666666666 (* (- x) x) 1.0) y))))
double code(double x, double y) {
double tmp;
if (x <= 1.75e+63) {
tmp = fma(fma((y * y), 0.008333333333333333, 0.16666666666666666), (y * y), 1.0) * y;
} else if (x <= 7.4e+119) {
tmp = ((fma(-0.027777777777777776, (x * x), 0.16666666666666666) * y) * y) * y;
} else {
tmp = fma(-0.16666666666666666, (-x * x), 1.0) * y;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= 1.75e+63) tmp = Float64(fma(fma(Float64(y * y), 0.008333333333333333, 0.16666666666666666), Float64(y * y), 1.0) * y); elseif (x <= 7.4e+119) tmp = Float64(Float64(Float64(fma(-0.027777777777777776, Float64(x * x), 0.16666666666666666) * y) * y) * y); else tmp = Float64(fma(-0.16666666666666666, Float64(Float64(-x) * x), 1.0) * y); end return tmp end
code[x_, y_] := If[LessEqual[x, 1.75e+63], N[(N[(N[(N[(y * y), $MachinePrecision] * 0.008333333333333333 + 0.16666666666666666), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[x, 7.4e+119], N[(N[(N[(N[(-0.027777777777777776 * N[(x * x), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * y), $MachinePrecision] * y), $MachinePrecision] * y), $MachinePrecision], N[(N[(-0.16666666666666666 * N[((-x) * x), $MachinePrecision] + 1.0), $MachinePrecision] * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.75 \cdot 10^{+63}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(y \cdot y, 0.008333333333333333, 0.16666666666666666\right), y \cdot y, 1\right) \cdot y\\
\mathbf{elif}\;x \leq 7.4 \cdot 10^{+119}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(-0.027777777777777776, x \cdot x, 0.16666666666666666\right) \cdot y\right) \cdot y\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.16666666666666666, \left(-x\right) \cdot x, 1\right) \cdot y\\
\end{array}
\end{array}
if x < 1.75000000000000015e63Initial program 90.2%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.5%
Taylor expanded in x around 0
Applied rewrites60.9%
if 1.75000000000000015e63 < x < 7.3999999999999999e119Initial program 99.9%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites85.0%
Taylor expanded in x around 0
Applied rewrites2.2%
Taylor expanded in y around 0
Applied rewrites17.6%
Taylor expanded in y around inf
Applied rewrites48.6%
if 7.3999999999999999e119 < x Initial program 100.0%
Taylor expanded in y around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f6458.3
Applied rewrites58.3%
Taylor expanded in x around 0
Applied rewrites13.8%
Applied rewrites29.2%
(FPCore (x y)
:precision binary64
(if (<= x 54.0)
(* (fma (* y y) 0.16666666666666666 1.0) y)
(if (<= x 7.4e+119)
(* (* (* (fma -0.027777777777777776 (* x x) 0.16666666666666666) y) y) y)
(* (fma -0.16666666666666666 (* (- x) x) 1.0) y))))
double code(double x, double y) {
double tmp;
if (x <= 54.0) {
tmp = fma((y * y), 0.16666666666666666, 1.0) * y;
} else if (x <= 7.4e+119) {
tmp = ((fma(-0.027777777777777776, (x * x), 0.16666666666666666) * y) * y) * y;
} else {
tmp = fma(-0.16666666666666666, (-x * x), 1.0) * y;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= 54.0) tmp = Float64(fma(Float64(y * y), 0.16666666666666666, 1.0) * y); elseif (x <= 7.4e+119) tmp = Float64(Float64(Float64(fma(-0.027777777777777776, Float64(x * x), 0.16666666666666666) * y) * y) * y); else tmp = Float64(fma(-0.16666666666666666, Float64(Float64(-x) * x), 1.0) * y); end return tmp end
code[x_, y_] := If[LessEqual[x, 54.0], N[(N[(N[(y * y), $MachinePrecision] * 0.16666666666666666 + 1.0), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[x, 7.4e+119], N[(N[(N[(N[(-0.027777777777777776 * N[(x * x), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * y), $MachinePrecision] * y), $MachinePrecision] * y), $MachinePrecision], N[(N[(-0.16666666666666666 * N[((-x) * x), $MachinePrecision] + 1.0), $MachinePrecision] * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 54:\\
\;\;\;\;\mathsf{fma}\left(y \cdot y, 0.16666666666666666, 1\right) \cdot y\\
\mathbf{elif}\;x \leq 7.4 \cdot 10^{+119}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(-0.027777777777777776, x \cdot x, 0.16666666666666666\right) \cdot y\right) \cdot y\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.16666666666666666, \left(-x\right) \cdot x, 1\right) \cdot y\\
\end{array}
\end{array}
if x < 54Initial program 89.7%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites88.9%
Taylor expanded in x around 0
Applied rewrites33.2%
Taylor expanded in y around 0
Applied rewrites59.0%
Taylor expanded in x around 0
Applied rewrites56.3%
if 54 < x < 7.3999999999999999e119Initial program 99.7%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites91.3%
Taylor expanded in x around 0
Applied rewrites6.7%
Taylor expanded in y around 0
Applied rewrites11.4%
Taylor expanded in y around inf
Applied rewrites33.2%
if 7.3999999999999999e119 < x Initial program 100.0%
Taylor expanded in y around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f6458.3
Applied rewrites58.3%
Taylor expanded in x around 0
Applied rewrites13.8%
Applied rewrites29.2%
(FPCore (x y)
:precision binary64
(if (<= x 4.9e+82)
(* (fma (* y y) 0.16666666666666666 1.0) y)
(if (<= x 7.4e+119)
(* (* (* x x) -0.16666666666666666) y)
(* (fma -0.16666666666666666 (* (- x) x) 1.0) y))))
double code(double x, double y) {
double tmp;
if (x <= 4.9e+82) {
tmp = fma((y * y), 0.16666666666666666, 1.0) * y;
} else if (x <= 7.4e+119) {
tmp = ((x * x) * -0.16666666666666666) * y;
} else {
tmp = fma(-0.16666666666666666, (-x * x), 1.0) * y;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= 4.9e+82) tmp = Float64(fma(Float64(y * y), 0.16666666666666666, 1.0) * y); elseif (x <= 7.4e+119) tmp = Float64(Float64(Float64(x * x) * -0.16666666666666666) * y); else tmp = Float64(fma(-0.16666666666666666, Float64(Float64(-x) * x), 1.0) * y); end return tmp end
code[x_, y_] := If[LessEqual[x, 4.9e+82], N[(N[(N[(y * y), $MachinePrecision] * 0.16666666666666666 + 1.0), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[x, 7.4e+119], N[(N[(N[(x * x), $MachinePrecision] * -0.16666666666666666), $MachinePrecision] * y), $MachinePrecision], N[(N[(-0.16666666666666666 * N[((-x) * x), $MachinePrecision] + 1.0), $MachinePrecision] * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.9 \cdot 10^{+82}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot y, 0.16666666666666666, 1\right) \cdot y\\
\mathbf{elif}\;x \leq 7.4 \cdot 10^{+119}:\\
\;\;\;\;\left(\left(x \cdot x\right) \cdot -0.16666666666666666\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.16666666666666666, \left(-x\right) \cdot x, 1\right) \cdot y\\
\end{array}
\end{array}
if x < 4.9000000000000001e82Initial program 90.4%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.2%
Taylor expanded in x around 0
Applied rewrites31.5%
Taylor expanded in y around 0
Applied rewrites55.0%
Taylor expanded in x around 0
Applied rewrites54.5%
if 4.9000000000000001e82 < x < 7.3999999999999999e119Initial program 100.0%
Taylor expanded in y around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f6463.4
Applied rewrites63.4%
Taylor expanded in x around 0
Applied rewrites27.2%
Taylor expanded in x around inf
Applied rewrites27.2%
if 7.3999999999999999e119 < x Initial program 100.0%
Taylor expanded in y around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f6458.3
Applied rewrites58.3%
Taylor expanded in x around 0
Applied rewrites13.8%
Applied rewrites29.2%
(FPCore (x y) :precision binary64 (if (<= x 3.6e+192) (* (fma (* y y) 0.16666666666666666 1.0) y) (fma (* (* y x) x) -0.16666666666666666 y)))
double code(double x, double y) {
double tmp;
if (x <= 3.6e+192) {
tmp = fma((y * y), 0.16666666666666666, 1.0) * y;
} else {
tmp = fma(((y * x) * x), -0.16666666666666666, y);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= 3.6e+192) tmp = Float64(fma(Float64(y * y), 0.16666666666666666, 1.0) * y); else tmp = fma(Float64(Float64(y * x) * x), -0.16666666666666666, y); end return tmp end
code[x_, y_] := If[LessEqual[x, 3.6e+192], N[(N[(N[(y * y), $MachinePrecision] * 0.16666666666666666 + 1.0), $MachinePrecision] * y), $MachinePrecision], N[(N[(N[(y * x), $MachinePrecision] * x), $MachinePrecision] * -0.16666666666666666 + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.6 \cdot 10^{+192}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot y, 0.16666666666666666, 1\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(y \cdot x\right) \cdot x, -0.16666666666666666, y\right)\\
\end{array}
\end{array}
if x < 3.6000000000000002e192Initial program 91.3%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites88.6%
Taylor expanded in x around 0
Applied rewrites28.6%
Taylor expanded in y around 0
Applied rewrites50.8%
Taylor expanded in x around 0
Applied rewrites50.6%
if 3.6000000000000002e192 < x Initial program 99.9%
Taylor expanded in y around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f6454.4
Applied rewrites54.4%
Taylor expanded in x around 0
Applied rewrites20.9%
Taylor expanded in x around 0
Applied rewrites21.0%
(FPCore (x y) :precision binary64 (if (<= x 2.45e+42) (* 1.0 y) (* (* (* x x) -0.16666666666666666) y)))
double code(double x, double y) {
double tmp;
if (x <= 2.45e+42) {
tmp = 1.0 * y;
} else {
tmp = ((x * x) * -0.16666666666666666) * 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 (x <= 2.45d+42) then
tmp = 1.0d0 * y
else
tmp = ((x * x) * (-0.16666666666666666d0)) * y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 2.45e+42) {
tmp = 1.0 * y;
} else {
tmp = ((x * x) * -0.16666666666666666) * y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 2.45e+42: tmp = 1.0 * y else: tmp = ((x * x) * -0.16666666666666666) * y return tmp
function code(x, y) tmp = 0.0 if (x <= 2.45e+42) tmp = Float64(1.0 * y); else tmp = Float64(Float64(Float64(x * x) * -0.16666666666666666) * y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 2.45e+42) tmp = 1.0 * y; else tmp = ((x * x) * -0.16666666666666666) * y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 2.45e+42], N[(1.0 * y), $MachinePrecision], N[(N[(N[(x * x), $MachinePrecision] * -0.16666666666666666), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.45 \cdot 10^{+42}:\\
\;\;\;\;1 \cdot y\\
\mathbf{else}:\\
\;\;\;\;\left(\left(x \cdot x\right) \cdot -0.16666666666666666\right) \cdot y\\
\end{array}
\end{array}
if x < 2.4500000000000001e42Initial program 90.0%
Taylor expanded in y around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f6450.9
Applied rewrites50.9%
Taylor expanded in x around 0
Applied rewrites31.0%
if 2.4500000000000001e42 < x Initial program 99.9%
Taylor expanded in y around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f6459.6
Applied rewrites59.6%
Taylor expanded in x around 0
Applied rewrites13.7%
Taylor expanded in x around inf
Applied rewrites13.7%
(FPCore (x y) :precision binary64 (fma (* (* y x) x) -0.16666666666666666 y))
double code(double x, double y) {
return fma(((y * x) * x), -0.16666666666666666, y);
}
function code(x, y) return fma(Float64(Float64(y * x) * x), -0.16666666666666666, y) end
code[x_, y_] := N[(N[(N[(y * x), $MachinePrecision] * x), $MachinePrecision] * -0.16666666666666666 + y), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(y \cdot x\right) \cdot x, -0.16666666666666666, y\right)
\end{array}
Initial program 92.2%
Taylor expanded in y around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f6452.8
Applied rewrites52.8%
Taylor expanded in x around 0
Applied rewrites32.1%
Taylor expanded in x around 0
Applied rewrites32.2%
(FPCore (x y) :precision binary64 (* 1.0 y))
double code(double x, double y) {
return 1.0 * 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 = 1.0d0 * y
end function
public static double code(double x, double y) {
return 1.0 * y;
}
def code(x, y): return 1.0 * y
function code(x, y) return Float64(1.0 * y) end
function tmp = code(x, y) tmp = 1.0 * y; end
code[x_, y_] := N[(1.0 * y), $MachinePrecision]
\begin{array}{l}
\\
1 \cdot y
\end{array}
Initial program 92.2%
Taylor expanded in y around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f6452.8
Applied rewrites52.8%
Taylor expanded in x around 0
Applied rewrites25.2%
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) x)))
double code(double x, double y) {
return sin(x) * (sinh(y) / x);
}
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 = sin(x) * (sinh(y) / x)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / x);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / x)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / x)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / x); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{x}
\end{array}
herbie shell --seed 2025017
(FPCore (x y)
:name "Linear.Quaternion:$ccosh from linear-1.19.1.3"
:precision binary64
:alt
(! :herbie-platform default (* (sin x) (/ (sinh y) x)))
(/ (* (sin x) (sinh y)) x))