1
E7: INTRODUCTION TO COMPUTER
PROGRAMMING FOR SCIENTISTS AND
ENGINEERS
Lecture 3
Strings
Relational operators
Logical variables and operators
Copyright 2007-2014, Horowitz, OConnell, Packard, Frenklach. This work is licensed under the Creative
Commons At

1
E7: INTRODUCTION TO COMPUTER
PROGRAMMING FOR SCIENTISTS AND
ENGINEERS
2
Review of Ordinary Differential Equations (ODEs)
Many problems in science and engineering lead to
Ordinary Differential Equations (ODEs) of the form
dy(t)
= f (t, y)
dt
Lecture Outl

1
E7: INTRODUCTION TO COMPUTER
PROGRAMMING FOR SCIENTISTS AND
ENGINEERS
2
Linear equations in matrix form
Consider n LINEAR equations and m unknowns.
Lecture Outline
1. Least squares solution when
n = # equations > m = # of unknowns
2. Regression and cur

1
E7: INTRODUCTION TO COMPUTER
PROGRAMMING FOR SCIENTISTS AND
ENGINEERS
Consider n LINEAR equations and m unknowns.
n equations
Lecture:
2
Linear algebraic equations
Linear Algebraic Equations and
Least Squares Solution
1. Solutions of linear algebraic eq

1
E7: INTRODUCTION TO COMPUTER
PROGRAMMING FOR SCIENTISTS AND
ENGINEERS
Lecture:
Many engineering and science problems reduce to the
simultaneous solution of several linear algebraic
equations.
Matrix Algebra and
Linear Algebraic Equations
Some typical ex

Normal call to ode45
Events
[TSol,YSol] = ode45(fh,Tspan,Yinitial);
Solution interval is defined by Tspan ([initial time , final time ])
E7#Numerical#Solu/on#of#ODEs#
using#MATLAB#
Se;ng#up#Events#to#Interrupt#
Simula/ons#
Other questions
How do you stop

1
E7: INTRODUCTION TO COMPUTER
PROGRAMMING FOR SCIENTISTS AND
ENGINEERS
Lecture Outline
1. Polynomial functions
Copyright 2007-2013, Horowitz, Packard. This work is licensed under the Creative Commons AttributionShare Alike License. To view a copy of this

Assigned: Sept 3
Fall 2014
Due: Sept 5
E7 Homework Assignment 0:
Homework Sample
The purpose of this lab is to introduce you to the MATLAB environment, some basic MATLAB commands, and how to use it as a standard calculator.
Note: Use the template provided

E7: INTRODUCTION TO COMPUTER
PROGRAMMING FOR SCIENTISTS AND
ENGINEERS
Induction
Lecture Outline
Review of Recursion
Induction & Examples
Copyright 2007-2014, Alam, Horowitz, Packard. This work is licensed under the Creative Commons
Attribution-Share Ali

1
E7: INTRODUCTION TO COMPUTER
PROGRAMMING FOR SCIENTISTS AND
ENGINEERS
Linear Algebraic Equations and
Least Squares Solution
1. Solutions of linear algebraic equations
2. Least squares solution
Copyright 2007-2014, Alam, Horowitz, Packard. This work is l

1
E7: INTRODUCTION TO COMPUTER
PROGRAMMING FOR SCIENTISTS AND
ENGINEERS
Lecture Outline
The concept of a function
MATLAB functions
User defined functions
Copyright 2007- 2014, Alam, Horowitz, Packard. This work is licensed under the Creative Commons
Attri

Assigned: Nov 24
Fall 2014
Due: Monday Dec 15 - noon
E7 Homework Assignment - EXTRA:
Apply Your E7 Knowledge in Real Life
This assignment is an EXTRA CREDIT group assignment (must have 3-4 members). Groups
of 1 or 2 members will not receive credit.
The pu

Assigned: Nov 7
Fall 2014
Due: Sunday Nov 16 - noon
E7 Homework Assignment 10:
Interpolation and Root Finding
Midterm 2 will take place on Friday, November 14th. As a consequence, the due date of this
homework will be extended until Sunday afternoon. Howe

Engineering 7: Introduction to computer
programming for scientists and engineers
Interpolation
Recap
Polynomial interpolation
Spline interpolation
(UC BERKELEY-COE)
ENGINEERING 7
Regression and Interpolation:
learning functions from data
(UC BERKELEY-COE)