
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(x) * (sinh(y) / y);
}
real(8) function code(x, y)
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]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 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);
}
real(8) function code(x, y)
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]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
(FPCore (x y) :precision binary64 (/ (sin x) (/ y (sinh y))))
double code(double x, double y) {
return sin(x) / (y / sinh(y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) / (y / sinh(y))
end function
public static double code(double x, double y) {
return Math.sin(x) / (y / Math.sinh(y));
}
def code(x, y): return math.sin(x) / (y / math.sinh(y))
function code(x, y) return Float64(sin(x) / Float64(y / sinh(y))) end
function tmp = code(x, y) tmp = sin(x) / (y / sinh(y)); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] / N[(y / N[Sinh[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin x}{\frac{y}{\sinh y}}
\end{array}
Initial program 100.0%
add-log-exp70.1%
*-un-lft-identity70.1%
log-prod70.1%
metadata-eval70.1%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/86.9%
associate-*l/89.8%
associate-/r/100.0%
Simplified100.0%
(FPCore (x y) :precision binary64 (if (<= (/ (sinh y) y) 1.01) (sin x) (/ (* x (sinh y)) y)))
double code(double x, double y) {
double tmp;
if ((sinh(y) / y) <= 1.01) {
tmp = sin(x);
} else {
tmp = (x * sinh(y)) / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((sinh(y) / y) <= 1.01d0) then
tmp = sin(x)
else
tmp = (x * sinh(y)) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((Math.sinh(y) / y) <= 1.01) {
tmp = Math.sin(x);
} else {
tmp = (x * Math.sinh(y)) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if (math.sinh(y) / y) <= 1.01: tmp = math.sin(x) else: tmp = (x * math.sinh(y)) / y return tmp
function code(x, y) tmp = 0.0 if (Float64(sinh(y) / y) <= 1.01) tmp = sin(x); else tmp = Float64(Float64(x * sinh(y)) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((sinh(y) / y) <= 1.01) tmp = sin(x); else tmp = (x * sinh(y)) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision], 1.01], N[Sin[x], $MachinePrecision], N[(N[(x * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sinh y}{y} \leq 1.01:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \sinh y}{y}\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 y) y) < 1.01000000000000001Initial program 100.0%
Taylor expanded in y around 0 99.1%
if 1.01000000000000001 < (/.f64 (sinh.f64 y) y) Initial program 100.0%
Taylor expanded in x around 0 75.8%
associate-*r/75.8%
Applied egg-rr75.8%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ (sinh y) y))) (if (<= t_0 1.01) (sin x) (* x t_0))))
double code(double x, double y) {
double t_0 = sinh(y) / y;
double tmp;
if (t_0 <= 1.01) {
tmp = sin(x);
} else {
tmp = x * 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 = sinh(y) / y
if (t_0 <= 1.01d0) then
tmp = sin(x)
else
tmp = x * t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.sinh(y) / y;
double tmp;
if (t_0 <= 1.01) {
tmp = Math.sin(x);
} else {
tmp = x * t_0;
}
return tmp;
}
def code(x, y): t_0 = math.sinh(y) / y tmp = 0 if t_0 <= 1.01: tmp = math.sin(x) else: tmp = x * t_0 return tmp
function code(x, y) t_0 = Float64(sinh(y) / y) tmp = 0.0 if (t_0 <= 1.01) tmp = sin(x); else tmp = Float64(x * t_0); end return tmp end
function tmp_2 = code(x, y) t_0 = sinh(y) / y; tmp = 0.0; if (t_0 <= 1.01) tmp = sin(x); else tmp = x * t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[t$95$0, 1.01], N[Sin[x], $MachinePrecision], N[(x * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sinh y}{y}\\
\mathbf{if}\;t\_0 \leq 1.01:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot t\_0\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 y) y) < 1.01000000000000001Initial program 100.0%
Taylor expanded in y around 0 99.1%
if 1.01000000000000001 < (/.f64 (sinh.f64 y) y) Initial program 100.0%
Taylor expanded in x around 0 75.8%
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(x) * (sinh(y) / y);
}
real(8) function code(x, y)
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]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
Initial program 100.0%
(FPCore (x y)
:precision binary64
(if (<= y 500000.0)
(sin x)
(if (or (<= y 4.5e+69) (not (<= y 2.3e+241)))
(* -0.16666666666666666 (pow x 3.0))
(* (/ 1.0 y) (* x y)))))
double code(double x, double y) {
double tmp;
if (y <= 500000.0) {
tmp = sin(x);
} else if ((y <= 4.5e+69) || !(y <= 2.3e+241)) {
tmp = -0.16666666666666666 * pow(x, 3.0);
} else {
tmp = (1.0 / y) * (x * y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 500000.0d0) then
tmp = sin(x)
else if ((y <= 4.5d+69) .or. (.not. (y <= 2.3d+241))) then
tmp = (-0.16666666666666666d0) * (x ** 3.0d0)
else
tmp = (1.0d0 / y) * (x * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 500000.0) {
tmp = Math.sin(x);
} else if ((y <= 4.5e+69) || !(y <= 2.3e+241)) {
tmp = -0.16666666666666666 * Math.pow(x, 3.0);
} else {
tmp = (1.0 / y) * (x * y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 500000.0: tmp = math.sin(x) elif (y <= 4.5e+69) or not (y <= 2.3e+241): tmp = -0.16666666666666666 * math.pow(x, 3.0) else: tmp = (1.0 / y) * (x * y) return tmp
function code(x, y) tmp = 0.0 if (y <= 500000.0) tmp = sin(x); elseif ((y <= 4.5e+69) || !(y <= 2.3e+241)) tmp = Float64(-0.16666666666666666 * (x ^ 3.0)); else tmp = Float64(Float64(1.0 / y) * Float64(x * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 500000.0) tmp = sin(x); elseif ((y <= 4.5e+69) || ~((y <= 2.3e+241))) tmp = -0.16666666666666666 * (x ^ 3.0); else tmp = (1.0 / y) * (x * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 500000.0], N[Sin[x], $MachinePrecision], If[Or[LessEqual[y, 4.5e+69], N[Not[LessEqual[y, 2.3e+241]], $MachinePrecision]], N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] * N[(x * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 500000:\\
\;\;\;\;\sin x\\
\mathbf{elif}\;y \leq 4.5 \cdot 10^{+69} \lor \neg \left(y \leq 2.3 \cdot 10^{+241}\right):\\
\;\;\;\;-0.16666666666666666 \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y} \cdot \left(x \cdot y\right)\\
\end{array}
\end{array}
if y < 5e5Initial program 100.0%
Taylor expanded in y around 0 71.2%
if 5e5 < y < 4.4999999999999999e69 or 2.2999999999999999e241 < y Initial program 100.0%
Taylor expanded in y around 0 2.6%
Taylor expanded in x around 0 32.4%
distribute-rgt-in32.4%
*-lft-identity32.4%
associate-*l*32.4%
pow-plus32.4%
metadata-eval32.4%
Simplified32.4%
Taylor expanded in x around inf 32.2%
if 4.4999999999999999e69 < y < 2.2999999999999999e241Initial program 100.0%
Taylor expanded in x around 0 82.8%
associate-*r/82.8%
Applied egg-rr82.8%
Taylor expanded in y around 0 15.6%
clear-num15.6%
associate-/r/15.6%
Applied egg-rr15.6%
Final simplification59.5%
(FPCore (x y) :precision binary64 (if (<= y 5.5e+69) (sin x) (* (/ 1.0 y) (* x y))))
double code(double x, double y) {
double tmp;
if (y <= 5.5e+69) {
tmp = sin(x);
} else {
tmp = (1.0 / y) * (x * y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 5.5d+69) then
tmp = sin(x)
else
tmp = (1.0d0 / y) * (x * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 5.5e+69) {
tmp = Math.sin(x);
} else {
tmp = (1.0 / y) * (x * y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 5.5e+69: tmp = math.sin(x) else: tmp = (1.0 / y) * (x * y) return tmp
function code(x, y) tmp = 0.0 if (y <= 5.5e+69) tmp = sin(x); else tmp = Float64(Float64(1.0 / y) * Float64(x * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 5.5e+69) tmp = sin(x); else tmp = (1.0 / y) * (x * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 5.5e+69], N[Sin[x], $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] * N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.5 \cdot 10^{+69}:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y} \cdot \left(x \cdot y\right)\\
\end{array}
\end{array}
if y < 5.50000000000000002e69Initial program 100.0%
Taylor expanded in y around 0 65.6%
if 5.50000000000000002e69 < y Initial program 100.0%
Taylor expanded in x around 0 78.7%
associate-*r/78.7%
Applied egg-rr78.7%
Taylor expanded in y around 0 16.5%
clear-num16.5%
associate-/r/16.5%
Applied egg-rr16.5%
(FPCore (x y) :precision binary64 (if (<= x 2.7e+73) x (/ (+ (+ 1.0 (* x y)) -1.0) y)))
double code(double x, double y) {
double tmp;
if (x <= 2.7e+73) {
tmp = x;
} else {
tmp = ((1.0 + (x * y)) + -1.0) / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 2.7d+73) then
tmp = x
else
tmp = ((1.0d0 + (x * y)) + (-1.0d0)) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 2.7e+73) {
tmp = x;
} else {
tmp = ((1.0 + (x * y)) + -1.0) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 2.7e+73: tmp = x else: tmp = ((1.0 + (x * y)) + -1.0) / y return tmp
function code(x, y) tmp = 0.0 if (x <= 2.7e+73) tmp = x; else tmp = Float64(Float64(Float64(1.0 + Float64(x * y)) + -1.0) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 2.7e+73) tmp = x; else tmp = ((1.0 + (x * y)) + -1.0) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 2.7e+73], x, N[(N[(N[(1.0 + N[(x * y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.7 \cdot 10^{+73}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + x \cdot y\right) + -1}{y}\\
\end{array}
\end{array}
if x < 2.6999999999999999e73Initial program 100.0%
Taylor expanded in x around 0 75.9%
Taylor expanded in y around 0 39.5%
if 2.6999999999999999e73 < x Initial program 100.0%
Taylor expanded in x around 0 26.8%
associate-*r/26.8%
Applied egg-rr26.8%
Taylor expanded in y around 0 13.6%
expm1-log1p-u6.1%
expm1-undefine6.2%
log1p-undefine6.2%
rem-exp-log13.6%
Applied egg-rr13.6%
Final simplification35.2%
(FPCore (x y) :precision binary64 (if (<= x 1e+44) x (* (/ 1.0 y) (* x y))))
double code(double x, double y) {
double tmp;
if (x <= 1e+44) {
tmp = x;
} else {
tmp = (1.0 / y) * (x * y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 1d+44) then
tmp = x
else
tmp = (1.0d0 / y) * (x * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 1e+44) {
tmp = x;
} else {
tmp = (1.0 / y) * (x * y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1e+44: tmp = x else: tmp = (1.0 / y) * (x * y) return tmp
function code(x, y) tmp = 0.0 if (x <= 1e+44) tmp = x; else tmp = Float64(Float64(1.0 / y) * Float64(x * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1e+44) tmp = x; else tmp = (1.0 / y) * (x * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1e+44], x, N[(N[(1.0 / y), $MachinePrecision] * N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{+44}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y} \cdot \left(x \cdot y\right)\\
\end{array}
\end{array}
if x < 1.0000000000000001e44Initial program 100.0%
Taylor expanded in x around 0 77.6%
Taylor expanded in y around 0 40.6%
if 1.0000000000000001e44 < x Initial program 99.9%
Taylor expanded in x around 0 25.8%
associate-*r/25.8%
Applied egg-rr25.8%
Taylor expanded in y around 0 12.2%
clear-num12.2%
associate-/r/12.2%
Applied egg-rr12.2%
(FPCore (x y) :precision binary64 (if (<= x 2e+41) x (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (x <= 2e+41) {
tmp = x;
} else {
tmp = (x * y) / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 2d+41) then
tmp = x
else
tmp = (x * y) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 2e+41) {
tmp = x;
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 2e+41: tmp = x else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (x <= 2e+41) tmp = x; else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 2e+41) tmp = x; else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 2e+41], x, N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2 \cdot 10^{+41}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if x < 2.00000000000000001e41Initial program 100.0%
Taylor expanded in x around 0 77.6%
Taylor expanded in y around 0 40.6%
if 2.00000000000000001e41 < x Initial program 99.9%
Taylor expanded in x around 0 25.8%
associate-*r/25.8%
Applied egg-rr25.8%
Taylor expanded in y around 0 12.2%
(FPCore (x y) :precision binary64 x)
double code(double x, double y) {
return x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x
end function
public static double code(double x, double y) {
return x;
}
def code(x, y): return x
function code(x, y) return x end
function tmp = code(x, y) tmp = x; end
code[x_, y_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 100.0%
Taylor expanded in x around 0 67.7%
Taylor expanded in y around 0 33.3%
herbie shell --seed 2024111
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))