Post History
Python 3, 26 bytes lambda n:(n+(n*n+4)**.5)/2 We can actually just compute this directly, although I could have taken an alternate path considering the fact that, given $R_n$ as the ratio betwe...
#3: Post edited
- # Python 3, 26 bytes
- ```python
- lambda n:(n+(n*n+4)**.5)/2
- ```
We can actually just compute this directly, although I could have taken an alternate path considering the fact that, given $R_n$ as the ratio between any two terms in the $n$-fibonacci sequence defined above (where $n\in\mathbb Z$), then$$R_{-n}=R_n-n$$or equivalently,$$R_n=R_{-n}+n$$although it seems like it would have cost me an additional <s>21</s> 19 bytes:- ```python
f=lambda n:n+f(-n)if n<0else(n+(n*n+4)**.5)/2- ```
<sup>-2 bytes by rearranging the terms<sup>- ---
- Explanation of the above statement:
- >We can write $G(x)=F_n(x)$ for arbitrary $n\in\mathbb Z$. Now, we can write $G(x)$ in recurrence relation form as$$\lambda^2-n\lambda-1=0$$The solution to this equation (let'_s call this $\lambda_+$),$$\lambda_+=\dfrac{n+\sqrt{n^2+4}}2$$gives the ratio of one term to the next as $x\to\infty$, because $G$ does not depend on parameter $n$.
- >
- >Now, if we let $G(x)=F_{-n}(x)$, the recurrence relation now becomes$$\lambda^2+n\lambda-1=0$$and now our ratio between terms is$$\lambda_-=\dfrac{-n+\sqrt{n^2+4}}2$$Finally, we get $\lambda_+-\lambda_-=n$, or equivalently$$\lambda_+=\lambda_-+n$$$$\lambda_-=\lambda_+-n$$
- # Python 3, 26 bytes
- ```python
- lambda n:(n+(n*n+4)**.5)/2
- ```
- We can actually just compute this directly, although I could have taken an alternate path considering the fact that, given $R_n$ as the ratio between any two terms in the $n$-fibonacci sequence defined above (where $n\in\mathbb Z$), then$$R_{-n}=R_n-n$$or equivalently,$$R_n=R_{-n}+n$$although it seems like it would have cost me an additional <s>21</s> <s>19</s> 17 bytes:
- ```python
- f=lambda n:[(n+(n*n+4)**.5)/2,n+f(-n)][n<0]
- ```
- <sup>-2 bytes by rearranging the terms</sup><br><sup>-2 bytes by using list indices</sup>
- ---
- Explanation of the above statement:
- >We can write $G(x)=F_n(x)$ for arbitrary $n\in\mathbb Z$. Now, we can write $G(x)$ in recurrence relation form as$$\lambda^2-n\lambda-1=0$$The solution to this equation (let'_s call this $\lambda_+$),$$\lambda_+=\dfrac{n+\sqrt{n^2+4}}2$$gives the ratio of one term to the next as $x\to\infty$, because $G$ does not depend on parameter $n$.
- >
- >Now, if we let $G(x)=F_{-n}(x)$, the recurrence relation now becomes$$\lambda^2+n\lambda-1=0$$and now our ratio between terms is$$\lambda_-=\dfrac{-n+\sqrt{n^2+4}}2$$Finally, we get $\lambda_+-\lambda_-=n$, or equivalently$$\lambda_+=\lambda_-+n$$$$\lambda_-=\lambda_+-n$$
#2: Post edited
- # Python 3, 26 bytes
- ```python
- lambda n:(n+(n*n+4)**.5)/2
- ```
We can actually just compute this directly, although I could have taken an alternate path considering the fact that, given $R_n$ as the ratio between any two terms in the $n$-fibonacci sequence defined above (where $n\in\mathbb Z$), then$$R_{-n}=R_n-n$$or equivalently,$$R_n=R_{-n}+n$$although it seems like it would have cost me an additional 21 bytes:- ```python
f=lambda n:(n+(n*n+4)**.5)/2if n>=0else f(-n)+n- ```
- ---
- Explanation of the above statement:
- >We can write $G(x)=F_n(x)$ for arbitrary $n\in\mathbb Z$. Now, we can write $G(x)$ in recurrence relation form as$$\lambda^2-n\lambda-1=0$$The solution to this equation (let'_s call this $\lambda_+$),$$\lambda_+=\dfrac{n+\sqrt{n^2+4}}2$$gives the ratio of one term to the next as $x\to\infty$, because $G$ does not depend on parameter $n$.
- >
- >Now, if we let $G(x)=F_{-n}(x)$, the recurrence relation now becomes$$\lambda^2+n\lambda-1=0$$and now our ratio between terms is$$\lambda_-=\dfrac{-n+\sqrt{n^2+4}}2$$Finally, we get $\lambda_+-\lambda_-=n$, or equivalently$$\lambda_+=\lambda_-+n$$$$\lambda_-=\lambda_+-n$$
- # Python 3, 26 bytes
- ```python
- lambda n:(n+(n*n+4)**.5)/2
- ```
- We can actually just compute this directly, although I could have taken an alternate path considering the fact that, given $R_n$ as the ratio between any two terms in the $n$-fibonacci sequence defined above (where $n\in\mathbb Z$), then$$R_{-n}=R_n-n$$or equivalently,$$R_n=R_{-n}+n$$although it seems like it would have cost me an additional <s>21</s> 19 bytes:
- ```python
- f=lambda n:n+f(-n)if n<0else(n+(n*n+4)**.5)/2
- ```
- <sup>-2 bytes by rearranging the terms<sup>
- ---
- Explanation of the above statement:
- >We can write $G(x)=F_n(x)$ for arbitrary $n\in\mathbb Z$. Now, we can write $G(x)$ in recurrence relation form as$$\lambda^2-n\lambda-1=0$$The solution to this equation (let'_s call this $\lambda_+$),$$\lambda_+=\dfrac{n+\sqrt{n^2+4}}2$$gives the ratio of one term to the next as $x\to\infty$, because $G$ does not depend on parameter $n$.
- >
- >Now, if we let $G(x)=F_{-n}(x)$, the recurrence relation now becomes$$\lambda^2+n\lambda-1=0$$and now our ratio between terms is$$\lambda_-=\dfrac{-n+\sqrt{n^2+4}}2$$Finally, we get $\lambda_+-\lambda_-=n$, or equivalently$$\lambda_+=\lambda_-+n$$$$\lambda_-=\lambda_+-n$$
#1: Initial revision
# Python 3, 26 bytes
```python
lambda n:(n+(n*n+4)**.5)/2
```
We can actually just compute this directly, although I could have taken an alternate path considering the fact that, given $R_n$ as the ratio between any two terms in the $n$-fibonacci sequence defined above (where $n\in\mathbb Z$), then$$R_{-n}=R_n-n$$or equivalently,$$R_n=R_{-n}+n$$although it seems like it would have cost me an additional 21 bytes:
```python
f=lambda n:(n+(n*n+4)**.5)/2if n>=0else f(-n)+n
```
---
Explanation of the above statement:
>We can write $G(x)=F_n(x)$ for arbitrary $n\in\mathbb Z$. Now, we can write $G(x)$ in recurrence relation form as$$\lambda^2-n\lambda-1=0$$The solution to this equation (let'_s call this $\lambda_+$),$$\lambda_+=\dfrac{n+\sqrt{n^2+4}}2$$gives the ratio of one term to the next as $x\to\infty$, because $G$ does not depend on parameter $n$.
>
>Now, if we let $G(x)=F_{-n}(x)$, the recurrence relation now becomes$$\lambda^2+n\lambda-1=0$$and now our ratio between terms is$$\lambda_-=\dfrac{-n+\sqrt{n^2+4}}2$$Finally, we get $\lambda_+-\lambda_-=n$, or equivalently$$\lambda_+=\lambda_-+n$$$$\lambda_-=\lambda_+-n$$
