Блог пользователя allrounder

Автор allrounder, история, 11 лет назад, По-английски

can anyone help me in solving the recurrence of the type f(n)=f(n-1) + n*n + 3*n + 2. i could not able to figure out how to solve this recurrence.....if there is any way out solve this would be helpful

  • Проголосовать: нравится
  • +7
  • Проголосовать: не нравится

»
11 лет назад, скрыть # |
 
Проголосовать: нравится +9 Проголосовать: не нравится

Make a 4*1 matrix F[][] as f(n-1) in row 1, n^2 in row 2, 3*n in row 3 and 2 in row 4.

Now you need a 4*4 transformation matrix T[][] that when multiplied by F[][] will yield a 4*1 matrix having states corresponding to n+1. This can be created as follows:

row1 — 1 1 1 1

row2 — 0 1 2/3 1

row3 — 0 0 1 3/2

row4 — 0 0 0 1

On multiplying T and F the matrix you will get will have following states:

row1 — f(n)

row2 — (n+1)^2

row3 — 3*(n+1)

row4 — 2

Consecutive multiplication will keep on yielding corresponding states

for calculating f(k) just use T^(k-1)*F(n=1) for all k>=1.

»
11 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Note: I not sure if this is correct.

The trick is to split the formula in two parts.

let f(N) = f(N — 1) + 3N + 2

vector = [f(N), F(N — 1), N, 1]

matrix = [

[1, 3, 2, 0],

[0, 1, 0, 0],

[0, 0, 1, 1],

[0, 0, 0, 1]

]

compute matrix^N * vector

the result should be added sum(k*k) for 1 <= k <= N

I guess there is a formula for that sum.

  • »
    »
    11 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    You don't need to hold both f(N) and f(N-1) in your vector to solve this recurrence. I think there should be [1,0,3,2] in first row of your matrix instead of [1,3,2,0], and therefore, f(N-1) is useless.

»
11 лет назад, скрыть # |
 
Проголосовать: нравится +43 Проголосовать: не нравится

Recurrences of the form fn = fn - 1 + Pk(n) have a solution of the form fn = Pk + 1(n), as it's just a sum of the first n values of Pk(n). In your case the solution is a cubic polynomial, you can find its coefficients by:

  • guessing;
  • use first 4 values of fn and solve a system of linear equalities;
  • use formulas for sums like ;
  • generating functions (but they are overkill there).
»
11 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +21 Проголосовать: не нравится

As (n + 1)2 = n2 + 2n + 1, We can use 4 * 1 matrix with element F(n - 1), n2, n, 1 and the translation matrix would be a 4 * 4 matrix with the following rows:

1132

0121

0011

0001

»
11 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится +8 Проголосовать: не нравится

But i thought this is solvable with math and will get something like this : f(n) = a*n^3 + b*n^2 + c*n + d ,u can get several equation replacing them with initial value and solve them to get a,b,...d

Or

u can go something like this : f(n) will be 2*n + 3*(1+2+3+....+n) + (1^2+2^2+3^2+.....n^2) .replace with known series summation formula and solved

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

How to form transformation Matrix for f(n+1) = 36 f(n) + n (36^(n+1)) + 36^(n+1) + 36 relation ? Here in this case its {{36,36,36,1},{0,36,36,0},{0,0,36,0},{0,0,0,1}}. How it is formed ? Please explain it with example. problem link : https://www.codechef.com/problems/HLPMIL