Skip to content
DeepForgeby svx
All problems
EasyCalculusca-017

Fixed-Point Iteration Step

Problem

Apply n steps of the fixed-point iteration x_{k+1} = g(x_k), starting from x, where g(x) = sum(coeffs[i] * x^i).

Return the resulting value; with n = 0 return x unchanged.

Hint

Repeatedly overwrite x with g(x); the coefficient array defines g.

Test cases

case 1
in: [[0,0.5],4,3]
expected: 0.5
case 2
in: [[0,0,1],0.5,2]
expected: 0.0625
case 3
in: [[0,0,1],3,0]
expected: 3
case 4
in: [[0.25],8,2]
expected: 0.25
Starter codePython
def fixed_point_step(coeffs, x, n=1):
    # Your code here
    pass

4 test cases · run your code against them in the editor