
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(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 = sin(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / y)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\sin x \cdot \frac{\sinh y}{y}
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(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 = sin(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / y)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\sin x \cdot \frac{\sinh y}{y}
(FPCore (x y) :precision binary64 (if (<= (fabs y) 6.2e-5) (* (sin x) 1.0) (/ (* (sinh (fabs y)) (sin x)) (fabs y))))
double code(double x, double y) {
double tmp;
if (fabs(y) <= 6.2e-5) {
tmp = sin(x) * 1.0;
} else {
tmp = (sinh(fabs(y)) * sin(x)) / fabs(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 (abs(y) <= 6.2d-5) then
tmp = sin(x) * 1.0d0
else
tmp = (sinh(abs(y)) * sin(x)) / abs(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.abs(y) <= 6.2e-5) {
tmp = Math.sin(x) * 1.0;
} else {
tmp = (Math.sinh(Math.abs(y)) * Math.sin(x)) / Math.abs(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.fabs(y) <= 6.2e-5: tmp = math.sin(x) * 1.0 else: tmp = (math.sinh(math.fabs(y)) * math.sin(x)) / math.fabs(y) return tmp
function code(x, y) tmp = 0.0 if (abs(y) <= 6.2e-5) tmp = Float64(sin(x) * 1.0); else tmp = Float64(Float64(sinh(abs(y)) * sin(x)) / abs(y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (abs(y) <= 6.2e-5) tmp = sin(x) * 1.0; else tmp = (sinh(abs(y)) * sin(x)) / abs(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Abs[y], $MachinePrecision], 6.2e-5], N[(N[Sin[x], $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(N[Sinh[N[Abs[y], $MachinePrecision]], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|y\right| \leq 6.2 \cdot 10^{-5}:\\
\;\;\;\;\sin x \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\frac{\sinh \left(\left|y\right|\right) \cdot \sin x}{\left|y\right|}\\
\end{array}
if y < 6.2000000000000003e-5Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites51.0%
if 6.2000000000000003e-5 < y Initial program 100.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6488.9%
Applied rewrites88.9%
(FPCore (x y)
:precision binary64
(*
(copysign 1.0 x)
(if (<= (fabs x) 5e-36)
(* (fabs x) (/ (sinh y) y))
(* (/ (sin (fabs x)) y) (sinh y)))))double code(double x, double y) {
double tmp;
if (fabs(x) <= 5e-36) {
tmp = fabs(x) * (sinh(y) / y);
} else {
tmp = (sin(fabs(x)) / y) * sinh(y);
}
return copysign(1.0, x) * tmp;
}
public static double code(double x, double y) {
double tmp;
if (Math.abs(x) <= 5e-36) {
tmp = Math.abs(x) * (Math.sinh(y) / y);
} else {
tmp = (Math.sin(Math.abs(x)) / y) * Math.sinh(y);
}
return Math.copySign(1.0, x) * tmp;
}
def code(x, y): tmp = 0 if math.fabs(x) <= 5e-36: tmp = math.fabs(x) * (math.sinh(y) / y) else: tmp = (math.sin(math.fabs(x)) / y) * math.sinh(y) return math.copysign(1.0, x) * tmp
function code(x, y) tmp = 0.0 if (abs(x) <= 5e-36) tmp = Float64(abs(x) * Float64(sinh(y) / y)); else tmp = Float64(Float64(sin(abs(x)) / y) * sinh(y)); end return Float64(copysign(1.0, x) * tmp) end
function tmp_2 = code(x, y) tmp = 0.0; if (abs(x) <= 5e-36) tmp = abs(x) * (sinh(y) / y); else tmp = (sin(abs(x)) / y) * sinh(y); end tmp_2 = (sign(x) * abs(1.0)) * tmp; end
code[x_, y_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[x], $MachinePrecision], 5e-36], N[(N[Abs[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[N[Abs[x], $MachinePrecision]], $MachinePrecision] / y), $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 5 \cdot 10^{-36}:\\
\;\;\;\;\left|x\right| \cdot \frac{\sinh y}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin \left(\left|x\right|\right)}{y} \cdot \sinh y\\
\end{array}
if x < 5e-36Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites63.1%
if 5e-36 < x Initial program 100.0%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flipN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
mult-flip-revN/A
lower-/.f6488.6%
Applied rewrites88.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (sin (fabs x))) (t_1 (/ (sinh y) y)) (t_2 (* t_0 t_1)))
(*
(copysign 1.0 x)
(if (<= t_2 (- INFINITY))
(* (* (fabs x) (fma (* -0.16666666666666666 (fabs x)) (fabs x) 1.0)) t_1)
(if (<= t_2 1.0) (* t_0 1.0) (* (fabs x) t_1))))))double code(double x, double y) {
double t_0 = sin(fabs(x));
double t_1 = sinh(y) / y;
double t_2 = t_0 * t_1;
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = (fabs(x) * fma((-0.16666666666666666 * fabs(x)), fabs(x), 1.0)) * t_1;
} else if (t_2 <= 1.0) {
tmp = t_0 * 1.0;
} else {
tmp = fabs(x) * t_1;
}
return copysign(1.0, x) * tmp;
}
function code(x, y) t_0 = sin(abs(x)) t_1 = Float64(sinh(y) / y) t_2 = Float64(t_0 * t_1) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(Float64(abs(x) * fma(Float64(-0.16666666666666666 * abs(x)), abs(x), 1.0)) * t_1); elseif (t_2 <= 1.0) tmp = Float64(t_0 * 1.0); else tmp = Float64(abs(x) * t_1); end return Float64(copysign(1.0, x) * tmp) end
code[x_, y_] := Block[{t$95$0 = N[Sin[N[Abs[x], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * t$95$1), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$2, (-Infinity)], N[(N[(N[Abs[x], $MachinePrecision] * N[(N[(-0.16666666666666666 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[t$95$2, 1.0], N[(t$95$0 * 1.0), $MachinePrecision], N[(N[Abs[x], $MachinePrecision] * t$95$1), $MachinePrecision]]]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \sin \left(\left|x\right|\right)\\
t_1 := \frac{\sinh y}{y}\\
t_2 := t\_0 \cdot t\_1\\
\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;\left(\left|x\right| \cdot \mathsf{fma}\left(-0.16666666666666666 \cdot \left|x\right|, \left|x\right|, 1\right)\right) \cdot t\_1\\
\mathbf{elif}\;t\_2 \leq 1:\\
\;\;\;\;t\_0 \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\left|x\right| \cdot t\_1\\
\end{array}
\end{array}
if (*.f64 (sin.f64 x) (/.f64 (sinh.f64 y) y)) < -inf.0Initial program 100.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6462.7%
Applied rewrites62.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6462.7%
Applied rewrites62.7%
if -inf.0 < (*.f64 (sin.f64 x) (/.f64 (sinh.f64 y) y)) < 1Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites51.0%
if 1 < (*.f64 (sin.f64 x) (/.f64 (sinh.f64 y) y)) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites63.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (sinh y) y)))
(*
(copysign 1.0 x)
(if (<= (* (sin (fabs x)) t_0) 5e-7)
(* (* (fabs x) (fma (* -0.16666666666666666 (fabs x)) (fabs x) 1.0)) t_0)
(/ (* (fabs x) (sinh y)) y)))))double code(double x, double y) {
double t_0 = sinh(y) / y;
double tmp;
if ((sin(fabs(x)) * t_0) <= 5e-7) {
tmp = (fabs(x) * fma((-0.16666666666666666 * fabs(x)), fabs(x), 1.0)) * t_0;
} else {
tmp = (fabs(x) * sinh(y)) / y;
}
return copysign(1.0, x) * tmp;
}
function code(x, y) t_0 = Float64(sinh(y) / y) tmp = 0.0 if (Float64(sin(abs(x)) * t_0) <= 5e-7) tmp = Float64(Float64(abs(x) * fma(Float64(-0.16666666666666666 * abs(x)), abs(x), 1.0)) * t_0); else tmp = Float64(Float64(abs(x) * sinh(y)) / y); end return Float64(copysign(1.0, x) * tmp) end
code[x_, y_] := Block[{t$95$0 = N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[Sin[N[Abs[x], $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], 5e-7], N[(N[(N[Abs[x], $MachinePrecision] * N[(N[(-0.16666666666666666 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(N[Abs[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
t_0 := \frac{\sinh y}{y}\\
\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
\mathbf{if}\;\sin \left(\left|x\right|\right) \cdot t\_0 \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\left(\left|x\right| \cdot \mathsf{fma}\left(-0.16666666666666666 \cdot \left|x\right|, \left|x\right|, 1\right)\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|x\right| \cdot \sinh y}{y}\\
\end{array}
\end{array}
if (*.f64 (sin.f64 x) (/.f64 (sinh.f64 y) y)) < 4.9999999999999998e-7Initial program 100.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6462.7%
Applied rewrites62.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6462.7%
Applied rewrites62.7%
if 4.9999999999999998e-7 < (*.f64 (sin.f64 x) (/.f64 (sinh.f64 y) y)) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites63.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6452.1%
Applied rewrites52.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (fabs x) (fabs x))))
(*
(copysign 1.0 x)
(if (<= (* (sin (fabs x)) (/ (sinh y) y)) 5e-7)
(* (* (fabs x) (+ 1.0 (* -0.16666666666666666 (sqrt (* t_0 t_0))))) 1.0)
(/ (* (fabs x) (sinh y)) y)))))double code(double x, double y) {
double t_0 = fabs(x) * fabs(x);
double tmp;
if ((sin(fabs(x)) * (sinh(y) / y)) <= 5e-7) {
tmp = (fabs(x) * (1.0 + (-0.16666666666666666 * sqrt((t_0 * t_0))))) * 1.0;
} else {
tmp = (fabs(x) * sinh(y)) / y;
}
return copysign(1.0, x) * tmp;
}
public static double code(double x, double y) {
double t_0 = Math.abs(x) * Math.abs(x);
double tmp;
if ((Math.sin(Math.abs(x)) * (Math.sinh(y) / y)) <= 5e-7) {
tmp = (Math.abs(x) * (1.0 + (-0.16666666666666666 * Math.sqrt((t_0 * t_0))))) * 1.0;
} else {
tmp = (Math.abs(x) * Math.sinh(y)) / y;
}
return Math.copySign(1.0, x) * tmp;
}
def code(x, y): t_0 = math.fabs(x) * math.fabs(x) tmp = 0 if (math.sin(math.fabs(x)) * (math.sinh(y) / y)) <= 5e-7: tmp = (math.fabs(x) * (1.0 + (-0.16666666666666666 * math.sqrt((t_0 * t_0))))) * 1.0 else: tmp = (math.fabs(x) * math.sinh(y)) / y return math.copysign(1.0, x) * tmp
function code(x, y) t_0 = Float64(abs(x) * abs(x)) tmp = 0.0 if (Float64(sin(abs(x)) * Float64(sinh(y) / y)) <= 5e-7) tmp = Float64(Float64(abs(x) * Float64(1.0 + Float64(-0.16666666666666666 * sqrt(Float64(t_0 * t_0))))) * 1.0); else tmp = Float64(Float64(abs(x) * sinh(y)) / y); end return Float64(copysign(1.0, x) * tmp) end
function tmp_2 = code(x, y) t_0 = abs(x) * abs(x); tmp = 0.0; if ((sin(abs(x)) * (sinh(y) / y)) <= 5e-7) tmp = (abs(x) * (1.0 + (-0.16666666666666666 * sqrt((t_0 * t_0))))) * 1.0; else tmp = (abs(x) * sinh(y)) / y; end tmp_2 = (sign(x) * abs(1.0)) * tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[Sin[N[Abs[x], $MachinePrecision]], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 5e-7], N[(N[(N[Abs[x], $MachinePrecision] * N[(1.0 + N[(-0.16666666666666666 * N[Sqrt[N[(t$95$0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(N[Abs[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
t_0 := \left|x\right| \cdot \left|x\right|\\
\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
\mathbf{if}\;\sin \left(\left|x\right|\right) \cdot \frac{\sinh y}{y} \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\left(\left|x\right| \cdot \left(1 + -0.16666666666666666 \cdot \sqrt{t\_0 \cdot t\_0}\right)\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|x\right| \cdot \sinh y}{y}\\
\end{array}
\end{array}
if (*.f64 (sin.f64 x) (/.f64 (sinh.f64 y) y)) < 4.9999999999999998e-7Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites51.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6434.2%
Applied rewrites34.2%
rem-square-sqrtN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f6435.1%
lift-pow.f64N/A
unpow2N/A
lower-*.f6435.1%
lift-pow.f64N/A
unpow2N/A
lower-*.f6435.1%
Applied rewrites35.1%
if 4.9999999999999998e-7 < (*.f64 (sin.f64 x) (/.f64 (sinh.f64 y) y)) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites63.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6452.1%
Applied rewrites52.1%
(FPCore (x y)
:precision binary64
(*
(copysign 1.0 x)
(if (<= (* (sin (fabs x)) (/ (sinh y) y)) 5e-7)
(* (* (fabs x) (fma (* -0.16666666666666666 (fabs x)) (fabs x) 1.0)) 1.0)
(/ (* (fabs x) (sinh y)) y))))double code(double x, double y) {
double tmp;
if ((sin(fabs(x)) * (sinh(y) / y)) <= 5e-7) {
tmp = (fabs(x) * fma((-0.16666666666666666 * fabs(x)), fabs(x), 1.0)) * 1.0;
} else {
tmp = (fabs(x) * sinh(y)) / y;
}
return copysign(1.0, x) * tmp;
}
function code(x, y) tmp = 0.0 if (Float64(sin(abs(x)) * Float64(sinh(y) / y)) <= 5e-7) tmp = Float64(Float64(abs(x) * fma(Float64(-0.16666666666666666 * abs(x)), abs(x), 1.0)) * 1.0); else tmp = Float64(Float64(abs(x) * sinh(y)) / y); end return Float64(copysign(1.0, x) * tmp) end
code[x_, y_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[Sin[N[Abs[x], $MachinePrecision]], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 5e-7], N[(N[(N[Abs[x], $MachinePrecision] * N[(N[(-0.16666666666666666 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(N[Abs[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
\mathbf{if}\;\sin \left(\left|x\right|\right) \cdot \frac{\sinh y}{y} \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\left(\left|x\right| \cdot \mathsf{fma}\left(-0.16666666666666666 \cdot \left|x\right|, \left|x\right|, 1\right)\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|x\right| \cdot \sinh y}{y}\\
\end{array}
if (*.f64 (sin.f64 x) (/.f64 (sinh.f64 y) y)) < 4.9999999999999998e-7Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites51.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6434.2%
Applied rewrites34.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6434.2%
Applied rewrites34.2%
if 4.9999999999999998e-7 < (*.f64 (sin.f64 x) (/.f64 (sinh.f64 y) y)) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites63.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6452.1%
Applied rewrites52.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (sinh y) y)))
(*
(copysign 1.0 x)
(if (<= (* (sin (fabs x)) t_0) 5e-7)
(* (* (fabs x) (fma (* -0.16666666666666666 (fabs x)) (fabs x) 1.0)) 1.0)
(* (fabs x) t_0)))))double code(double x, double y) {
double t_0 = sinh(y) / y;
double tmp;
if ((sin(fabs(x)) * t_0) <= 5e-7) {
tmp = (fabs(x) * fma((-0.16666666666666666 * fabs(x)), fabs(x), 1.0)) * 1.0;
} else {
tmp = fabs(x) * t_0;
}
return copysign(1.0, x) * tmp;
}
function code(x, y) t_0 = Float64(sinh(y) / y) tmp = 0.0 if (Float64(sin(abs(x)) * t_0) <= 5e-7) tmp = Float64(Float64(abs(x) * fma(Float64(-0.16666666666666666 * abs(x)), abs(x), 1.0)) * 1.0); else tmp = Float64(abs(x) * t_0); end return Float64(copysign(1.0, x) * tmp) end
code[x_, y_] := Block[{t$95$0 = N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[Sin[N[Abs[x], $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], 5e-7], N[(N[(N[Abs[x], $MachinePrecision] * N[(N[(-0.16666666666666666 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[Abs[x], $MachinePrecision] * t$95$0), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
t_0 := \frac{\sinh y}{y}\\
\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
\mathbf{if}\;\sin \left(\left|x\right|\right) \cdot t\_0 \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\left(\left|x\right| \cdot \mathsf{fma}\left(-0.16666666666666666 \cdot \left|x\right|, \left|x\right|, 1\right)\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\left|x\right| \cdot t\_0\\
\end{array}
\end{array}
if (*.f64 (sin.f64 x) (/.f64 (sinh.f64 y) y)) < 4.9999999999999998e-7Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites51.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6434.2%
Applied rewrites34.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6434.2%
Applied rewrites34.2%
if 4.9999999999999998e-7 < (*.f64 (sin.f64 x) (/.f64 (sinh.f64 y) y)) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites63.1%
(FPCore (x y)
:precision binary64
(*
(copysign 1.0 x)
(if (<= (sin (fabs x)) 5e-7)
(* (* (fabs x) (fma (* -0.16666666666666666 (fabs x)) (fabs x) 1.0)) 1.0)
(/ (* y (fabs x)) y))))double code(double x, double y) {
double tmp;
if (sin(fabs(x)) <= 5e-7) {
tmp = (fabs(x) * fma((-0.16666666666666666 * fabs(x)), fabs(x), 1.0)) * 1.0;
} else {
tmp = (y * fabs(x)) / y;
}
return copysign(1.0, x) * tmp;
}
function code(x, y) tmp = 0.0 if (sin(abs(x)) <= 5e-7) tmp = Float64(Float64(abs(x) * fma(Float64(-0.16666666666666666 * abs(x)), abs(x), 1.0)) * 1.0); else tmp = Float64(Float64(y * abs(x)) / y); end return Float64(copysign(1.0, x) * tmp) end
code[x_, y_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Sin[N[Abs[x], $MachinePrecision]], $MachinePrecision], 5e-7], N[(N[(N[Abs[x], $MachinePrecision] * N[(N[(-0.16666666666666666 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(y * N[Abs[x], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
\mathbf{if}\;\sin \left(\left|x\right|\right) \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\left(\left|x\right| \cdot \mathsf{fma}\left(-0.16666666666666666 \cdot \left|x\right|, \left|x\right|, 1\right)\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot \left|x\right|}{y}\\
\end{array}
if (sin.f64 x) < 4.9999999999999998e-7Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites51.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6434.2%
Applied rewrites34.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6434.2%
Applied rewrites34.2%
if 4.9999999999999998e-7 < (sin.f64 x) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites63.1%
Taylor expanded in y around 0
Applied rewrites26.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6422.0%
Applied rewrites22.0%
(FPCore (x y)
:precision binary64
(*
(copysign 1.0 x)
(if (<= (* (sin (fabs x)) (/ (sinh y) y)) 5e-81)
(* (* (fabs x) 1.0) 1.0)
(/ (* y (fabs x)) y))))double code(double x, double y) {
double tmp;
if ((sin(fabs(x)) * (sinh(y) / y)) <= 5e-81) {
tmp = (fabs(x) * 1.0) * 1.0;
} else {
tmp = (y * fabs(x)) / y;
}
return copysign(1.0, x) * tmp;
}
public static double code(double x, double y) {
double tmp;
if ((Math.sin(Math.abs(x)) * (Math.sinh(y) / y)) <= 5e-81) {
tmp = (Math.abs(x) * 1.0) * 1.0;
} else {
tmp = (y * Math.abs(x)) / y;
}
return Math.copySign(1.0, x) * tmp;
}
def code(x, y): tmp = 0 if (math.sin(math.fabs(x)) * (math.sinh(y) / y)) <= 5e-81: tmp = (math.fabs(x) * 1.0) * 1.0 else: tmp = (y * math.fabs(x)) / y return math.copysign(1.0, x) * tmp
function code(x, y) tmp = 0.0 if (Float64(sin(abs(x)) * Float64(sinh(y) / y)) <= 5e-81) tmp = Float64(Float64(abs(x) * 1.0) * 1.0); else tmp = Float64(Float64(y * abs(x)) / y); end return Float64(copysign(1.0, x) * tmp) end
function tmp_2 = code(x, y) tmp = 0.0; if ((sin(abs(x)) * (sinh(y) / y)) <= 5e-81) tmp = (abs(x) * 1.0) * 1.0; else tmp = (y * abs(x)) / y; end tmp_2 = (sign(x) * abs(1.0)) * tmp; end
code[x_, y_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[Sin[N[Abs[x], $MachinePrecision]], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 5e-81], N[(N[(N[Abs[x], $MachinePrecision] * 1.0), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(y * N[Abs[x], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
\mathbf{if}\;\sin \left(\left|x\right|\right) \cdot \frac{\sinh y}{y} \leq 5 \cdot 10^{-81}:\\
\;\;\;\;\left(\left|x\right| \cdot 1\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot \left|x\right|}{y}\\
\end{array}
if (*.f64 (sin.f64 x) (/.f64 (sinh.f64 y) y)) < 4.9999999999999998e-81Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites51.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6434.2%
Applied rewrites34.2%
Taylor expanded in x around 0
Applied rewrites26.6%
if 4.9999999999999998e-81 < (*.f64 (sin.f64 x) (/.f64 (sinh.f64 y) y)) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites63.1%
Taylor expanded in y around 0
Applied rewrites26.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6422.0%
Applied rewrites22.0%
(FPCore (x y) :precision binary64 (* (* x 1.0) 1.0))
double code(double x, double y) {
return (x * 1.0) * 1.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 = (x * 1.0d0) * 1.0d0
end function
public static double code(double x, double y) {
return (x * 1.0) * 1.0;
}
def code(x, y): return (x * 1.0) * 1.0
function code(x, y) return Float64(Float64(x * 1.0) * 1.0) end
function tmp = code(x, y) tmp = (x * 1.0) * 1.0; end
code[x_, y_] := N[(N[(x * 1.0), $MachinePrecision] * 1.0), $MachinePrecision]
\left(x \cdot 1\right) \cdot 1
Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites51.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6434.2%
Applied rewrites34.2%
Taylor expanded in x around 0
Applied rewrites26.6%
herbie shell --seed 2025202
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))