Newton’s Method and Loops:
Solving equations numerically:
For the subsequently few lectures we will focus on the problem of solving an equation:
f(x) = 0.
As you erudite in calculus, the final step in several optimization problems is to solve an equation ofthis form where f is the derivative of a function F that you desire to maximize or minimize. In realengineering problems the function you wish to optimize able to come from a large variety of sources,including formulas, solutions of differential equations, experiments, or simulations.
Newton iterations:
We will signify an actual solution of equation by x∗. There are three methods which you may perhapshave discussed in Calculus: the bisection method the secant method with Newton’s method. Allthree depend on commencement close (in some sense) to an actual solution x∗.
Recall Newton’s method youmust know that the basis for Newton’s method is approximation ofa function by it linearization at a point that is:
f(x) ≈ f(x0) + f′(x0)(x − x0).
Since we wish to find x therefore that f(x) = 0 set the left hand side (f(x)) of this approximation equalto 0 along with solve for x to obtain
x≈ x0−f(x0)/f′(x0)
We begin the method with the initial guess x0, which we hope is fairly close to x∗. Then we definea sequence of points {x0, x1, x2, x3, . . .}from the formula:
xi+1 = xi−f(xi)/f′(xi)
If f(x) is reasonably well-behaved near x∗as well asx0 is close enough to x∗subsequently it is a fact that the sequence will converge to x∗and will do it very quickly.
The loop for ... end:
In order to do Newton’s method we requirerepeating the calculation in a number of times. Thisis accomplished in a program using a loop which signifies a section of a program which is repeated.The simplest manner to accomplish this is to count the number of times through. In Mat labafor ... end statement makes a loop as in the subsequent simple function program:
function S = mysum(n)% gives the sum of the first n integersS = 0; % start at zero% The loop:for i = 1:n % do n timesS = S + i; % add the current integerend % end of the loop
Call this function in the command window as:
>mysum(100)
The result will be the total of the first 100 integers. All for ... end loops have the similar format itbegins with for followed by an index (i) and a range of numbers (1:n). Afterward come the commandsthat are to be repeated. Last come the end command.
Loops are one of the major ways that computers are made to do calculations that humans cannot.
Any computation that involves a repeated process is easily done by a loop.
At the moment let’s do a program that does n steps (iterations) of Newton’s method. We will requires to inputthe initial guess, the function, its derivative, and the number of steps. The output will be the absolutevalue of xthat isxn. If we are merely interested in the final approximation not the intermediate stepswhich is usually the case in the real world then we can use a single variable x in the program andchange it at each step:
function x = mynewton(f,f1,x0,n)% Solves f(x) = 0 by doing n steps of Newton’s method starting at x0.% Inputs: f -- the function, input as an inline% f1 -- it’s derivative, input as an inline% x0 -- starting guess, a number% n -- the number of steps to do% Output: x -- the approximate solutionformat long % prints more digitsformat compact % makes the output more compactx = x0; % set x equal to the initial guess x0for i = 1:n % Do n timesx = x - f(x)/f1(x) % Newton’s formula, prints x tooend
In the command window define an inline function: f(x) = x3− 5 i.e.
> f = inline(’x^3 - 5’)
and define f1 to be its derivative, i.e.
> f1 = inline(’3*x^2’).
Then run my Newton on this function. By trial as well as error what is the lowest value of n for which theprogram converges (stops changing). Through simple algebra the true root of this function is 3√ 5. Howaccurate is the program’s answer to the true value?
Convergence:
Newton’s method converges rapidly when f′(x∗) is nonzero and finite, and x0 is close enough to x∗that the linear approximation is valid. Let us take a look at what is able to go wrong.
For f(x) = x1/3 we have x∗= 0 but f′(x*) = ∞. If you try
> f = inline(’x^(1/3)’)> f1 = inline(’(1/3)*x^(-2/3)’)> x = mynewton(f,f1,0.1,10)
then x explodes.For f(x) = x2 we have x= 0 but f′(x) = 0. If you try
> f = inline(’x^2’)> f1 = inline(’2*x’)> x = mynewton(f,f1,1,10)
Then x does converge to 0 however not that rapidly.
If x0 isn’t close enough to xthat the linear approximation is valid, then the iteration gives some x1 that may or mayn’t be any better than x0. If we keep iterating afterwards either
• xn will ultimately get close to xand the method will then converge (rapidly) or• The iterations will not approach x.
Latest technology based Matlab Programming Online Tutoring Assistance
Tutors, at the www.tutorsglobe.com, take pledge to provide full satisfaction and assurance in Matlab Programming help via online tutoring. Students are getting 100% satisfaction by online tutors across the globe. Here you can get homework help for Matlab Programming, project ideas and tutorials. We provide email based Matlab Programming help. You can join us to ask queries 24x7 with live, experienced and qualified online tutors specialized in Matlab Programming. Through Online Tutoring, you would be able to complete your homework or assignments at your home. Tutors at the TutorsGlobe are committed to provide the best quality online tutoring assistance for Matlab Programming Homework help and assignment help services. They use their experience, as they have solved thousands of the Matlab Programming assignments, which may help you to solve your complex issues of Matlab Programming. TutorsGlobe assure for the best quality compliance to your homework. Compromise with quality is not in our dictionary. If we feel that we are not able to provide the homework help as per the deadline or given instruction by the student, we refund the money of the student without any delay.
tutorsglobe.com percentage method assignment help-homework help by online measurement of price elasticity of demand tutors
Carbanion-Aldol, Wittig Reaction and Claisen Condensation tutorial all along with the key concepts of Acidity of a-Hydrogen, Reactions Involving Carbanions, Halogenation of ketone, Nucleophilic addition to carbonyl compounds, Mechanism of Aldol condensation
theory and lecture notes of introduction to bioengineering all along with the key concepts of bioinstrumentation, biomechanics, biomaterials, systems physiology, clinical engineering, rehabilitation engineering. tutorsglobe offers homework help, assignment help and tutor’s assistance on introduction to bioengineering
Metallurgy tutorial all along with the key concepts of Types of Furnaces used, Steps involved in Metallurgical Operations, Ore Dressing, Extraction of Crude metal and Purification of Metals
tutorsglobe.com price and output determination assignment help-homework help by online monopoly tutors
Introduction to Coordination Chemistry tutorial all along with the key concepts of Werner's Coordination Theory, Classification of Coordination Compounds, Monodentate ligands, Bidentate ligands, Polydentate ligands, Radioactivity, Features of Radioactivity and Types of Radiation
tutorsglobe.com orthopedics assignment help-homework help by online bones and joints tutors
tutorsglobe.com starch-sugar interconversion theory assignment help-homework help by online mechanism of stomatal closing and opening tutors
Modern Examples of Evolution tutorial all along with the key concepts of Sickle-cell Anaemia, Industrial Melanism, Chloroquine - Resistance Malaria Parasite, Pesticide-Resistance Insects, HIV, Phylogenetic categorization of Organisms
Theory and lecture notes of Integration-Midpoint and Simpsons Rules all along with the key concepts of functions and data, Midpoint rule, Simpson’s rule, Error bounds. Tutorsglobe offers homework help, assignment help and tutor’s assistance on Integration-Midpoint and Simpsons Rules.
tutorsglobe.com venture capital fund assignment help-homework help by online source of finance tutors
LC Oscillators tutorial all along with the key concepts of Time Domain Solution, Resonance Effect, Series LC Circuit, Impedance, Parallel LC Circuit, Applications of Resonance Effect, LC OR Oscillatory Circuit, Frequency Stability of Oscillator
Photochemistry and Pericyclic Reactions tutorial all along with the key concepts of Photochemical reaction, tunicate, Consequences of photo excitation, Pauli Exclusion Principle
It might not be out of place here to understand the mean of the word ‘value’. Since a matter of fact, the word ‘value’ comprises dissimilar meanings for dissimilar persons.
tutorsglobe.com significance of natural vegetative propagation assignment help-homework help by online natural methods of vegetative propagation tutors
1931355
Questions Asked
3689
Tutors
1448015
Questions Answered
Start Excelling in your courses, Ask an Expert and get answers for your homework and assignments!!