You will turn three reduction formulas into code. Each one builds a value from a smaller case, with a loop that starts from the easy case.
The idea. A reduction formula gives I n I_n I n from I n − 1 I_{n-1} I n − 1 or I n − 2 I_{n-2} I n − 2 . Start with the easy cases and apply the formula one step at a time.
Wallis: W n = n − 1 n W n − 2 W_n = \dfrac{n - 1}{n}W_{n-2} W n = n n − 1 W n − 2 with W 0 = π 2 W_0 = \dfrac{\pi}{2} W 0 = 2 π and W 1 = 1 W_1 = 1 W 1 = 1 . Powers times e x e^x e x : I n ( x ) = x n e x − n I n − 1 ( x ) I_n(x) = x^n e^x - n\,I_{n-1}(x) I n ( x ) = x n e x − n I n − 1 ( x ) with I 0 ( x ) = e x I_0(x) = e^x I 0 ( x ) = e x . Tangent: T n = 1 n − 1 − T n − 2 T_n = \dfrac{1}{n - 1} - T_{n-2} T n = n − 1 1 − T n − 2 with T 0 = π 4 T_0 = \dfrac{\pi}{4} T 0 = 4 π and T 1 = 1 2 ln 2 T_1 = \dfrac{1}{2}\ln 2 T 1 = 2 1 ln 2 . Your tasks.
Finish wallis(n). Return W n W_n W n . Finish xexp(n, x). Return I n ( x ) I_n(x) I n ( x ) , with the constant taken as 0 0 0 . Finish tangent_integral(n). Return T n T_n T n . Run it first, just as it is. The checker at the end prints FAIL for each task. Then do the tasks one at a time, and run the program again after each one. A Hint appears under every check that still fails.
When every line says PASS, call wallis(12). Is it larger or smaller than wallis(10), and by what factor? Compare with 11 12 \dfrac{11}{12} 12 11 .