CE 335 Exam 1 Solutions
1]
(a) Only the first three derivatives of f(x) are nonzero. We have
f(x) = x3  2x2 + 5x  1
f'(x) = 3x2  4x + 5
f'(x) = 6x  4
f'(x) = 6
So the Taylor series about zero is
f(0 + h)
= f(0) + hf'(0) + h2f'(0)/2 + h3f'(0)/6
= 1 +
CE 335
Solutions to Homework 3
9)
(a) (40  0) degC / (2*0.05) degC = 400 (need to reduce the range by this factor).
log2(400) = 8.64, so 9 iterations (the maximum absolute error will decrease by a factor of 2 each
iteration).
(b)
function T = find_T(DO)
CE 335
Solutions to Homework 4
11)
function [x, fx, ea, iter] = goldmax(f, xl, xu, es, maxit, varargin)
% goldmax: maximization golden section search
% arguments same as for goldmin function in book
if nargin < 3, error('at least 3 arguments required'), e
CE 335
Solutions to Homework 5
11)
We need to assume that all material supplied is used.
Augmented matrix formulation of problem:
15
17
19

3890
1.0
1.2
1.5

282
0.3
0.4
0.55 
95
subtract multiple of first row from second and third (in Matlab: A(2, :)
HW#5
EGM6341
From textbook by Atkinson
pp185194
Problem #6
The total error e(x) is the sum of the truncation error TE(x) and the roundoff error R(x)
( x) = TE ( x) + R ( x)
The truncation error is given by
TE ( x) =
1
f " ( )( x x 0 )( x x1 ) by for so
Solution to HW#6
EGM6341
#28a. Find a polynomial p(x) of degree 2 that satisfies
p(x0)= y0, p(x0)=y0, p(x1)=y1
Given a formula in the form of
p(x) = y0l0(x) + y0 l1(x) + y1 l2(x).
Solution:
For the suggested p(x), it is seen that
p(x0)= y0 => l0(x0) = 1,
Solution to Homework #2
EGM6341
For the following numbers xA and xT, how many significant digits are there in xA with
respect to xT?
a)
xA = 451.023,
xT = 451.01
b)
xA =0.045113,
xT = 0.04518
c)
xA = 23.4213,
xT = 23.4604
Soln. a)
 xA  xT  = 451.023
Solution to Homework #1 EGM6341
1. (a) Assume (x) is continuous on a x b, and consider the average
1 n
S = f (x j )
n j =1
with all points xj in the interval [a, b]. Show that
S = f ( )
for some in [a, b].
Soln: Because (x) is continuous in the interval
Solution to
HW#7
EGM6341
pp. 323329
Problem #1. Write a program to evaluate I =
b
a
f ( x )dx using the trapezoidal rule
with n subdivisions, calling the result In. Use the program to calculate the following
integrals with n=2,4,8,16,512
1
a)
I = exp( x
HW#4
EGM6341
From the textbook by Atkinson:
pp 496503:
Problem #6a (just expand the determinant using cofactors and minor)
Solution:
x 1
1 x
0 1
f n ( x) = det
0 .
0
1
x
0
1
.
0
1
0
0
. 0
. 0
x 1
1 x
Expand the determinant using first row, we obtain
x
HW#3
EGM6341
pp.117127 of Atkinsons textbook
#2
Write a program implementing the algorithm Bisect given in Section 2.1. Use the
program to calculate the real roots of the following equations. Use an error tolerance of
=105.
f(x) = exp(x)3x2 = 0
f(x) =
CE 335
Solutions to Homework 1
8)
Given the differential equation, the Euler's method numerical approximation is
y(t + t) = y(t) + t(3(Q/A)sin2(t)  Q/A).
Here, the number of time steps to take is n = (t1  t0)/t = (10 d)/(0.5 d) = 20.
We can write a Matl
CE 335 Exam 2 Solutions
1]
(a) Setting f(x) = sin(x)  x2,
we find that f(0.88) = 0.004 < 0 while f(0.872) = +0.005 > 0. So [0.872 0.88] is a bracketing interval,
and since f(x) is continuous, there is a root in that interval.
(b) Iteration 1:
c = (0.88
CE 335 Exam 3 Solutions
1]
(a) The function v = aPb can be transformed to make it linear in the unknown parameters log(a) and b:
log(v) = log(a) + b log(P). The coefficient matrix X of the linearized problem has ones in the first
column and log(Pi) in the
CE 335 Final Exam
Solutions
1] For the branch of the tangent function between /2 and /2, the root is at x = 0. The smallest
positive root is found on the next branch, in the positive half where < x < 3 /2  in fact, we need that
tan(x) ~ 4. Taking (after
CE 335
Computer Assignment 1
An introduction to Matlab programming: A trigonometric function
We will implement a Matlab program to calculate the cosine of a given angle, similar to the builtin
function cos. The numerical method we will use is based on th
CE 335
Computer Assignment 1
An introduction to Matlab programming: A trigonometric function
We will implement a Matlab program to calculate the cosine of a given angle, similar to the builtin
function cos. The numerical method we will use is based on th
CE 335
Programming Assignment 2
Optimization: Orienting solar collectors
The orientation of photovoltaic panels and solar water heaters relative to the sun determines how much
sunlight they absorb, which we generally want to maximize. The sun's direction
CE 335
Programming Assignment 2
Optimization: Orienting solar collectors
The orientation of photovoltaic panels and solar water heaters relative to the sun determines how much
sunlight they absorb, which we generally want to maximize. The sun's direction
CE 335
Programming Assignment 3
Interpolation and regression: Approximating temperature dependence
In many engineering applications, interpolation and regression are used to derive approximate
expressions for functions that are difficult or timeconsuming
CE 335
Programming Assignment 3
Interpolation and regression: Approximating temperature dependence
In many engineering applications, interpolation and regression are used to derive approximate
expressions for functions that are difficult or timeconsuming
CE 335
Programming Assignment 4
Differential Equations: Seismic response of buildings
Horizontal acceleration of the ground during an earthquake causes shear stress on building members as
the building tries to keep up with the ground motion. If the accele
CE 335
Programming Assignment 4
Differential Equations: Seismic response of buildings
Horizontal acceleration of the ground during an earthquake causes shear stress on building members as
the building tries to keep up with the ground motion. If the accele
CE 335 Old exam questions (with solutions following) for Chapters 14
1] Write a Matlab function that determines whether any given year is a leap year in the Gregorian
calendar. It should return 1 if the positive integer year is a leap year and 0 otherwis
Solution to part of HW#8
Problem #6 Write a computer program to solve y= f(x,y), y(x0)=y0, using Eulers method.
Write it to be used with an arbitrary f, stepsize h, and interval [x0,b]. Using the program,
solve y=x2 y, y(0) = 1, for 0x4, with stepsizes of