Skip to content
DeepForgeby svx
All problems
HardOptimizationop-187

Riccati Recursion

Problem

Run n iterations of the scalar discrete Riccati recursion.

Each iteration updates P to Q + a ** 2 * P - (a * P * b) ** 2 / (R + b ** 2 * P). Return the final value of P after n iterations.

Hint

The recursion converges to the infinite-horizon value as n grows.

Test cases

case 1
in: [0,1,1,1,1,3]
expected: 1.6
case 2
in: [1,0.9,0.5,1,0.5,5]
expected: 1.7571388609021663
case 3
in: [2,1,1,1,1,0]
expected: 2
Starter codePython
def riccati_recursion(P, a, b, Q, R, n):
    # Your code here
    pass

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