Created
March 18, 2011 05:07
-
-
Save jsoffer/875648 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Recurrencia a(n+2) + 2*a(n+1) + 2*a(n) = 0, n >= 0, a(0) = 1, a(1) = 3 | |
[GP] (recuperando las raíces) | |
? polroots(x^2+2*x+2) | |
%1 = [-1.000000000000000000000000000 - 1.000000000000000000000000000*I, -1.000000000000000000000000000 + 1.000000000000000000000000000*I]~ | |
[Haskell] | |
(construyendo la recurrencia directamente) | |
> let t = 1 : 3 : zipWith (\ a b -> negate $ 2*a + 2*b) t (tail t) | |
> take 10 t | |
[1,3,-8,10,-4,-12,32,-40,16,48] | |
[Resolviendo la recurrencia] | |
a(n) = sqrt(2)^n [c1 sin (3pi/4 n) + c2 cos (3pi/4 n)] | |
sqrt(2) es el módulo de las raices conjugadas y 3pi/4 es el ángulo de una. | |
Como a(0) = 1, y sin(0) = 0, cos(0) = 1, c2 = 1. Luego, | |
a(1) = 3 = sqrt(2) [c1 sin (3pi/4) + c2 cos (3pi/4)] = sqrt(2) [c1 (sqrt(2)/2) + (-sqrt(2)/2)] = c1 - 1, y c1 = 4. | |
[Haskell] | |
> let theta = (3*pi/4) | |
> let f n = (2**(n/2)) * ((4 * (sin (theta*n)))+(cos (theta*n))) | |
> let s = map f [0..] | |
> take 10 $ map round s | |
[1,3,-8,10,-4,-12,32,-40,16,48] | |
y las sucesiones 's' y 't' coinciden. | |
> take 100 $ zipWith3 (\ a b c -> a + 2*b + 2*c) (drop 2 s) (drop 1 s) s | |
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,1,0,-1,-2,-3,-2,-4,4,30,44,45,-19] | |
Hasta a(86) se cumple la recurrencia en la sucesión resuelta por (f n), después aparece error por punto flotante en seno, coseno y raíz. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment