There is a sequence. The first integer is positive, the second integer is negative. An alternating part is a part that switches between positive and negative (0 is not included)
(a) I have a complete answer to this part
(b) What second term should be chosen to get the longest possible switching between positive and negative
For b, I wrote an entire proof as to why, assuming a is the positive first integer, b is the integer closest to -0.618a. However, I was testing cases today, and I found that a=43 is an exception to this. 0.618 multiplied by a would be -26.57 something, which is about -27. However, the number to make the sequence the longest is actually -26.
Could anyone give me a hint as to why this happened?
You have posed an interesting question here, but have not shown how you got to where you are. If you look at a previous link of mine, you'll find a general solution to the problem $f_n=f_{n-1}+f_{n-2}$ with arbitrary initial conditions, say $f_0$ and $f_1$, or $a$ and $b$ in your notation. It easy to show that your solution can be expressed as
$$ f_n=\bigg(b-\frac{a}{2}\bigg)F_n+\frac{a}{2}L_n $$
where $F_n$ and $L_n$ are the Fibonacci and Lucas numbers, respectively. Here you can see that the Fibonacci terms are always negative while the Lucas terms are all positive (for $a>0$ and $b<0$).
This can also be expressed as
$$ f_n=bF_n+aF_{n-1} $$
Now, we can express the Fibonacci number with the Binet formula as follows
$$ F_n=\frac{\varphi^n-\psi^n}{\varphi-\psi} $$
where $\varphi$ is the golden ratio and $\psi=1-\varphi$. Thus
$$ f_n=\frac{b(\varphi^n-\psi^n)+a(\varphi^{n-1}-\psi^{n-1})}{\varphi-\psi} $$
Almost there. For large $n$ we have $\varphi^n>>\psi^n$ and the above becomes
$$ f_n\approx\frac{\varphi^{n-1}}{\varphi-\psi}(b\varphi+a) $$
From this we can see that if $\ b\varphi+a=0$, $\ f_n\to 0$ for large $n$. In fact, I tried this numerically, and it seems to oscillate forever. Now, if $\ b\varphi+a<0$, then the negative terms dominate and the series goes negative. Likewise, if $\ b\varphi+a>0$, then the series goes positive.
To sum up, the point is the criterion you found, i.e., $\ b\varphi+a=0$ for determining the value of $b$ that gives the longest oscillation, is only approximate. However, if you allow non-integer values of $b=-a/\varphi$, then you can oscillate forever.