
(FPCore (x y) :precision binary64 (/ (* (sin x) (sinh y)) x))
double code(double x, double y) {
return (sin(x) * sinh(y)) / x;
}
real(8) function code(x, y)
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 22 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;
}
real(8) function code(x, y)
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 (* (/ (sin x) x) (sinh y)))
double code(double x, double y) {
return (sin(x) / x) * sinh(y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (sin(x) / x) * sinh(y)
end function
public static double code(double x, double y) {
return (Math.sin(x) / x) * Math.sinh(y);
}
def code(x, y): return (math.sin(x) / x) * math.sinh(y)
function code(x, y) return Float64(Float64(sin(x) / x) * sinh(y)) end
function tmp = code(x, y) tmp = (sin(x) / x) * sinh(y); end
code[x_, y_] := N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin x}{x} \cdot \sinh y
\end{array}
Initial program 87.5%
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* (sin x) (sinh y)) x)))
(if (<= t_0 (- INFINITY))
(/
(*
y
(*
(fma
(* x x)
(*
x
(fma
(* x x)
(fma (* x x) -0.0001984126984126984 0.008333333333333333)
-0.16666666666666666))
x)
(fma y (* y 0.16666666666666666) 1.0)))
x)
(if (<= t_0 1e-6)
(* (/ (sin x) x) (fma (* y y) (* y 0.16666666666666666) y))
(* (sinh y) 1.0)))))
double code(double x, double y) {
double t_0 = (sin(x) * sinh(y)) / x;
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (y * (fma((x * x), (x * fma((x * x), fma((x * x), -0.0001984126984126984, 0.008333333333333333), -0.16666666666666666)), x) * fma(y, (y * 0.16666666666666666), 1.0))) / x;
} else if (t_0 <= 1e-6) {
tmp = (sin(x) / x) * fma((y * y), (y * 0.16666666666666666), y);
} else {
tmp = sinh(y) * 1.0;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(sin(x) * sinh(y)) / x) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(y * Float64(fma(Float64(x * x), Float64(x * fma(Float64(x * x), fma(Float64(x * x), -0.0001984126984126984, 0.008333333333333333), -0.16666666666666666)), x) * fma(y, Float64(y * 0.16666666666666666), 1.0))) / x); elseif (t_0 <= 1e-6) tmp = Float64(Float64(sin(x) / x) * fma(Float64(y * y), Float64(y * 0.16666666666666666), y)); else tmp = Float64(sinh(y) * 1.0); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[Sin[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(y * N[(N[(N[(x * x), $MachinePrecision] * N[(x * N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision] + -0.16666666666666666), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision] * N[(y * N[(y * 0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[t$95$0, 1e-6], N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * N[(N[(y * y), $MachinePrecision] * N[(y * 0.16666666666666666), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision], N[(N[Sinh[y], $MachinePrecision] * 1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin x \cdot \sinh y}{x}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\frac{y \cdot \left(\mathsf{fma}\left(x \cdot x, x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), x\right) \cdot \mathsf{fma}\left(y, y \cdot 0.16666666666666666, 1\right)\right)}{x}\\
\mathbf{elif}\;t\_0 \leq 10^{-6}:\\
\;\;\;\;\frac{\sin x}{x} \cdot \mathsf{fma}\left(y \cdot y, y \cdot 0.16666666666666666, y\right)\\
\mathbf{else}:\\
\;\;\;\;\sinh y \cdot 1\\
\end{array}
\end{array}
if (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < -inf.0Initial program 100.0%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
*-lft-identityN/A
associate-*r*N/A
distribute-rgt-inN/A
lower-*.f64N/A
lower-sin.f64N/A
+-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6468.9
Applied rewrites68.9%
Taylor expanded in x around 0
Applied rewrites58.2%
if -inf.0 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) < 9.99999999999999955e-7Initial program 78.4%
Taylor expanded in y around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r/N/A
*-commutativeN/A
associate-*r*N/A
associate-*r/N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-/l*N/A
distribute-rgt-outN/A
*-rgt-identityN/A
distribute-lft-inN/A
Applied rewrites99.0%
if 9.99999999999999955e-7 < (/.f64 (*.f64 (sin.f64 x) (sinh.f64 y)) x) Initial program 100.0%
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites77.3%
Final simplification83.2%
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) x)))
double code(double x, double y) {
return sin(x) * (sinh(y) / x);
}
real(8) function code(x, y)
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 2024223
(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))