Challenge
Given three numbers \$a\$, \$b\$, and \$n\$, you must expand \$(a + bx)^n\$ in ascending powers of \$x\$ up to \$x^3\$.
Binomial Expansion
Note that this method is an approximation
The binomial expansion works like so:
(a + bx)^n = a^n(1 + bx/a)^n
= a^n(1 + n(bx/a) + n(n -1)(bx/a)^2/2! + n(n-1)(n-1)(bx/a)^3/3!)
Or, more readable:
$$\begin{align} (a+bx)^n &= a^n\left(1+\frac{b}{a}x\right)^n\\ &\approx a^n\left(1 + n\left(\frac{b}{a}x\right)+ \frac{n(n-1)}{2!}\left(\frac{b}{a}x\right)^2 + \frac{n(n-1)(n-2)}{3!}\left(\frac{b}{a}x\right)^3\right) \end{align}$$
Which simplifies down to an expression in the form
$$\alpha + \beta x + \gamma x^2 + \delta x^3$$
Where \$\alpha\$, \$\beta\$, \$\gamma\$ and \$\delta\$ are constants which you must calculate.
These constants should be given to at least 3 decimal places where appropriate (i.e. 1.2537 should be output instead of 1.25, but 1.2 can be output if the answer is exactly 1.2).
You must then output these four constants in a list (in order as they appear in the final equation). This list may be separated however you wish.
Input
The inputs \$a\$ and \$b\$ will be integers in the range -100 to 100 inclusive where \$a \neq 0\$.
\$n\$ will be given to one decimal place and will be in the range \$-2 \leq n \leq 2\$
Examples
a = 1, b = 6, n = -1.0
1, -6, 36, -216
a = 3, b = 2, n = 2.0
9, 12, 4, 0
a = 5, b = 4, n = 0.3
1.621, 0.389, -0.109, 0.049
Winning
The shortest code in bytes wins.
n
inx
, where as the right side has degree3
. \$\endgroup\$a
guaranteed to be non-zero? \$\endgroup\$