0 views

Uploaded by lawjames

numerical analysis project

- HSC Maths Extension 1 Notes
- HP28S MATH APPS SOLUTION MANUAL
- Nature of Roots of a Polynomial
- A-level Physics P5
- List of r Commands
- Priority Search Trees
- Circular Fit by Several Algorithms in R
- 45 Statistics
- Pertemuan 3 Forecasting
- plugin-1-s2.0-S0167691198000127-main.pdf
- Pre Calculus
- General Mathematics Midterm ABM STEM
- Dynamic Modelling and Validation of Diesel Engine Fuelled with Palm Oil Methyl Esters
- joreskog
- High
- CHAPTER 6
- Algorithm 9xx: Sparse QR Factorization on the GPU
- Curve Fitting
- ch
- Geometric 314119074747 Un Se

You are on page 1of 2

Project 4

Least Squares Approximation and Numerical Linear Algebra

February 20, 2011

1. Let x=0:.2:1, y=rand(1,6) plot this data plot(x,y,o). Using MATLABs polyfit find the least

squares polynomials of degrees, deg= 1, 2, 3, 4, 5 and plot them all together with the data. Save the plot to

turn in.

2. Collect data from the function y=logistic below. Plot x=1:200 and y and hold the plot. Now find the

regression line through the data. Plot the regression line with the data. Save the plot to turn in.

function y=logistic

x=rand;

y=[];

for i=1:200,

x=3*x*(1-x);

y=[y,x];

end

3. Let F (x) = x3 + 2x2 x + 3 and let f be the vector of coefficients of F (x). Plot the polynomial as follows:

(1) On the interval [1, 3] using the sample vector xs=-1:.01:3 and let ys be the values of F (x) for

this sample.

(2) Add some random noise yn=ys+1-2*rand(1,401) and plot the noisy vector with F (x). Save the

plot to turn in.

(3) Do a degree 3 least squares fit using the data from the vectors xs and yn and call the outcome

f3. Look at max(abs(f-f3/f3(1)) to see how close the regression polynomial is to the original polynomial.

Why did we divide by f3(1)?

(4) Collect 50 regularly spaced knot points from xs and yn and call the outcomes x and y. Do a least

squares cubic fit to this data. Call the outcome g3. How close is g3 to f? (like part (3))

(4) Plot the least squares polynomial by forming y3=polyval(g3,xs) with the plot of the noisy vector,

yn. Save the plot to turn in.

(5) What is the absolute error and the relative error between ys and y3.

1

4. For the function Runge R(x) = 1+x 2,

(1) Plot R(x) on the interval [10, 10] using a fine resolution sample like xs=-10:.01:10. Let ys be

the values of R(x) on the sample xs.

(2) Now form the knots with x=-10:2:10 and let y be the values of R(x) on x.

plot(xs,ys), hold, plot(x,y,o)

(3) Use MATLABs polyfit to find the regression polynomials f6, f8 and f10 of degrees 6, 8 and 10.

Plot these with your plot of R(x). Call the plotting vectors y6, y8, y10. Save the plot to turn in.

(4) By looking at the absolute errors,

max(abs(ys-y6)), etc

and the relative error,

max(abs((ys-y6)./ys)), etc

which of these polynomials is the better fit to R(x)?

5. The following data is purported to show the growth in myspace.com participation over a period of 31

months. It was claimed that myspace.com experienced exponential growth.

x=[1,5,7,11,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28, 29,30,31]

y=[2,4,5,11,19,22,23,28,33,35,43,48,55,67,72,80,87,90,100,108,120,131]

The x vector is in months and the y vector in millons of subscribers.

(1) Plot the data.

1

(2) Find the least squares quadratic polynomial and plot it with the data. Use a fine resolution sample

for plotting like xs=0:.01:35.

(3) Find the maximum of the absolute error at the knot points.

An exponential polynomial has the form y = aebx where a and b are constants. We can get a least squares

exponential fit by taking the log of both sides to get

log(y) = log(a) + bx

y1 = a1 + b1 x1

which has a least squares approximation using our methods. Now recover a = ea1 and b1 = b.

(4) Plot y = aebx using MATLABs exp to compute the exponential. Save the plot to turn in.

(5) Find the maximum of the absolute error at the knot points.

(6) Which curve, the quadratic or the exponential, is the better fit?

6. Write a MATLAB function [L,U]=mylu(A) which finds the LU Decomposition of A. You may assume

that no row switches are needed. Check your mylu on rand(5) and magic(5). You have three things to

check: L is unit lower triangular, U is upper triangular, and A = LU.

7. Write a function [x,count]=ppmysolve(A,b) based on your mysolve which incorporates the partial

pivoting strategy. The output variable count should count the number of row switches. Test your ppmysolve

on these systems. How many row switches are used in each of these?

(a) A=magic(7), b=A*ones(7,1)

(b) A=vander(rand(8,1)), b=A*ones(8,1)

(c) A=A*A where A=vander(rand(8,1)), b=A*ones(8,1)

8. Write a MATLAB function [Q,R]=gramqr(A) which finds a QR Decomposition of A using the Gram

Schmidt Method. Do not, repeat, DO NOT, assign R = QT A. Test your gramqr on these matrices. You

have three things to check for in each.

(a) A=magic(5)

(b) A=pascal(6)

(c) A=hilb(8)

(d) A=ones(5)+eps*eye(5)

9. Write a MATLAB function [Q,R]=mgs(A) which finds a QR Decomposition of A using the Modified

Gram-Schmidt method. Check your mgs on the matrices in problem 8.

A=triu(rand(8),1)+2 b (-20)*eye(8)

compute cond(A) and rcond(A). Read up on these functions using MATLABs help. Set

b=A*ones(8,1)

Use the condition number to predict the number of accurate decimal places in the computed answer.

- HSC Maths Extension 1 NotesUploaded byleozhou951
- HP28S MATH APPS SOLUTION MANUALUploaded bygnd100
- Nature of Roots of a PolynomialUploaded bymeenu7823
- A-level Physics P5Uploaded byforum4physics
- List of r CommandsUploaded byRoopak Behera
- Priority Search TreesUploaded bymanishbhardwaj8131
- Circular Fit by Several Algorithms in RUploaded byNikhil Rastogi
- 45 StatisticsUploaded byYasaswi
- Pertemuan 3 ForecastingUploaded byBanggas Hanistia Pahlevi
- plugin-1-s2.0-S0167691198000127-main.pdfUploaded byUsef Usefi
- Pre CalculusUploaded bybackbeat_2006
- General Mathematics Midterm ABM STEMUploaded byRPONTEJO
- Dynamic Modelling and Validation of Diesel Engine Fuelled with Palm Oil Methyl EstersUploaded byIJEC_Editor
- joreskogUploaded byC. Madhavaiah
- HighUploaded bySabu Vincent
- CHAPTER 6Uploaded byAbimbola
- Algorithm 9xx: Sparse QR Factorization on the GPUUploaded byErnesto Dufrechou
- Curve FittingUploaded byNi Putu Indira Melila
- chUploaded byDida Khaling
- Geometric 314119074747 Un SeUploaded byCokorda Agung Nata Arimbawa
- 24S3-1Uploaded bythanhtan
- Qm 016 Question PolyUploaded byamer
- Polynomial and Matrix CalculationsUploaded bymajid jalil
- Chapter 2 White Board ReviewUploaded byPutramica Winarto
- ch2.pdfUploaded byJaskirat Singh
- Geometrie Avansati lb englezaUploaded byMaraMarutz
- bio 1615 paperUploaded byapi-251797845
- PMO 20 Qualifying Round With Answers OnlyUploaded byJaredd Dio
- Class 9 10 Curriculum 2016 2017 MathsUploaded byAbhishek Patra
- Lec17.pdfUploaded byNasrullah Yusup

- R cheatsheet Data WranglingUploaded byarekbee
- Ets RegressionUploaded bylawjames
- Spap Salary DataUploaded bylawjames
- ex 2Uploaded bylawjames
- Rmarkdown Cheatsheet 2.0Uploaded byacevice69
- Stem Ready Program ApplicationUploaded bylawjames
- mysqluide.pdfUploaded bylawjames
- MGF1107 Exam 1 Study Guide-1Uploaded bylawjames
- Sas to Excel DatesUploaded bylawjames
- chapter6_practice1Uploaded bylawjames
- Loglinear Models in Two Dimensions - Thursday March 2 & Tuesday March 14Uploaded bylawjames
- Y = 0 or 1 example - Thursday March 2.docUploaded bylawjames
- 060801_Axiom_UG_EN01Uploaded byRobert Clark
- Kelly Clarkson Since You Been GoneUploaded byJanell Chen
- Hey There DelilahUploaded byJenny Yoo-Nah Roach

- Brents Algorithm.pdfUploaded byAndres Granados
- A Rational Cubic Spline Interpolation and Its ApplicationUploaded bykuldipkatiyar198570
- UNIT IUploaded byRam Prasad
- A Fuzzy SystemUploaded byprashantsinghiitbhu
- scipy-refUploaded byduddface
- 1-s2.0-0888613X9400033Y-mainUploaded bytheanhdtvt
- Casaseminar Eno Weno SchemeUploaded bynavala_pra
- 9280721Uploaded bySaifuddin Sulaiman
- TransientUploaded bySushank Dani
- Numerical Analysis 2000. Vol.1Uploaded byapi-3851953
- MTE-12Uploaded byVipin
- prolog tutorialUploaded byMP
- Implicit schemeUploaded byAmit Makhija
- EE227A -- Convex Optimization SYLLABUSUploaded byRohan Varma
- Numerical Methods with MATLAB.pdfUploaded byISTIAN
- Q2 ansUploaded bySu Yi
- SimplexUploaded bybanti21
- aaabook_9500tocUploaded bycorneli@
- Optimization (Mathematics) in Mathematics, The Term Optimization, Or Mathematical Programming,Uploaded bytuniya4
- Lp SolveUploaded byLuiz
- Simpsons_rules.pdfUploaded bySelviana Arifika
- IluUploaded byMuhammad Enam ul Haq
- Linear Programming with RUploaded byAlfredo Armijos
- Block Lu FactorizationUploaded byJubayer Ahmed
- 16- Lagrangian Relaxation Solution of Unit CommitmentUploaded bykaren dejo
- Trapezoidal Rule and Simpson's RuleUploaded bySai Vandana
- gcmmaUploaded byAlexandre
- Finite Diference MethodUploaded byjeffersans
- 08 Matlab InterpolationUploaded byOmed Ghareb
- Lecture Notes Nonlinear Equations and RootsUploaded byAmbreen Khan