
(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 6 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 5000000000.0) (sin x) (* x t_0))))
double code(double x, double y) {
double t_0 = sinh(y) / y;
double tmp;
if (t_0 <= 5000000000.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 <= 5000000000.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 <= 5000000000.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 <= 5000000000.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 <= 5000000000.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 <= 5000000000.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, 5000000000.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 5000000000:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot t\_0\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 y) y) < 5e9Initial program 100.0%
Taylor expanded in y around 0 97.5%
if 5e9 < (/.f64 (sinh.f64 y) y) Initial program 100.0%
Taylor expanded in x around 0 84.3%
(FPCore (x y)
:precision binary64
(if (<= y 2600000000.0)
(sin x)
(if (<= y 1.5e+129)
(+ x (* -0.16666666666666666 (* x (/ (* (* x y) (* x y)) (* y y)))))
(/ (* x y) y))))
double code(double x, double y) {
double tmp;
if (y <= 2600000000.0) {
tmp = sin(x);
} else if (y <= 1.5e+129) {
tmp = x + (-0.16666666666666666 * (x * (((x * y) * (x * y)) / (y * y))));
} 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 <= 2600000000.0d0) then
tmp = sin(x)
else if (y <= 1.5d+129) then
tmp = x + ((-0.16666666666666666d0) * (x * (((x * y) * (x * y)) / (y * y))))
else
tmp = (x * y) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 2600000000.0) {
tmp = Math.sin(x);
} else if (y <= 1.5e+129) {
tmp = x + (-0.16666666666666666 * (x * (((x * y) * (x * y)) / (y * y))));
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2600000000.0: tmp = math.sin(x) elif y <= 1.5e+129: tmp = x + (-0.16666666666666666 * (x * (((x * y) * (x * y)) / (y * y)))) else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 2600000000.0) tmp = sin(x); elseif (y <= 1.5e+129) tmp = Float64(x + Float64(-0.16666666666666666 * Float64(x * Float64(Float64(Float64(x * y) * Float64(x * y)) / Float64(y * y))))); else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 2600000000.0) tmp = sin(x); elseif (y <= 1.5e+129) tmp = x + (-0.16666666666666666 * (x * (((x * y) * (x * y)) / (y * y)))); else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2600000000.0], N[Sin[x], $MachinePrecision], If[LessEqual[y, 1.5e+129], N[(x + N[(-0.16666666666666666 * N[(x * N[(N[(N[(x * y), $MachinePrecision] * N[(x * y), $MachinePrecision]), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2600000000:\\
\;\;\;\;\sin x\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{+129}:\\
\;\;\;\;x + -0.16666666666666666 \cdot \left(x \cdot \frac{\left(x \cdot y\right) \cdot \left(x \cdot y\right)}{y \cdot y}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if y < 2.6e9Initial program 100.0%
Taylor expanded in y around 0 58.3%
if 2.6e9 < y < 1.50000000000000015e129Initial program 100.0%
Taylor expanded in y around 0 2.7%
Taylor expanded in x around 0 15.7%
distribute-rgt-in15.7%
*-lft-identity15.7%
associate-*l*15.7%
pow-plus15.7%
metadata-eval15.7%
Simplified15.7%
unpow315.7%
pow215.7%
Applied egg-rr15.7%
*-un-lft-identity15.7%
*-commutative15.7%
*-inverses15.7%
associate-/l*15.7%
pow215.7%
frac-2neg15.7%
frac-times20.1%
*-commutative20.1%
distribute-rgt-neg-in20.1%
Applied egg-rr20.1%
if 1.50000000000000015e129 < 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.7%
Taylor expanded in x around 0 23.5%
Final simplification50.1%
(FPCore (x y) :precision binary64 (if (<= y 8.5e+69) (+ x (* -0.16666666666666666 (* x (* x x)))) (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (y <= 8.5e+69) {
tmp = x + (-0.16666666666666666 * (x * (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 <= 8.5d+69) then
tmp = x + ((-0.16666666666666666d0) * (x * (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 <= 8.5e+69) {
tmp = x + (-0.16666666666666666 * (x * (x * x)));
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 8.5e+69: tmp = x + (-0.16666666666666666 * (x * (x * x))) else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 8.5e+69) tmp = Float64(x + Float64(-0.16666666666666666 * Float64(x * 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 <= 8.5e+69) tmp = x + (-0.16666666666666666 * (x * (x * x))); else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 8.5e+69], N[(x + N[(-0.16666666666666666 * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.5 \cdot 10^{+69}:\\
\;\;\;\;x + -0.16666666666666666 \cdot \left(x \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if y < 8.5000000000000002e69Initial program 100.0%
Taylor expanded in y around 0 56.4%
Taylor expanded in x around 0 33.9%
distribute-rgt-in33.9%
*-lft-identity33.9%
associate-*l*33.9%
pow-plus33.9%
metadata-eval33.9%
Simplified33.9%
unpow333.9%
pow233.9%
Applied egg-rr33.9%
unpow233.9%
Applied egg-rr33.9%
if 8.5000000000000002e69 < 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.7%
Taylor expanded in x around 0 21.4%
Final simplification31.4%
(FPCore (x y) :precision binary64 (if (<= y 3.6e+69) x (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (y <= 3.6e+69) {
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 (y <= 3.6d+69) 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 (y <= 3.6e+69) {
tmp = x;
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 3.6e+69: tmp = x else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (y <= 3.6e+69) tmp = x; else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 3.6e+69) tmp = x; else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 3.6e+69], x, N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.6 \cdot 10^{+69}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if y < 3.6000000000000003e69Initial program 100.0%
Taylor expanded in x around 0 63.3%
Taylor expanded in y around 0 28.8%
if 3.6000000000000003e69 < 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.7%
Taylor expanded in x around 0 21.4%
(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 68.3%
Taylor expanded in y around 0 23.7%
herbie shell --seed 2024160
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))