Disclaimer: Math noob here.
I have this arithmetic-geometric sequence $u(k)=(a-dk)r^{k-1}$
and summation $s(n)=\sum_{k=1}^n u(k)$
Using Wikipedia (sources 1, 2, and 3), I have solved for the closed-form function of $s(n)$ and got the following equation: $$s(n)=\frac{a+(nd-a)r^n}{1-r}-\frac{d(1-r^n)}{(1-r)^2}$$
The following constraints apply:
- $1\le{a}\le1000$
- $1\le{d}\le10$
- ${d}\le{a}$
- $3000\le{n}\le4000$
- $1\le{x}\le10^{15}$
Given this equation and these constraints, is it possible to solve for $r$ given $s(n)=-x$ ? And if yes, how?
Context
I'm trying to solve hacker rank's version of Euler Problem 235: An Arithmetic Geometric sequence. I have used the bisection method to find $r$ and successfully solved 10 out of 20 of the test cases. However, the failed test cases only return "wrong answer" without any feedback. Thus, I'm trying to find another solution to solve for $r$.
Resources
- https://en.wikipedia.org/wiki/Arithmetic_progression
- https://en.wikipedia.org/wiki/Geometric_progression
- https://en.wikipedia.org/wiki/Arithmetico%E2%80%93geometric_sequence
- https://en.wikipedia.org/wiki/Bisection_method
- https://euler.stephan-brumme.com/235/
- https://www.hackerrank.com/contests/projecteuler/challenges/euler235/problem
- https://blog.dreamshire.com/project-euler-problem-235-solution/
- MathJax basic tutorial and quick reference