Due 3 November

The goal of this assignment is to give you more programming experience with the MIPS instruction set and to expose you to issues of floating point precision.

Consider the series E_{N}(x) = 1 + x + x^{2} + x^{3} + ... + x^{N}. For values of -1 < x < 1 this series will produce the same value as E_{c}(x) = (1-x^{N+1})/(1-x) with exact arithmetic.

Write a function float pow(float x, int N) that computes x

^{N}by repeated multiplication using single-precision floating-point arithmetic.Write a function Ec that takes a single precision floating point number x and an integer N as arguments and evaluates (1-x

^{N+1})/(1-x) and returns the result. Call your pow function to evaluate x^{N}in this calculation.Write a function Efwd that takes the same arguments and evaluates the series forward. That is, in the natural order starting with 1.

Write a function Erev that takes the same arguments and evaluates the series backward. That is, starting from the last term x

^{N}and working back toward 1.Write a main function that calls each of your functions for x=0.99 and N = 100. Print the result of each function and the difference Efwd – Ec and Erev – Ec.

Turn in your program and the numbers you printed in step 5 along with a short paragraph explaining the differences among the results.

The register usage conventions for the floating point registers are:

$f0 - $f2 floating point subprogram return value $f4 - $f10 temporaries - not preserved across calls $f12 - $f14 the first 2 floating point parameters - not preserved across calls $f16 - $f18 temporaries - not preserved across calls $f20 - $f30 saved values - preserved across calls