{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

New Word 2007 Document (24)

# New Word 2007 Document (24) - Exercise write an M file...

This preview shows page 1. Sign up to view the full content.

Graphical Method: Suppose we want to know if there is a solution to: cos ( x ) = x If the solution is unique, and what that solution is. This is not an algebraic equation, and there is little hope of forming an explicit expression for the solution. Since we can't solve this equation exactly, it's worth knowing whether there is anything we can say about it. In fact, if there is a solution x* to the equation, we can probably find a computer representable number x which approximately satisfies the equation (has low residual error) and which is close to x* (has a low approximation error). Exercise 1 : Plot the functions cos(x) and x together in the same graph. What does your graph suggest about the solubility of our sample problem?
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Exercise : write an M file cosy.m that defines the function f(x) = cos ( x ) - x (Remember how, in lab #2, we talked about how to set up a function? Do not spend time trying to make this function fancy.) function A = name ( input ) result = . .. Note that MATLAB has a special command for plotting functions that's easier than what we normally do. For instance, we could plot cosy from -4.0 to 4.0 by typing: fplot ( 'cosy', [ -4.0, 4.0 ] ) Note the quotes around the function name, and the square brackets that make the x limits a vector. Now would be a good time to try the fplot command out, and see what the cosy function looks like. Can you add an x axis using hold on and the appropriate plot command?...
View Full Document

{[ snackBarMessage ]}