| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 13120 |
\[\cosh x \cdot \frac{\sin y}{y}
\]
(FPCore (x y) :precision binary64 (* (cosh x) (/ (sin y) y)))
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (sin y) y)))
(+
t_0
(+
(* 0.5 (* (pow x 2.0) t_0))
(+
(* 0.041666666666666664 (* (pow x 4.0) t_0))
(* 0.001388888888888889 (* (pow x 6.0) t_0)))))))double code(double x, double y) {
return cosh(x) * (sin(y) / y);
}
double code(double x, double y) {
double t_0 = sin(y) / y;
return t_0 + ((0.5 * (pow(x, 2.0) * t_0)) + ((0.041666666666666664 * (pow(x, 4.0) * t_0)) + (0.001388888888888889 * (pow(x, 6.0) * t_0))));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = cosh(x) * (sin(y) / y)
end function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = sin(y) / y
code = t_0 + ((0.5d0 * ((x ** 2.0d0) * t_0)) + ((0.041666666666666664d0 * ((x ** 4.0d0) * t_0)) + (0.001388888888888889d0 * ((x ** 6.0d0) * t_0))))
end function
public static double code(double x, double y) {
return Math.cosh(x) * (Math.sin(y) / y);
}
public static double code(double x, double y) {
double t_0 = Math.sin(y) / y;
return t_0 + ((0.5 * (Math.pow(x, 2.0) * t_0)) + ((0.041666666666666664 * (Math.pow(x, 4.0) * t_0)) + (0.001388888888888889 * (Math.pow(x, 6.0) * t_0))));
}
def code(x, y): return math.cosh(x) * (math.sin(y) / y)
def code(x, y): t_0 = math.sin(y) / y return t_0 + ((0.5 * (math.pow(x, 2.0) * t_0)) + ((0.041666666666666664 * (math.pow(x, 4.0) * t_0)) + (0.001388888888888889 * (math.pow(x, 6.0) * t_0))))
function code(x, y) return Float64(cosh(x) * Float64(sin(y) / y)) end
function code(x, y) t_0 = Float64(sin(y) / y) return Float64(t_0 + Float64(Float64(0.5 * Float64((x ^ 2.0) * t_0)) + Float64(Float64(0.041666666666666664 * Float64((x ^ 4.0) * t_0)) + Float64(0.001388888888888889 * Float64((x ^ 6.0) * t_0))))) end
function tmp = code(x, y) tmp = cosh(x) * (sin(y) / y); end
function tmp = code(x, y) t_0 = sin(y) / y; tmp = t_0 + ((0.5 * ((x ^ 2.0) * t_0)) + ((0.041666666666666664 * ((x ^ 4.0) * t_0)) + (0.001388888888888889 * ((x ^ 6.0) * t_0)))); end
code[x_, y_] := N[(N[Cosh[x], $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]}, N[(t$95$0 + N[(N[(0.5 * N[(N[Power[x, 2.0], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[(0.041666666666666664 * N[(N[Power[x, 4.0], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(0.001388888888888889 * N[(N[Power[x, 6.0], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\cosh x \cdot \frac{\sin y}{y}
\begin{array}{l}
t_0 := \frac{\sin y}{y}\\
t_0 + \left(0.5 \cdot \left({x}^{2} \cdot t_0\right) + \left(0.041666666666666664 \cdot \left({x}^{4} \cdot t_0\right) + 0.001388888888888889 \cdot \left({x}^{6} \cdot t_0\right)\right)\right)
\end{array}
Results
| Original | 0.1 |
|---|---|
| Target | 0.1 |
| Herbie | 0.7 |
Initial program 0.1
Taylor expanded in x around 0 0.7
Simplified0.7
[Start]0.7 | \[ \frac{\sin y}{y} + \left(0.5 \cdot \frac{\sin y \cdot {x}^{2}}{y} + \left(0.041666666666666664 \cdot \frac{\sin y \cdot {x}^{4}}{y} + 0.001388888888888889 \cdot \frac{\sin y \cdot {x}^{6}}{y}\right)\right)
\] |
|---|---|
rational.json-simplify-49 [=>]0.7 | \[ \frac{\sin y}{y} + \left(0.5 \cdot \color{blue}{\left({x}^{2} \cdot \frac{\sin y}{y}\right)} + \left(0.041666666666666664 \cdot \frac{\sin y \cdot {x}^{4}}{y} + 0.001388888888888889 \cdot \frac{\sin y \cdot {x}^{6}}{y}\right)\right)
\] |
rational.json-simplify-49 [=>]0.7 | \[ \frac{\sin y}{y} + \left(0.5 \cdot \left({x}^{2} \cdot \frac{\sin y}{y}\right) + \left(0.041666666666666664 \cdot \color{blue}{\left({x}^{4} \cdot \frac{\sin y}{y}\right)} + 0.001388888888888889 \cdot \frac{\sin y \cdot {x}^{6}}{y}\right)\right)
\] |
rational.json-simplify-49 [=>]0.7 | \[ \frac{\sin y}{y} + \left(0.5 \cdot \left({x}^{2} \cdot \frac{\sin y}{y}\right) + \left(0.041666666666666664 \cdot \left({x}^{4} \cdot \frac{\sin y}{y}\right) + 0.001388888888888889 \cdot \color{blue}{\left({x}^{6} \cdot \frac{\sin y}{y}\right)}\right)\right)
\] |
Final simplification0.7
| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 13120 |
| Alternative 2 | |
|---|---|
| Error | 31.5 |
| Cost | 6592 |
| Alternative 3 | |
|---|---|
| Error | 1.4 |
| Cost | 6592 |
| Alternative 4 | |
|---|---|
| Error | 32.1 |
| Cost | 64 |
herbie shell --seed 2023075
(FPCore (x y)
:name "Linear.Quaternion:$csinh from linear-1.19.1.3"
:precision binary64
:herbie-target
(/ (* (cosh x) (sin y)) y)
(* (cosh x) (/ (sin y) y)))