
(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 7 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) (/ (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 (let* ((t_0 (/ (sinh y) y))) (if (<= t_0 2.0) (sin x) (* x t_0))))
double code(double x, double y) {
double t_0 = sinh(y) / y;
double tmp;
if (t_0 <= 2.0) {
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 <= 2.0d0) 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 <= 2.0) {
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 <= 2.0: 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 <= 2.0) 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 <= 2.0) 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, 2.0], 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 2:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot t\_0\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 y) y) < 2Initial program 100.0%
Taylor expanded in y around 0 99.4%
if 2 < (/.f64 (sinh.f64 y) y) Initial program 100.0%
Taylor expanded in x around 0 80.4%
(FPCore (x y)
:precision binary64
(if (<= y 1.6e+23)
(sin x)
(if (<= y 4.15e+98)
(* x (+ 1.0 (* (/ (* x y) (* y (/ 1.0 x))) -0.16666666666666666)))
(/ (* x y) y))))
double code(double x, double y) {
double tmp;
if (y <= 1.6e+23) {
tmp = sin(x);
} else if (y <= 4.15e+98) {
tmp = x * (1.0 + (((x * y) / (y * (1.0 / x))) * -0.16666666666666666));
} 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 (y <= 1.6d+23) then
tmp = sin(x)
else if (y <= 4.15d+98) then
tmp = x * (1.0d0 + (((x * y) / (y * (1.0d0 / x))) * (-0.16666666666666666d0)))
else
tmp = (x * y) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1.6e+23) {
tmp = Math.sin(x);
} else if (y <= 4.15e+98) {
tmp = x * (1.0 + (((x * y) / (y * (1.0 / x))) * -0.16666666666666666));
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.6e+23: tmp = math.sin(x) elif y <= 4.15e+98: tmp = x * (1.0 + (((x * y) / (y * (1.0 / x))) * -0.16666666666666666)) else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 1.6e+23) tmp = sin(x); elseif (y <= 4.15e+98) tmp = Float64(x * Float64(1.0 + Float64(Float64(Float64(x * y) / Float64(y * Float64(1.0 / x))) * -0.16666666666666666))); else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.6e+23) tmp = sin(x); elseif (y <= 4.15e+98) tmp = x * (1.0 + (((x * y) / (y * (1.0 / x))) * -0.16666666666666666)); else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.6e+23], N[Sin[x], $MachinePrecision], If[LessEqual[y, 4.15e+98], N[(x * N[(1.0 + N[(N[(N[(x * y), $MachinePrecision] / N[(y * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.6 \cdot 10^{+23}:\\
\;\;\;\;\sin x\\
\mathbf{elif}\;y \leq 4.15 \cdot 10^{+98}:\\
\;\;\;\;x \cdot \left(1 + \frac{x \cdot y}{y \cdot \frac{1}{x}} \cdot -0.16666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if y < 1.6e23Initial program 100.0%
Taylor expanded in y around 0 64.7%
if 1.6e23 < y < 4.1499999999999998e98Initial program 100.0%
Taylor expanded in y around 0 2.5%
Taylor expanded in x around 0 24.1%
*-commutative24.1%
Simplified24.1%
*-rgt-identity24.1%
*-inverses24.1%
associate-/l*24.1%
pow224.1%
clear-num24.1%
frac-times24.1%
*-un-lft-identity24.1%
*-commutative24.1%
*-commutative24.1%
associate-/r*24.1%
*-inverses24.1%
Applied egg-rr24.1%
if 4.1499999999999998e98 < y Initial program 100.0%
add-log-exp100.0%
*-un-lft-identity100.0%
log-prod100.0%
metadata-eval100.0%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in y around 0 2.6%
Taylor expanded in x around 0 25.5%
Final simplification53.6%
(FPCore (x y)
:precision binary64
(if (<= x 6.2e+129)
(* x (+ 1.0 (* -0.16666666666666666 (/ (* x (* x y)) y))))
(if (<= x 3.3e+272)
(/ (* x y) y)
(* x (+ 1.0 (* -0.16666666666666666 (* x x)))))))
double code(double x, double y) {
double tmp;
if (x <= 6.2e+129) {
tmp = x * (1.0 + (-0.16666666666666666 * ((x * (x * y)) / y)));
} else if (x <= 3.3e+272) {
tmp = (x * y) / y;
} else {
tmp = x * (1.0 + (-0.16666666666666666 * (x * x)));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 6.2d+129) then
tmp = x * (1.0d0 + ((-0.16666666666666666d0) * ((x * (x * y)) / y)))
else if (x <= 3.3d+272) then
tmp = (x * y) / y
else
tmp = x * (1.0d0 + ((-0.16666666666666666d0) * (x * x)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 6.2e+129) {
tmp = x * (1.0 + (-0.16666666666666666 * ((x * (x * y)) / y)));
} else if (x <= 3.3e+272) {
tmp = (x * y) / y;
} else {
tmp = x * (1.0 + (-0.16666666666666666 * (x * x)));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 6.2e+129: tmp = x * (1.0 + (-0.16666666666666666 * ((x * (x * y)) / y))) elif x <= 3.3e+272: tmp = (x * y) / y else: tmp = x * (1.0 + (-0.16666666666666666 * (x * x))) return tmp
function code(x, y) tmp = 0.0 if (x <= 6.2e+129) tmp = Float64(x * Float64(1.0 + Float64(-0.16666666666666666 * Float64(Float64(x * Float64(x * y)) / y)))); elseif (x <= 3.3e+272) tmp = Float64(Float64(x * y) / y); else tmp = Float64(x * Float64(1.0 + Float64(-0.16666666666666666 * Float64(x * x)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 6.2e+129) tmp = x * (1.0 + (-0.16666666666666666 * ((x * (x * y)) / y))); elseif (x <= 3.3e+272) tmp = (x * y) / y; else tmp = x * (1.0 + (-0.16666666666666666 * (x * x))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 6.2e+129], N[(x * N[(1.0 + N[(-0.16666666666666666 * N[(N[(x * N[(x * y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.3e+272], N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision], N[(x * N[(1.0 + N[(-0.16666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.2 \cdot 10^{+129}:\\
\;\;\;\;x \cdot \left(1 + -0.16666666666666666 \cdot \frac{x \cdot \left(x \cdot y\right)}{y}\right)\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{+272}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + -0.16666666666666666 \cdot \left(x \cdot x\right)\right)\\
\end{array}
\end{array}
if x < 6.1999999999999999e129Initial program 100.0%
Taylor expanded in y around 0 47.9%
Taylor expanded in x around 0 30.5%
*-commutative30.5%
Simplified30.5%
unpow230.5%
*-un-lft-identity30.5%
associate-*r*30.5%
*-inverses30.5%
associate-/l*31.8%
associate-*l/32.2%
*-commutative32.2%
Applied egg-rr32.2%
if 6.1999999999999999e129 < x < 3.29999999999999998e272Initial program 100.0%
add-log-exp99.4%
*-un-lft-identity99.4%
log-prod99.4%
metadata-eval99.4%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in y around 0 40.3%
Taylor expanded in x around 0 36.4%
if 3.29999999999999998e272 < x Initial program 100.0%
Taylor expanded in y around 0 51.6%
Taylor expanded in x around 0 50.9%
*-commutative50.9%
Simplified50.9%
unpow250.9%
Applied egg-rr50.9%
Final simplification33.2%
(FPCore (x y) :precision binary64 (if (<= y 4e+98) (* x (+ 1.0 (* -0.16666666666666666 (* x x)))) (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (y <= 4e+98) {
tmp = x * (1.0 + (-0.16666666666666666 * (x * 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 (y <= 4d+98) then
tmp = x * (1.0d0 + ((-0.16666666666666666d0) * (x * x)))
else
tmp = (x * y) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 4e+98) {
tmp = x * (1.0 + (-0.16666666666666666 * (x * x)));
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 4e+98: tmp = x * (1.0 + (-0.16666666666666666 * (x * x))) else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 4e+98) tmp = Float64(x * Float64(1.0 + Float64(-0.16666666666666666 * Float64(x * x)))); else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 4e+98) tmp = x * (1.0 + (-0.16666666666666666 * (x * x))); else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 4e+98], N[(x * N[(1.0 + N[(-0.16666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4 \cdot 10^{+98}:\\
\;\;\;\;x \cdot \left(1 + -0.16666666666666666 \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if y < 3.99999999999999999e98Initial program 100.0%
Taylor expanded in y around 0 59.2%
Taylor expanded in x around 0 34.2%
*-commutative34.2%
Simplified34.2%
unpow234.2%
Applied egg-rr34.2%
if 3.99999999999999999e98 < y Initial program 100.0%
add-log-exp100.0%
*-un-lft-identity100.0%
log-prod100.0%
metadata-eval100.0%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in y around 0 2.6%
Taylor expanded in x around 0 25.5%
Final simplification32.4%
(FPCore (x y) :precision binary64 (if (<= x 3.7e+81) x (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (x <= 3.7e+81) {
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 <= 3.7d+81) 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 <= 3.7e+81) {
tmp = x;
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 3.7e+81: tmp = x else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (x <= 3.7e+81) tmp = x; else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 3.7e+81) tmp = x; else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 3.7e+81], x, N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.7 \cdot 10^{+81}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if x < 3.7000000000000001e81Initial program 100.0%
Taylor expanded in x around 0 72.2%
Taylor expanded in y around 0 28.4%
if 3.7000000000000001e81 < x Initial program 100.0%
add-log-exp99.5%
*-un-lft-identity99.5%
log-prod99.5%
metadata-eval99.5%
add-log-exp100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in y around 0 43.9%
Taylor expanded in x around 0 21.9%
(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 65.9%
Taylor expanded in y around 0 23.9%
herbie shell --seed 2024150
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))