
(FPCore (x y) :precision binary64 :pre TRUE (* (cos x) (/ (sinh y) y)))
double code(double x, double y) {
return cos(x) * (sinh(y) / y);
}
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]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (cos(x)) * ((((1) / (2)) * ((exp(y)) + ((- (1)) / (exp(y))))) / y) END code
\cos x \cdot \frac{\sinh y}{y}
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 :pre TRUE (* (cos x) (/ (sinh y) y)))
double code(double x, double y) {
return cos(x) * (sinh(y) / y);
}
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]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (cos(x)) * ((((1) / (2)) * ((exp(y)) + ((- (1)) / (exp(y))))) / y) END code
\cos x \cdot \frac{\sinh y}{y}
(FPCore (x y) :precision binary64 :pre TRUE (/ (* (sinh y) (cos x)) y))
double code(double x, double y) {
return (sinh(y) * cos(x)) / y;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (sinh(y) * cos(x)) / y
end function
public static double code(double x, double y) {
return (Math.sinh(y) * Math.cos(x)) / y;
}
def code(x, y): return (math.sinh(y) * math.cos(x)) / y
function code(x, y) return Float64(Float64(sinh(y) * cos(x)) / y) end
function tmp = code(x, y) tmp = (sinh(y) * cos(x)) / y; end
code[x_, y_] := N[(N[(N[Sinh[y], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = ((((1) / (2)) * ((exp(y)) + ((- (1)) / (exp(y))))) * (cos(x))) / y END code
\frac{\sinh y \cdot \cos x}{y}
Initial program 100.0%
Applied rewrites99.9%
(FPCore (x y) :precision binary64 :pre TRUE (* (sinh y) (/ (cos x) y)))
double code(double x, double y) {
return sinh(y) * (cos(x) / y);
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sinh(y) * (cos(x) / y)
end function
public static double code(double x, double y) {
return Math.sinh(y) * (Math.cos(x) / y);
}
def code(x, y): return math.sinh(y) * (math.cos(x) / y)
function code(x, y) return Float64(sinh(y) * Float64(cos(x) / y)) end
function tmp = code(x, y) tmp = sinh(y) * (cos(x) / y); end
code[x_, y_] := N[(N[Sinh[y], $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (((1) / (2)) * ((exp(y)) + ((- (1)) / (exp(y))))) * ((cos(x)) / y) END code
\sinh y \cdot \frac{\cos x}{y}
Initial program 100.0%
Applied rewrites99.9%
(FPCore (x y)
:precision binary64
:pre TRUE
(let* ((t_0 (/ (sinh y) y)) (t_1 (* (cos x) t_0)))
(if (<= t_1 (- INFINITY))
(/ (* (fma (* x x) -0.5 1.0) (sinh y)) y)
(if (<= t_1 0.9999999999933117) (/ (* y (cos x)) y) 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 = (fma((x * x), -0.5, 1.0) * sinh(y)) / y;
} else if (t_1 <= 0.9999999999933117) {
tmp = (y * cos(x)) / y;
} else {
tmp = 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(Float64(fma(Float64(x * x), -0.5, 1.0) * sinh(y)) / y); elseif (t_1 <= 0.9999999999933117) tmp = Float64(Float64(y * cos(x)) / y); else tmp = 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[(N[(N[(N[(x * x), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[t$95$1, 0.9999999999933117], N[(N[(y * N[Cos[x], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
t_0 := \frac{\sinh y}{y}\\
t_1 := \cos x \cdot t\_0\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\frac{\mathsf{fma}\left(x \cdot x, -0.5, 1\right) \cdot \sinh y}{y}\\
\mathbf{elif}\;t\_1 \leq 0.9999999999933117:\\
\;\;\;\;\frac{y \cdot \cos x}{y}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if (*.f64 (cos.f64 x) (/.f64 (sinh.f64 y) y)) < -inf.0Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites63.3%
Applied rewrites63.3%
if -inf.0 < (*.f64 (cos.f64 x) (/.f64 (sinh.f64 y) y)) < 0.99999999999331168Initial program 100.0%
Applied rewrites99.9%
Taylor expanded in y around 0
Applied rewrites50.5%
if 0.99999999999331168 < (*.f64 (cos.f64 x) (/.f64 (sinh.f64 y) y)) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites40.1%
Applied rewrites65.3%
(FPCore (x y) :precision binary64 :pre TRUE (if (<= (cos x) -0.05) (/ (* (fma (* x x) -0.5 1.0) (sinh y)) y) (/ (sinh y) y)))
double code(double x, double y) {
double tmp;
if (cos(x) <= -0.05) {
tmp = (fma((x * x), -0.5, 1.0) * sinh(y)) / y;
} else {
tmp = sinh(y) / y;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (cos(x) <= -0.05) tmp = Float64(Float64(fma(Float64(x * x), -0.5, 1.0) * sinh(y)) / y); else tmp = Float64(sinh(y) / y); end return tmp end
code[x_, y_] := If[LessEqual[N[Cos[x], $MachinePrecision], -0.05], N[(N[(N[(N[(x * x), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET tmp = IF ((cos(x)) <= (-5000000000000000277555756156289135105907917022705078125e-56)) THEN (((((x * x) * (-5e-1)) + (1)) * (((1) / (2)) * ((exp(y)) + ((- (1)) / (exp(y)))))) / y) ELSE ((((1) / (2)) * ((exp(y)) + ((- (1)) / (exp(y))))) / y) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;\cos x \leq -0.05:\\
\;\;\;\;\frac{\mathsf{fma}\left(x \cdot x, -0.5, 1\right) \cdot \sinh y}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sinh y}{y}\\
\end{array}
if (cos.f64 x) < -0.050000000000000003Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites63.3%
Applied rewrites63.3%
if -0.050000000000000003 < (cos.f64 x) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites40.1%
Applied rewrites65.3%
(FPCore (x y) :precision binary64 :pre TRUE (if (<= (cos x) -0.05) (/ (/ 1.0 (/ 2.0 (* (fma (* x x) -0.5 1.0) (* 2.0 y)))) y) (/ (sinh y) y)))
double code(double x, double y) {
double tmp;
if (cos(x) <= -0.05) {
tmp = (1.0 / (2.0 / (fma((x * x), -0.5, 1.0) * (2.0 * y)))) / y;
} else {
tmp = sinh(y) / y;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (cos(x) <= -0.05) tmp = Float64(Float64(1.0 / Float64(2.0 / Float64(fma(Float64(x * x), -0.5, 1.0) * Float64(2.0 * y)))) / y); else tmp = Float64(sinh(y) / y); end return tmp end
code[x_, y_] := If[LessEqual[N[Cos[x], $MachinePrecision], -0.05], N[(N[(1.0 / N[(2.0 / N[(N[(N[(x * x), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[(2.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET tmp = IF ((cos(x)) <= (-5000000000000000277555756156289135105907917022705078125e-56)) THEN (((1) / ((2) / ((((x * x) * (-5e-1)) + (1)) * ((2) * y)))) / y) ELSE ((((1) / (2)) * ((exp(y)) + ((- (1)) / (exp(y))))) / y) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;\cos x \leq -0.05:\\
\;\;\;\;\frac{\frac{1}{\frac{2}{\mathsf{fma}\left(x \cdot x, -0.5, 1\right) \cdot \left(2 \cdot y\right)}}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sinh y}{y}\\
\end{array}
if (cos.f64 x) < -0.050000000000000003Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites63.3%
Applied rewrites63.3%
Applied rewrites63.2%
Taylor expanded in y around 0
Applied rewrites35.6%
if -0.050000000000000003 < (cos.f64 x) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites40.1%
Applied rewrites65.3%
(FPCore (x y)
:precision binary64
:pre TRUE
(if (<= (cos x) -0.07735711983696969)
(*
(/
(- (- (fabs y) -1.0) (fma (fma 0.5 (fabs y) -1.0) (fabs y) 1.0))
(fabs y))
0.5)
(/ (sinh (fabs y)) (fabs y))))double code(double x, double y) {
double tmp;
if (cos(x) <= -0.07735711983696969) {
tmp = (((fabs(y) - -1.0) - fma(fma(0.5, fabs(y), -1.0), fabs(y), 1.0)) / fabs(y)) * 0.5;
} else {
tmp = sinh(fabs(y)) / fabs(y);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (cos(x) <= -0.07735711983696969) tmp = Float64(Float64(Float64(Float64(abs(y) - -1.0) - fma(fma(0.5, abs(y), -1.0), abs(y), 1.0)) / abs(y)) * 0.5); else tmp = Float64(sinh(abs(y)) / abs(y)); end return tmp end
code[x_, y_] := If[LessEqual[N[Cos[x], $MachinePrecision], -0.07735711983696969], N[(N[(N[(N[(N[Abs[y], $MachinePrecision] - -1.0), $MachinePrecision] - N[(N[(0.5 * N[Abs[y], $MachinePrecision] + -1.0), $MachinePrecision] * N[Abs[y], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[Sinh[N[Abs[y], $MachinePrecision]], $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision]]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET tmp = IF ((cos(x)) <= (-7735711983696968996326859269174747169017791748046875e-53)) THEN (((((abs(y)) - (-1)) - (((((5e-1) * (abs(y))) + (-1)) * (abs(y))) + (1))) / (abs(y))) * (5e-1)) ELSE ((((1) / (2)) * ((exp((abs(y)))) + ((- (1)) / (exp((abs(y))))))) / (abs(y))) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;\cos x \leq -0.07735711983696969:\\
\;\;\;\;\frac{\left(\left|y\right| - -1\right) - \mathsf{fma}\left(\mathsf{fma}\left(0.5, \left|y\right|, -1\right), \left|y\right|, 1\right)}{\left|y\right|} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\sinh \left(\left|y\right|\right)}{\left|y\right|}\\
\end{array}
if (cos.f64 x) < -0.07735711983696969Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites40.1%
Taylor expanded in y around 0
Applied rewrites3.4%
Taylor expanded in y around 0
Applied rewrites15.4%
Applied rewrites15.4%
if -0.07735711983696969 < (cos.f64 x) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites40.1%
Applied rewrites65.3%
(FPCore (x y) :precision binary64 :pre TRUE (/ (sinh y) y))
double code(double x, double y) {
return sinh(y) / y;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sinh(y) / y
end function
public static double code(double x, double y) {
return Math.sinh(y) / y;
}
def code(x, y): return math.sinh(y) / y
function code(x, y) return Float64(sinh(y) / y) end
function tmp = code(x, y) tmp = sinh(y) / y; end
code[x_, y_] := N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (((1) / (2)) * ((exp(y)) + ((- (1)) / (exp(y))))) / y END code
\frac{\sinh y}{y}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites40.1%
Applied rewrites65.3%
(FPCore (x y) :precision binary64 :pre TRUE (* 0.5 2.0))
double code(double x, double y) {
return 0.5 * 2.0;
}
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]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (5e-1) * (2) END code
0.5 \cdot 2
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites40.1%
Taylor expanded in y around 0
Applied rewrites28.6%
herbie shell --seed 2026092
(FPCore (x y)
:name "Linear.Quaternion:$csin from linear-1.19.1.3"
:precision binary64
(* (cos x) (/ (sinh y) y)))