Matematik och Datavetenskap, Chalmers Tekniska Högskola och Göteborgs Universitet
Theory: Read Ch 25 The Integral.
Exercises: Do the following exercises:
basic: 25.1, 25.2, 25.3, 25.7, 25.8, 25.9
advanced: 25.4, 25.10, 25.11
Topics: Matlab's online documentation. Function subprograms. Matlab commands: function, plot, fplot, feval. How to document your own matlab programs.
Reading: Read about function subprograms in PE-S. Make yourself acquainted with matlab's online documentation: help, helpwin, helpdesk.
Try matlab's editor. You may like it better than emacs. To open the file funk1.m you type "edit funk1" in the matlab command window.
Exercises:
1. The matlab function funk1.m
computes y=x^2-2 and the function Dfunk1.m computes the derivative of this
function, i.e., y=2x. Open these files in the matlab editor (or in
emacs) and read them. Test them by computing various function values,
for example:
>> a=3
>> funk1(3)
>> funk1(a)
>> funk1(a+3)
>> z=funk1(3*a)
>> Dfunk1(3*a)
>> x=0:.1:2
>> x=x'
>> funk1(x)
Plot the functions in two ways:
* use matlab's program fplot (read the documentation: help fplot);
* generate a vector of x-values and use matlab's program plot (read the
documentation: help colon, help plot).
Do the same with some other functions. Use new function names, for example, funk2.m, Dfunk2.m.
2. Rewrite your bisection, regula falsi, fixed point iteration, and Newton iteration programs as function subroutines. Use bisec.m as a model for writing such a program and how document it. Build your programs on the following program heads: fixpoint.m, regula_falsi.m newton.m.
Type "help bisec" to see how the documentation works.
Test your programs on some well chosen test
equations.
Goal: After week 1 each student should have the following programs: bisec.m, fixpoint.m, newton.m (and perhaps also regula_falsi.m), written according to the specifications in the given program heads.
/stig