next up previous
Next: 1. The method of Up: proj2 Previous: proj2

0. Polynomials in MATLAB or Octave

Polynomials are represented by their coefficient vectors. For example, the cubic polynomial $3.3 x^3 - 2.23 x^2 - 5.1 x + 9.8$ is entered typing $c = [3.3 ~~ -2.23 ~~ -5.1 ~~ 9.8]$ at the prompt. With $y = {\bf polyval}(c,x)$, we evaluate the polynomial at some point or vector $x$. After typing $r = {\bf roots}(c)$, the vector $r$ will contain approximations for the roots of the polynomial. The complement to the roots command is poly, e.g, $c = {\bf poly}(r)$ returns the coefficient vector of the monic polynomial which has its roots in $r$.

We can group commands into .m files, defining functions. The name of the function should match the file name. For this project, we need the function ``weierstrass'', with its definition in the file ``weierstrass.m'' (download it from the class web site). If the path is set correctly (do help path otherwise to see how to set the search path), then you can call this function just as a regular command.



Jan Verschelde 2003-09-16