r
A(r) = 4r
r
r
r2
r
2
r
A
A
4(r + r)2
4r2
4(2r + r) r
8r r
A
2
r
r
+, , , /,
(2
3 (5
4) 4/5 =
4
(2
5
1/2/3/4 = (1/2)/3)/4
2+3 2
log2 3 3
3 2/3 2 3 23 21/3
3(5
4)
(5);
( 3),
(5.
);
( 10);
space holder
2
c = (5/9)(f
32)
c
f
R
x=
b/2
f (x) = x2 + bx + c
[L,
%AveStrategy.m%
% Design a program to maximize the chances of winning the most money.
% Input: User is prompted for rolling a die.
% Output: The number representing the upturned die where the player makes the
most money.
%Part b)
Sum1=0; %assgin initial s
chroderbisection.m%
% Implement a MATLAB function by using the Schroder iteration for multiple roots
% Input:
% a: Beginning of interval [a, b]
% b: End of interval [a, b]
% f: function handle f(x) to find a zero for
% fp: function handle f'(x)
% fpp: fun
%RollADie%
% Design a program to maximize the chances of winning the most money.
% Input: User is prompted for rolling a die.
% Output: The number representing the upturned die where the player employing
the strategy in question stops
minFirstRoll1=1; %#1
MATH 98: INTRODUCTION TO
MATLAB PROGRAMMING
B3A EVANS
TH 2-330 F
F 3-430
Instructor: Kamin Kahrizi
E-mail: kamink@berkeley.edu
Office Hours: Tu 11-12 B3A Evans (only by appointment
24 hours in advance)
Fall 2014
The Logical Operators
The logical operator
MATH 98: INTRODUCTION TO
MATLAB PROGRAMMING
B3A EVANS, TH 2-330 F 3-430
SECTION 11, CCN: 54089
Instructor: Kamin Kahrizi
E-mail: kamink@berkeley.edu
Office Hours: Tu 11-12, by appointment
Fall 2014
Organizing and Debugging Code
Often, when writing code, i
MATH 98: INTRODUCTION TO
MATLAB PROGRAMMING
B3A EVANS, TH 2-330 F 3-430
Instructor: Kamin Kahrizi
E-mail: kamink@berkeley.edu
Office Hours: Tu 11-12, by appointment
Fall 2014
Administrivia
NO
CLASS
NO
CLASS
Last Day
of Class
Fall 2014
Exercise 1
Given tw
MATH 98: INTRODUCTION TO
MATLAB PROGRAMMING
B3A EVANS, TH 2-330 F 3-430
SECTION 11, CCN: 54089
Instructor: Kamin Kahrizi
E-mail: kamink@berkeley.edu
Office Hours: Tu 11-12, by appointment
Fall 2014
More Graphing
Try the following lines in a script.
subpl
MATH 98: INTRODUCTION TO
MATLAB PROGRAMMING
B3A EVANS, TH 2-330 F 3-430
SECTION 11, CCN: 54089
Instructor: Kamin Kahrizi
E-mail: kamink@berkeley.edu
Office Hours: Tu 11-12, by appointment
Fall 2014
Reminders
No class on 10/9, 10/16
Last class 10/17
Fall
MATH 98: INTRODUCTION TO
MATLAB PROGRAMMING
B3A EVANS, TH 2-330 F 3-430
SECTION 11, CCN: 54089
Instructor: Kamin Kahrizi
E-mail: kamink@berkeley.edu
Office Hours: Tu 11-12, by appointment
Fall 2014
Pop Quiz
On a sheet of paper, write down the answers to
MATH 98: INTRODUCTION TO
MATLAB PROGRAMMING
B3A EVANS, TH 2-330 F 3-430
SECTION 11, CCN: 54089
Instructor: Kamin Kahrizi
E-mail: kamink@berkeley.edu
Office Hours: Tu 11-12, by appointment
Fall 2014
Pop Quiz #2
On a sheet of paper, write down the answers
Lecture 1: Introduction to MATLAB
Cinna (see-na) Wu
cinnawu@math.berkeley.edu
Modied from slides by Ryan Hynd
Department of Mathematics
University of California, Berkeley
Math 98 : Introduction to MATLAB programming
Announcements
Announcements
syllabus/cl
A magic square is a square array of positive integers whose columns, rows, and diagonals
sum to the same number. For example
1 14 14 4
8 1 6
3 5 7 , 11 7 6 9
8 10 10 5
4 9 2
13 2 3 15
Note that all entries can be equal. For example
1 1
1 1
Write a MATL
Math98 HW5: due Oct. 6
Write a MATLAB function roman2num(s) that converts a Roman numeral 1 to number. The numeral
is contained in the string s and is capitalized. You can assume that s is a valid input without checking it.
The basic building blocks are a
Lecture 2: Programming Basics in MATLAB
Cinna (see-na) Wu
cinnawu@math.berkeley.edu
Modied from slides by Ryan Hynd
Department of Mathematics
University of California, Berkeley
Math 98 : Introduction to MATLAB programming
Announcements
Announcements
HW 1
Lecture 3: Manipulating Arrays
Cinna (see-na) Wu
cinnawu@math.berkeley.edu
Modied from slides by Ryan Hynd
Department of Mathematics
University of California, Berkeley
Math 98 Introduction to MATLAB programming
Arrays are important!
Three fundamental cont
Lecture 4: More on manipulating arrays
Cinna (see-na) Wu
cinnawu@math.berkeley.edu
Modied from slides by Ryan Hynd
Department of Mathematics
University of California, Berkeley
Math 98 Introduction to MATLAB programming
Announcements
HW 2 Posted:
http:/mat
Lecture 5: Functions in MATLAB
Department of Mathematics
University of California, Berkeley
Math 98 Introduction to MATLAB programming
Announcements
HW2 http:/math.berkeley.edu/ cinnawu/HW2.pdf is due
Thursday in class
Creating functions
Important feature
Lecture 6: More on Functions in MATLAB
Department of Mathematics
University of California, Berkeley
Math 98 Introduction to MATLAB programming
Announcements
HW1 Solutions are up
http:/math.berkeley.edu/ cinnawu/HW2sol.m.
HW3 is posted http:/math.berkeley.
Lecture 7: Basic Plotting in MATLAB
Department of Mathematics
University of California, Berkeley
Math 98 Introduction to MATLAB programming
Iterates of Newtons method
Iterates of approximations to
5
5
n
By Newtons method, we have xn+1 = x2 + 2xn , x0 > 0
Lecture 8: More on Plotting in MATLAB
Department of Mathematics
University of California, Berkeley
Math 98 Introduction to MATLAB programming
Announcements
HW2 Solutions are up
HW4 is posted.
Plotting curves in 3d
plot3
We saw last time how plot parametri
Lecture 9: Writing Fast Matlab Code
Cinna Wu
cinnawu@math.berkeley.edu
Department of Mathematics
University of California, Berkeley
Math 98 Introduction to MATLAB programming
Announcements
HW4 is due this Thursday!
Optimization Guidelines
The main three
C
Lecture 10: Miscellaneous topics
Cinna Wu
cinnawu@math.berkeley.edu
Department of Mathematics
University of California, Berkeley
Math 98 Introduction to MATLAB programming
Announcements
HW 4 Solutions are up
HW 5 (optional if you have passed four assignme
Math98 HW1: due September 8
Here is a simple game: a player can roll a fair, six-sided die up to three times. After each roll a player
may stop the game and receive $1 for each dot on the upturned die. The player has to roll at least once, and
the game au
Math98 HW3
Suppose f : R R and that x0 is a given real number. Halleys method
x0 is given by the sequence
xn+1 = xn
2f (xn )f (xn )
,
2f (xn )2 f (xn )f (xn )
1
for nding a root of f starting at
n 0.
This method is obtained by applying Newtons method on
2
1
2
0
Figure 1: PlotCycloidArc(8.5)
Math98 HW4
The cylcoid is the plane curve traced out by a point on a circle as the circle rolls without slipping on a
straight line.1 In this exercise we will use MATLAB to create an animation of a circle rolling on a
Temperature Model on a Grid
Consider the (2n + 1) (2n + 1) grid consisting of points (x, y) for |x| n and |y| n.
Note that (x, y) with |x| < n and |y| < n has four neighboring points in the grid. For
example the neighbors of (x, y) = (0, 0) are
(1, 0), (0