PDA

View Full Version : Recursie Algorithms. Is my solution ok?


ptex
Apr28-04, 10:32 PM
This is the question I must solve;
Solve the given recurrence relation for the given inital conditions.
(This means give a formula in terms of n, not in terms of previous entries)
an = 7an-1 - 12an-2
a0 = 3 a1 = 10
Now I am not sure what that means but I think this will solve the question

let me know if I am not even close;
Input = n
Output = X(n)

procdure find(n)
if n = 3 or n = 10 then
return (n)
return(find(n-1)+find(n-2))
end find(n)

jamesrc
Apr28-04, 11:20 PM
I'm fairly certain that what they are looking for is a single equation for a as a function of n. Simple example:

Given: an = an-1 + 1
and a0 = 11

Then:

an = 11+n

ptex
Apr29-04, 12:05 AM
Solve the given recurrence relation for the given inital conditions.
(This means give a formula in terms of n, not in terms of previous entries)
an = 7an-1 - 12an-2
a0 = 3 a1 = 10

So;
a2 = 7a2-1 - 12a2-2
a2 = 7a1 - 12a0
a2 = 7(10) - 12(3)
a2 = 70 - 36
a2 = 34?

gnome
Apr29-04, 12:21 AM
That was not a solution.

This is a solution:
http://www.physicsforums.com/showthread.php?t=22418

You have to find an exact algebraic (non-recursive) equation to represent the recurrence relation.

ptex
Apr29-04, 12:34 AM
Oh not that again I thought I was done with that. Ok I know what to do thanks again.

ptex
Apr29-04, 09:14 AM
I come up with all mixed fractions when I get a using the same method as I did on that problem? So that does not work.

gnome
Apr29-04, 10:43 AM
It works. You need to work on your algebra.