I want to find a base and step case for my definition of the multiplication of polynomials that only uses lists.
Whenever I try to make a definition I either use some input (which shouldn't be done) or I access some elements that are not the first element.
To give a clearer image, for example, the polynomial $3x^2 + 9x + 1$ is represented as $[1, 9, 3]$
So at the end, if I used my definition $[1, 9, 3]$ and $[1, 2]$ should give $[1, 11, 21, 6]$ which is equivalent to $6x^3+ 21x^2 + 11x + 1$ and the same for any two lists (polynomials)
Polynomials addition example
Base Cases f: $$f([],[]) = []$$ $$f(s:l,[]) = s :f(l,[])$$
$$f([],s:l) = s:f([],l)$$
Step case f:
$$f(s_a:l_a, s_b:l_b) = (s_a+s_b):f(l_a,l_b)$$
$[]$ is the empty list
any help is appreciated
Given two lists (coefficient sequencies) $[a_0,...,a_n]$ and $[b_0,...,b_m]$, you are looking for the list $[c_0,...,c_{n+m}]$, which describes the product of the polynomials given by the initial lists. I think what you are looking for can be derived like this:
\begin{align} \left(\sum_{i=0}^n a_nx^n\right)\cdot\left(\sum_{j=0}^m b_nx^n\right) &= \sum_{i=0}^n\sum_{j=0}^n x^{i+j} a_i b_j\\ &= \sum_{k=0}^{n+m}x^k\underbrace{\sum_{i=0}^k a_ib_{k-i}}_{c_k}. \end{align}
So in the end, the list $[c_0,...,c_k]$ is given by
$$c_k=\sum_{i=0}^k a_ib_{k-i}.$$