My goal is to create a C++ program that computes a geometric sequence's first three terms. What is provided is the sum of the first three terms and their multiplication.
It is assumed that the answers have to be real.
I get
b = p¹ᐟ³
and
a² + (b-s)a + b² = 0
Let
abcbe real numbers that are the first three terms of a geometric series. Assume none of them are 0. Otherwise, the "series" is degenerate.Let ratio
rbe a real number that is the ratio between successive terms. Thus,Solving equations (1) and (2) for
aandcgives:Given the product
p, equations (3) and (4) let us findbdirectly:Thus,
bis the cube root of the product.[Note: There are only two fractional exponents used in this answer: 1/3 and 2/3. If the tiny Unicode exponents are hard to read, you may want to zoom in.]
Setting equation (1) equal to equation (2) gives another equation for
c:Turning to sum
s, we have:Mulitplying both sides by
a, and then subtractingasfrom both sides, yields:Equation (7) can be solved by the familiar quadratic formula. For the quadratic equation
0 = Ax² + Bx + C, where upper-case letters are used to distinguish from the lower-case ones above, we can map equation (7) as follows:Ais1Bisp¹ᐟ³-sCisp²ᐟ³xisaThe discriminant,
B² - 4AC, determines the number and type of the roots.For equation (7), we have
Equation (9) shows that the discriminant vanishes in two cases:
s = -bs = 3bA program designed to find
a,b, andcfor the geometric series of this question must analyze the discriminant, and present solutions accordingly.For the real number solutions that exist:
abcThe factors of equation (8) provide a good indication of whether round-off error in a computer computation is affecting the analysis of the discriminant. If either factor is "close" to zero, then the sign of the discriminant may not be computed correctly. In addition, a discriminant that should be valued at 0, may be computed as some "small" value, either positive or negative.