# Question about solving recurrences/difference equations

i want to know if there's any standard symbolic method of solving recurrences often found in the analysis of algorithms. many of these recurrences are readily solved by the master theorem. let's say we don't want to use that (for whatever reason) and we don't want to draw recursion trees.

let's take for example:
T(n) = 2T(n/2) + n

how exactly would we put this in difference equation form? something like T[i+1] = kT + n? k is some constant (basically some function on the 2) after we do that it is straightforward (i think) to use some symbolic differentiation and then solve the recurrence. We should be getting nlogn (log base 2) as the solution to this recurrence. but i don't think i'm writing down the actual difference equation correctly.

## Answers and Replies

Let n=2i

T(n) = 2T(n/2) + n will gives T(2i) = 2T(i) + 2i.

How am I going to expressed this as T[i+1] = kT + n ? For T(n) = 2T(n/2) + n you can set $n=2^k$
Then you have $T(2^k) = 2T(2^{k-1}) + 2^k$. I don't know if that helps.

Wow that's good idea Edgardo. So what do we do next to solve T(n) = 2T(n/2) + n ?

May be we need to use z-transform or Fourier transform directly.

i want to know if there's any standard symbolic method of solving recurrences often found in the analysis of algorithms. many of these recurrences are readily solved by the master theorem. let's say we don't want to use that (for whatever reason) and we don't want to draw recursion trees.

let's take for example:
T(n) = 2T(n/2) + n

how exactly would we put this in difference equation form? something like T[i+1] = kT + n? k is some constant (basically some function on the 2) after we do that it is straightforward (i think) to use some symbolic differentiation and then solve the recurrence. We should be getting nlogn (log base 2) as the solution to this recurrence. but i don't think i'm writing down the actual difference equation correctly.

Let n=2m.
T(n) = 2T(n/2) + n will gives T(2m) = 2T(m) + 2n.

I have just come to know about WolframAlpha at Sticky: WolframAlpha guide on electrical engineering forum.
Solving the http://www09.wolframalpha.com/input/?i=f(2*m)=2*f(m)+2*m,+f(1)=1", and simplify (assuming T(1)=1 )

T(2n) = 2nlog2n + 4n.

What method does the WolframAlpha engine used to get the answer?

Last edited by a moderator:
{"ft_lang_label":"__label__en","ft_lang_prob":0.95384645,"math_prob":0.99383837,"size":1221,"snap":"2021-04-2021-17","text_gpt3_token_len":302,"char_repetition_ratio":0.1240756,"word_repetition_ratio":0.7162791,"special_character_ratio":0.24570024,"punctuation_ratio":0.06465517,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9998141,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-04-17T21:44:38Z\",\"WARC-Record-ID\":\"<urn:uuid:add0ee4e-cef8-42a7-a986-2ca7cbec6618>\",\"Content-Length\":\"63743\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:48011352-8733-4dad-843f-0e54a01563ed>\",\"WARC-Concurrent-To\":\"<urn:uuid:26848dd1-e024-470a-976c-28b95e036385>\",\"WARC-IP-Address\":\"104.26.15.132\",\"WARC-Target-URI\":\"https://www.physicsforums.com/threads/question-about-solving-recurrences-difference-equations.316610/\",\"WARC-Payload-Digest\":\"sha1:MROVEGILIQPM6S4WQAOMWN3C55MQTKCQ\",\"WARC-Block-Digest\":\"sha1:PID7S3MWCNCUJW2STIBTGCIJZ6NLQ6SW\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-17/CC-MAIN-2021-17_segments_1618038464045.54_warc_CC-MAIN-20210417192821-20210417222821-00429.warc.gz\"}"}