Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask MATLAB Expert

1 Errors

a. Run the MATLAB script

sum = single(0); term = single(1);
n=1;
while sum + term > sum
sum = sum + term;
n=n+1;
term = 1/n;
end
n

Describe what you think it is trying to do. What would this code do in exact arithmetic? describe why the code produces a finite result and (harder) describe the output. What would happen (don't try it!) if you replaced the  first line with sum=0; term=1;?

b. Use Taylor series to derive the form of the truncation error of the approximation

f'(x) =3f(x) -4f(x - h) + f(x -2h)/2h

assuming f ≡ C3. Given that the round off error has the same form as in the Forward Difference case, find an expression for the step size h that gives the smallest total (absolute) error. Modify ForwardDifference.m to show how the total error in using Equation 1 behaves for various values of h and comment on your results.

2 Operation counts

a. Derive the operation count (multiplications and divisions only) for

(i) Choleski factorization (without pivoting) A detailed algorithm for Choleski factorization can be found via the MAST30028 website on p. 78 of Heath's Lecture Slides --- Chapter 2.

(ii) Gauss elimination (equivalent to LU factorization) without pivoting of an Upper Hessenberg matrix. An Upper Hessenberg matrix is one with zeroes below the subdiagonal. Just modify the derivation for Gauss elimination.

(iii) solution of a tridiagonal system via LU factorization without pivoting (also called the Thomas algorithm) This is the algorithm implemented in the code tridisolve in the Asst1 folder on the server.

b. Verify qualitatively the running times you obtained above, by timing the solution of linear systems of size at least 1000X1000 with matrices having the appropriate structure (symmetric positive definite, Upper Hessenberg or tridiagonal).

Construct the matrices yourself with suitable MATLAB commands such as diag, triu, rather than using particular matrices from the MATLAB gallery.

For all cases, use \ to solve the system. For case c, try a tridiagonal matrix created with diag and one created with spdiags.

describe what you think is going on.

3 Application: Nonlinear systems of equations

You have met Newton's method as a method for solving nonlinear equations in the form f(x) = 0.

xn+1 = xn-f(xn)/f'(xn)

which gives iterates {xn} that converge rapidly to the solution x*  provided the initial guess x0 is sufficiently close to x* . Applying this to the function

f(x) = x2 - a produces the iteration xn+1 = xn - x2n -a/2xn= xn/2 + a/(2xn)

which should look familiar. It can be written in the alternative form: solve in turn

f'(xn)sn = f(xn); xn+1 = xn - sn

For a system of two nonlinear equations f1(x1, x2) = 0; f2(x1,x2) = 0

or  in vector notation

f (x) = 0

Newton's method generalizes in the following way: solve the 2X2 linear system

J(xn)sn = f (xn) then update xn+1 = xn - sn

where J is the Jacobian matrix formed from f

194_Jacobian matrix.jpg

To get an idea how it works, try out the Java applet http://www.cse.illinois.edu/iem/nonlinear_eqns/Newton2D/

a. prepare a MATLAB function to implement Newton's method for a system of 2 nonlinear equations.

It should have the calling sequence [roots, count, resids, history] = ass1Q3(func,x0,tol)

where:

• the first input argument is a function handle to a function that returns the value of the function f and the Jacobian matrix J at the position x e.g. function [ f J] = ex2( xx )

The function ex2 needs to be written by the user, including the expressions for f and J. There is no need for J to be found symbolically from f .

• x0 is the initial guess ( a column vector)

• tol is the absolute tolerance. The iterations should stop once the residual ||f||, measured using the vector ∞-norm, is below tol.

• the  first output argument is a column vector containing the solution x

• count is the number of iterations required

• resids is a vector containing the norms of the residuals at each iteration

• history is a matrix whose columns are the iterates xn i.e. each column is a 2X1 array.

The function should:

• use a default tolerance of 10-10 if none is given

• use a while loop but loop no more than 50 times.

Although I only need it to work for systems of 2 equations, you should be able to prepare it so that it can be used (in principle) on a system of any size. My code is less than 20 lines long.

b. prepare a driver function to test your code on ex 2 of the Newton2D Java applet. The driver should produce output such as
After 5 iterations, the roots are [1.61803 1.61803]

c. Modify your driver to find the solution to

3x31 + 4x22- 145 = 0; 4x21- x32+ 28 = 0

Show results for 2 different initial guesses: x0 = (2, 2),(2,-1).

For each case, plot the convergence history - the residual norms at each iteration - on a suitable plot and (on a different plot) the solution trajectory - the set of iterates xn.
Comment on your results.

MATLAB, Engineering

  • Category:- MATLAB
  • Reference No.:- M91787
  • Price:- $70

Priced at Now at $70, Verified Solution

  • AsyU replied

    Mywordsolution.com is my first experience and i have to say that you guys are life saver honestly your solution is too awesome which helped me alot thank you so much...

Have any Question?


Related Questions in MATLAB

Question 1 manipulate spectral imagehyperspectral images

Question 1. Manipulate spectral image Hyperspectral images can be seen as a generalisation of normal colour images such as RGB images. In a normal RGB colour image, there are 3 channels, i.e. channels for red colour, gre ...

Assignment details -need to write a code for connecting

Assignment Details - Need to write a code for connecting segments (Lines) a special case of TSP. The problem is to connect lines in 2d/ 3d space with path obstructions. Can you help me write the code for this? Hope you m ...

Assignment matlab programmingusing appropriate matlab

Assignment: MatLab Programming Using appropriate MatLab syntax, write the code required to analyse and display the data as per the problem description. The order of the MatLab Program should be as follows: Variables and ...

Assignment -data is given on which want to do computational

Assignment - Data is given on which want to do computational production planning using Metaheuristic MATLAB Programming: 1) Ant Colony Algorithm on both Partial and Total Flexible Problem. 2) Bee Algorithm on both Partia ...

Lab assignment - matlab matrix relationallogical operators

Lab Assignment - MATLAB Matrix, Relational/Logical Operators and Plotting This laboratory exercise/assignment will involve you 1) practicing multiplication operators in MATLAB; 2) practicing relational and logical operat ...

Suppose that you have used some concept learning algorithm

Suppose that you have used some concept learning algorithm to learn a hypothesis h1 from some training data. You are interested in knowing the accuracy that the hypothesis can be expected to achieve on the underlying pop ...

Suppose that a student has the option of enrolling for a

Suppose that a student has the option of enrolling for a single elective during a term. The student must select a course from a limited list of options: "English, " "History, " "Biology, " "Computer, " or "Math." Constru ...

Prepare a 3 - 10 pages long reportprepare a presentation

Prepare a 3 - 10 pages long report Prepare a presentation with 5 - 9 slides. The slides will include introduction (need and similar work), theoretical background (tested neural networks), Data, Results (Comparison of the ...

Assignment -matlab codes and simulated model in

Assignment - Matlab codes and simulated model in simulink/matlab and truetime. 1. Matlab codes and simulink model for pid controller optimization using particle swarm optimization (PSO) my plant is integer order 1000/(s^ ...

Question - verify the attached paper with matlab and get

Question - Verify the attached paper with matlab and get all the results in the paper and explain step by step the matlab code. Paper - Improving Massive MIMO Belief Propagation Detector with Deep Neural Network. Attachm ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As