Question

how to solve non-linear equations in the Matlab program in terms of iteration number, accuracy or...

how to solve non-linear equations in the Matlab program in terms of iteration number, accuracy or calculation cost.  Show it with a few examples and share the codes as editor and command window so I can try it out.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

i have given my best on answering this. hoping that this is usefull to you.

This example returns the iterative display showing the solution process for the system of two equations and two unknowns

2x1−x2=ex1−x1+2x2=ex2.

Rewrite the equations in the form F(x) = 0:

2x1−x2−ex1=0−x1+2x2−ex2=0.

Start your search for a solution at x0 = [-5 -5].

First, write a function that computes F, the values of the equations at x.

F = @(x) [2*x(1) - x(2) - exp(-x(1));

         -x(1) + 2*x(2) - exp(-x(2))];

Create the initial point x0.

x0 = [-5;-5];

Set options to return iterative display.

options = optimoptions('fsolve','Display','iter');

Solve the equations.

[x,fval] = fsolve(F,x0,options)

                                         Norm of      First-order   Trust-region

Iteration Func-count     f(x)          step         optimality    radius

     0          3         47071.2                      2.29e+04               1

     1          6         12003.4              1       5.75e+03               1

     2          9         3147.02              1       1.47e+03               1

     3         12         854.452              1            388               1

     4         15         239.527              1            107               1

     5         18         67.0412              1           30.8               1

     6         21         16.7042              1           9.05               1

     7         24         2.42788              1           2.26               1

     8         27        0.032658       0.759511          0.206             2.5

     9         30     7.03149e-06       0.111927        0.00294             2.5

    10         33     3.29525e-13     0.00169132       6.36e-07             2.5

Equation solved.

fsolve completed because the vector of function values is near zero

as measured by the value of the function tolerance, and

the problem appears regular as measured by the gradient.

x = 2×1

    0.5671

    0.5671

fval = 2×1

10-6 ×

   -0.4059

   -0.4059

The iterative display shows f(x), which is the square of the norm of the function F(x). This value decreases to near zero as the iterations proceed. The first-order optimality measure likewise decreases to near zero as the iterations proceed. These entries show the convergence of the iterations to a solution. For the meanings of the other entries, see Iterative Display.

The fval output gives the function value F(x), which should be zero at a solution (to within the FunctionTolerance tolerance).

description how to solve non-linear equations in the Matlab program

1. ITERATIVE NUMERICAL METHODS FOR NONLINEAR EQUATIONS

1.1 Preliminaries

We want to analyze a nonlinear equation of the form

?(?)=0, (1.1)

where f : ℝ? → ℝ? is a nonlinear function, which will be assumed to have a certain degree of smoothness. If n ≠ 1, then (1.1) represents a system of n equations (at least one nonlinear) with m unknowns. In this paper, we will restrict our discussion to the case m = n = 1, although many of the procedures we describe can very easily be generalized to the multidimensional case.

Definition 1.1. A number α ∈ ℂ satisfying equation (1.1) is called a zero or a root of f.

In most cases, an exact solution of equation (1.1) cannot be found explicitly, so numerical methods must be employed instead. An iterative method will produce a sequence {??}?∈ℕ of approximations of α, starting with one or more initial values (?0,?1,…), such thatlim?→∞??=?. These initial values will be determined, in general, from the context of the problem or from the graph of the function. What makes an iterative method better than another is how fast it converges to the desired solution. Regarding the speed of convergence, we define the following:

Definition 1.2. We say that a sequence of iterates {??}?∈ℕ converges to α with order of convergence p ≥ 1, if

|??+1 − α| ≤ c | ?? − α|p, for all n ∈ ℕ, (1.2)

where c > 0 is a constant independent of n. For p = 1, we require also that c < 1 and in that case, c is called the rate of linear convergence of ?? to α.

In the next sections we present the most popular iterative methods for nonlinear equations.

1.2 Bisection method

The simplest of iterative methods, the bisection method is derived from the Intermediate Value Theorem, which states that if a continuous function f, with an interval [?, ?] as its domain, takes values ?(?) and ?(?) at each end of the interval, then it also takes any value between ?(?) and ?(?),at some point within the interval. So, assume f : [?, ?] → R is a continuous function and that ?(?)?(?) < 0. Also, assume that the interval [??, ??] contains only one root α of f. Then the idea is that at each step, we bisect the interval, so that f has opposite signs at the endpoints of the interval. This will produce a sequence of embedded intervals [??, ??], such that for every n ∈ N, α ∈ [??, ??] and ?(??)?(??) < 0. The procedure is presented in Algorithm 1.1 and illustrated in Figure 1.

Algorithm 1.1.

a0 = a, b0 = b, f;

for ?=1,2,…

if ??− ??< err then

sol =??;

return

elseif ?(??)?(??)< 0 then

??+1=??, ??+1=??;

else

??+1=??, ??+1=??;

end if

end if

end for

The sequence {??}?∈ℕ is monotonely increasing, sequence {??}?∈ℕ is monotonely decreasing and lim?→∞?? = lim?→∞?? = lim?→∞?? = α. Also, we have

(1.3)

which shows that the bisection method converges linearly (order of convergence p = 1) with a rate of convergence ?= 12⁄.

Remark 1.1. The advantages of the bisection method are: it always converges (no initial guess of the solution is necessary) and the error bound (1.3) can be used as a stopping criterion. As disadvantages, we mention the following: it converges slowly (only linear) and it only approximates real roots.

1.3 Secant method

We consider two initial values ?0,?1 and we approximate the graph of ?=?(?) with the secant line determined by the points (?0,?(?0)) and (?1,?(?1)). The root α of f is then approximated by ?2, the point of intersection of the secant line with the x-axis. Recursively, we obtain a sequence of iterates given by

(1.4)

For the convergence of the method, we have the following result:

Theorem 1.1. Assume ?,?′and ?′′are continuous on an interval ?ℇ=(?−?,?+?) containing the simple root α (?′(?)≠0). Then, for starting values ?0 and ?1 sufficiently close to α, the iterates in (1.4) converge to α, with order of convergence ?=(1+√5)2⁄ ≈ 1.618033… (the “golden ratio”).

Remark 1.2.

1. To understand what “sufficiently close” means in the theorem above, let

(1.5)

Then the method converges if ?0,?1∈??, with ε > 0 chosen so that

max{???0,???1}<1.

2. It is obvious that the secant method does not always converge, but when it does, it does so faster than the bisection method.

3. Another advantage is that the secant method can be used to approximate complex roots, as well, if the initial values ?0 and ?1 are taken to be complex numbers satisfying the conditions above.

4. A simple computation shows that for sufficiently large n, |??−?|≈|??+1−??|, which can be used as a stopping criterion.

Below, we present the algorithm for the secant method.

Algorithm 1.2.

?0,?1,?;

for ?=0,1,…

if |??+1−??|< err then

sol=??;

return

else

;

end if

end for

1.4 Newton’s method

We start with one initial value ?0 and we approximate the graph of ?=?(?) with the line tangent to the graph of f at the point (?0,?(?0)). The root α of f is then approximated by ?1, the point of intersection of the tangent line with the x-axis. Recursively, we obtain a sequence of iterates given by

(1.6)

The convergence result:

Theorem 1.2. Assume ?,?′and ?′′are continuous on an interval ?ℇ=(?−?,?+?) containing the simple root α (?′(?)≠0). Then, if the initial value ?0 is sufficiently close to α, the iterates in (1.6) converge to α and

lim?→∞??+1− ?(??− ?)2=?′′(?)2?′(?) , (1.7)

which shows the order of convergence is p = 2.

Remark 1.3.

1. Similarly with Remark 1.2, “sufficiently close” means if ?0∈??, where ε is chosen so that ???0 <1, with ?? and ?0 defined in (1.5).

2. Again, as before, Newton’s method does not always converge, but when it does, it does so faster (p = 2) than the bisection method (p = 1) and the secant method (?=(1+√5)2⁄).

3. Also, Newton’s method can be used to approximate complex roots, as well, if the initial value ?0 is a complex number satisfying the conditions above.

4. Again, for sufficiently large n, |??−?|≈|??+1−??|, which can be used as a stopping criterion.

The algorithm is described below.

Algorithm 1.3.

?0,?,?′;

for ?=0,1,…

if |??+1−??|< err then

sol =??;

return

else

end if

end for

1.5 Newton-Fourier method

The Newton-Fourier method is an improvement on Newton’s method, in the sense that it gives both lower and upper bounds for a simple root. There will be two sequences of iterates, {??}?∈ℕand {??}?∈ℕ approaching the root both from above and from below. The sequence {??}?∈ℕ is defined as in Newton’s method (see (1.6)). The other sequence is defined as follows: Start with one initial value ?0 and construct the line parallel to the line tangent to the graph of f at the point (?0,?(?0))and passing through the point (?0,?(?0)). The next iterate, ?1will be the point of intersection of that line with the x-axis. For simplicity, we present a particular case of this method.

Theorem 1.3. Assume ?,?′and ?′′are continuous on an interval [?,?] containing the simple root α. Assume that ?(?)<0, ?(?)>0 and that?′(?), ?′′(?)>0, for all ?∈[?,?]. Define the sequences

(1.8)

Then the iterates {??}?∈ℕ are strictly increasing to α, the iterates {??}?∈ℕ are strictly decreasing to α and

lim?→∞??+1− ??+1(??− ??)2=?′′(?)2?′(?) , (1.9)

which shows the order of convergence is p = 2.

Remark 1.4.

1. The assumptions of Theorem 1.3 can be relaxed to ?∈∁2and ?′(?)?′′(?)≠0 in a neighborhood of α. The conclusion still holds in that neighborhood (with the possible interchange of the monotonicity of the two sequences, i.e. with {??}?∈ℕ being strictly decreasing to α and {??}?∈ℕ being strictly increasing to α).

2. From (1.9), for sufficiently large n, we get the error bound |??−?|≈|??−??|, which can be used as a stopping criterion.

Below, we give the algorithm and an illustration of the Newton-Fourier method.

Algorithm 1.4.

?0=?,?0=?,?,?′;

for ?=0,1,…

if |??−??|< err then

sol =??;

return

else

end if

end for

Add a comment
Know the answer?
Add Answer to:
how to solve non-linear equations in the Matlab program in terms of iteration number, accuracy or...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT