
(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 4 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 (let* ((t_0 (/ (* (sin x) (sinh y)) x))) (if (<= x -1.5e-8) t_0 (if (<= x 1e-25) (sinh y) t_0))))
double code(double x, double y) {
double t_0 = (sin(x) * sinh(y)) / x;
double tmp;
if (x <= -1.5e-8) {
tmp = t_0;
} else if (x <= 1e-25) {
tmp = sinh(y);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (sin(x) * sinh(y)) / x
if (x <= (-1.5d-8)) then
tmp = t_0
else if (x <= 1d-25) then
tmp = sinh(y)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (Math.sin(x) * Math.sinh(y)) / x;
double tmp;
if (x <= -1.5e-8) {
tmp = t_0;
} else if (x <= 1e-25) {
tmp = Math.sinh(y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (math.sin(x) * math.sinh(y)) / x tmp = 0 if x <= -1.5e-8: tmp = t_0 elif x <= 1e-25: tmp = math.sinh(y) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(sin(x) * sinh(y)) / x) tmp = 0.0 if (x <= -1.5e-8) tmp = t_0; elseif (x <= 1e-25) tmp = sinh(y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (sin(x) * sinh(y)) / x; tmp = 0.0; if (x <= -1.5e-8) tmp = t_0; elseif (x <= 1e-25) tmp = sinh(y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[Sin[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[x, -1.5e-8], t$95$0, If[LessEqual[x, 1e-25], N[Sinh[y], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin x \cdot \sinh y}{x}\\
\mathbf{if}\;x \leq -1.5 \cdot 10^{-8}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 10^{-25}:\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.49999999999999987e-8 or 1.00000000000000004e-25 < x Initial program 99.9%
if -1.49999999999999987e-8 < x < 1.00000000000000004e-25Initial program 75.4%
Taylor expanded in x around 0
Applied rewrites100.0%
(FPCore (x y) :precision binary64 (if (<= x 0.88) (sinh y) (* (sin x) (sinh y))))
double code(double x, double y) {
double tmp;
if (x <= 0.88) {
tmp = sinh(y);
} else {
tmp = sin(x) * sinh(y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 0.88d0) then
tmp = sinh(y)
else
tmp = sin(x) * sinh(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 0.88) {
tmp = Math.sinh(y);
} else {
tmp = Math.sin(x) * Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 0.88: tmp = math.sinh(y) else: tmp = math.sin(x) * math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (x <= 0.88) tmp = sinh(y); else tmp = Float64(sin(x) * sinh(y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 0.88) tmp = sinh(y); else tmp = sin(x) * sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 0.88], N[Sinh[y], $MachinePrecision], N[(N[Sin[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.88:\\
\;\;\;\;\sinh y\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \sinh y\\
\end{array}
\end{array}
if x < 0.880000000000000004Initial program 84.6%
Taylor expanded in x around 0
Applied rewrites77.1%
if 0.880000000000000004 < x Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites59.4%
(FPCore (x y) :precision binary64 (sinh y))
double code(double x, double y) {
return sinh(y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sinh(y)
end function
public static double code(double x, double y) {
return Math.sinh(y);
}
def code(x, y): return math.sinh(y)
function code(x, y) return sinh(y) end
function tmp = code(x, y) tmp = sinh(y); end
code[x_, y_] := N[Sinh[y], $MachinePrecision]
\begin{array}{l}
\\
\sinh y
\end{array}
Initial program 88.3%
Taylor expanded in x around 0
Applied rewrites67.6%
(FPCore (x y) :precision binary64 (sin x))
double code(double x, double y) {
return sin(x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x)
end function
public static double code(double x, double y) {
return Math.sin(x);
}
def code(x, y): return math.sin(x)
function code(x, y) return sin(x) end
function tmp = code(x, y) tmp = sin(x); end
code[x_, y_] := N[Sin[x], $MachinePrecision]
\begin{array}{l}
\\
\sin x
\end{array}
Initial program 88.3%
Taylor expanded in x around 0
Applied rewrites3.0%
(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 2024321
(FPCore (x y)
:name "Linear.Quaternion:$ccosh from linear-1.19.1.3"
:precision binary64
:pre (TRUE)
:alt
(! :herbie-platform default (* (sin x) (/ (sinh y) x)))
(/ (* (sin x) (sinh y)) x))