Question
The arithmetic-geometric mean of two positive real numbers x and y$is defined in the following way. We define two sequences a_n and g_n by a_0=x,
The arithmetic-geometric mean of two positive real numbers x and y$is defined in the following way. We define two sequences a_n and g_n by a_0=x, g_0 = y, and for n>=0, a_(n+1)= (a_n+g_n)/2, g_(n+1) =(a_n*g_n)^(1/2). It is a theorem that the sequences (a_n) and (g_n) tend to the same limit as n to infinity. This limit is called the arithmetic-geometric mean of x andy and written AGM(x, y).
Write a function `agm_sequences(x, y, k)` which returns a list `[a, g]` where `a = [a0, a1, a2, ..., ak]` is the list of the first k+1 terms of the sequence (a_n) with a_0 = x, and `g = [g0, g1, g2, ..., gk]` is the list of the first k+1 terms of the sequence (g_n) with g_0 = y.
For example, if x=y=1 then a_n = 1 and g_n = 1 for all n, so `agm_sequences(1, 1, 3)` must return [[1, 1, 1, 1], [1, 1, 1, 1]], and if x=2, y=8 then a_0=2, g_0 = 8, a_1 = 5, g_1 = 4 so `agm_sequences(2, 8, 1)` must return [2, 5], [8, 4]] (you may see `5.0` and `4.0` instead of `5` and `4` - that's OK).
def agm_sequences (x, y, k): Return the list [a, g] where a is the list of the first k+1 terms of the sequence (a_n) defined above and g is the list of the first k+1 terms of the sequence (g_n) defined above W YOUR CODE HEREStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started