# Time complexity of sum of $2^n$ values of polynomials

First a simpler question: let $q_{1}(k),\dots,q_{n}(k)$ be $n$ polynomials of degree smaller or equal to $n$.

Let $f(n): \mathbb{N} \rightarrow \mathbb{N}$ defined by $f(n) = \sum_{i=1}^{n}q_{i}(n)$.

Assume also $0\leq f_{i}(n)\leq n$.

What is the time complexity as a function of the input size for calculating $f(n)$ by the above definition?

I'm not quite sure how to approach this, but my current guess is as follows:

I know evaluating a polynomial is $O(n)$ time, where $n$ is the degree of the polynomial.

I know adding two integers is $O(n)$ where $n$ is the number of bits of the larger integer.

Every try to calculate this seems to get stuck, as i'm getting confused between the time complexity by input size and by actual size (the number itself).

after understanding this, i would like to understand the calculation for time complexity as a function of the input size for a similar problem:

Let $q_{1}(k),\dots,q_{2^n}(k)$ be $2^n$ polynomials of degree smaller or equal to $2^n$.

Let $f(n): \mathbb{N} \rightarrow \mathbb{N}$ defined by $f(n) = \sum_{i=1}^{2^n}q_{i}(n)$.

Assume also $0\leq f_{i}(n)\leq 2^n$.

Thanks for any help, i hope this is well enough defined.

It takes $O(n^2)$ time. A polynomial can be represented as the list of its coefficients. Since it has degree $n$, it can be represented by a list of $n+1$ numbers. Now adding polynomials can be done by adding their corresponding coefficients. There are $n+1$ coefficients of $f(n)$, and each takes $O(n)$ time to compute (you have to add up $n$ numbers), for a total of $O(n \times (n+1)) = O(n^2)$.
There's no possibility to do anything faster, as the input contains $n(n+1)$ numbers, and any correct solution will have to read all the input. It takes $\Theta(n^2)$ time even to read the input, let alone to do any processing, so any correct algorithm will have to take time at least $\Theta(n^2)$.
{"ft_lang_label":"__label__en","ft_lang_prob":0.8769319,"math_prob":0.99997437,"size":1177,"snap":"2023-40-2023-50","text_gpt3_token_len":357,"char_repetition_ratio":0.09889173,"word_repetition_ratio":0.1521739,"special_character_ratio":0.30416313,"punctuation_ratio":0.096525095,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":1.0000095,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-10-01T21:44:02Z\",\"WARC-Record-ID\":\"<urn:uuid:80407a7a-1a8d-4fe5-9eb7-664ed933d056>\",\"Content-Length\":\"154106\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:66496515-e336-41aa-8c44-9d75e1186a9b>\",\"WARC-Concurrent-To\":\"<urn:uuid:b8f7a36b-4e4c-4de6-be7e-e23aa83511f2>\",\"WARC-IP-Address\":\"104.18.10.86\",\"WARC-Target-URI\":\"https://cs.stackexchange.com/questions/92634/time-complexity-of-sum-of-2n-values-of-polynomials\",\"WARC-Payload-Digest\":\"sha1:OH4PN6JRYBEQGUKCWJMS45AEK7Z3EGG7\",\"WARC-Block-Digest\":\"sha1:CCGJ4NXSGUYYM7JHNOVYR3GLHWCCFS5Y\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233510941.58_warc_CC-MAIN-20231001205332-20231001235332-00518.warc.gz\"}"}