Question

1. The nonlinear system fi(x1, x2) = x - xż + 2x2 = 0, $2(x1, x2) = 2x1 + xź – 6= 0 has two solutions, (0.625204094, 2.179355Continuation Algorithm To approximate the solution of the nonlinear system F(x) = 0 given an initial approxima- tion x: INPUTGiven this pseudocode and problem (as an example), code the continuation algorithm in MATLAB.

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

%%%%%%%%% With initial condition x1=0, x2=0 %%%%%%

clc;
clear all;

N=2;

f1=@(x1,x2) x1^2-x2^2+2*x2;
f2=@(x1,x2) 2*x1+x2^2-6;
J=@(x1,x2)[2*x1 -2*x2+2;2 2*x2];
%intial conditions
x1(1)=0;
x2(1)=0;
F=[f1(x1,x2);f2(x1,x2)];
%step 1
h=1/N;
b=-h*F;
% Step 2
for i=1:2
A=J(x1(i),x2(i));
K1=inv(A)*b;
%step 3
A1=J(x1(i)+K1(1)/2,x2(i)+K1(2)/2);
K2=inv(A1)*b;
%step 4
A2=J(x1(i)+K2(1)/2,x2(i)+K2(2)/2);
K3=inv(A2)*b;
%step 5
A3=J(x1(i)+K3(1),x2(i)+K3(2));
K4=inv(A3)*b;
x1(i+1)=x1(i)+(K1(1)+2*K2(1)+2*K3(1)+K4(1))/6;
x2(i+1)=x2(i)+(K1(2)+2*K2(2)+2*K3(2)+K4(2))/6;
end
x1=x1(end)
x2=x2(end)
%%%%%%%%% Answer %%%%%%%%


x1 =

2.1195


x2 =

-1.3723

>>

%%%%%%%% With initial condition x1=1, x2=2 %%%%%%%%%%

clc;
clear all;

N=2;

f1=@(x1,x2) x1^2-x2^2+2*x2;
f2=@(x1,x2) 2*x1+x2^2-6;
J=@(x1,x2)[2*x1 -2*x2+2;2 2*x2];
%intial conditions
x1(1)=1;
x2(1)=1;
F=[f1(x1,x2);f2(x1,x2)];
%step 1
h=1/N;
b=-h*F;
% Step 2
for i=1:2
A=J(x1(i),x2(i));
K1=inv(A)*b;
%step 3
A1=J(x1(i)+K1(1)/2,x2(i)+K1(2)/2);
K2=inv(A1)*b;
%step 4
A2=J(x1(i)+K2(1)/2,x2(i)+K2(2)/2);
K3=inv(A2)*b;
%step 5
A3=J(x1(i)+K3(1),x2(i)+K3(2));
K4=inv(A3)*b;
x1(i+1)=x1(i)+(K1(1)+2*K2(1)+2*K3(1)+K4(1))/6;
x2(i+1)=x2(i)+(K1(2)+2*K2(2)+2*K3(2)+K4(2))/6;
end
x1=x1(end)
x2=x2(end)


%%%%%%%%%%% Answer %%%%%%%%


x1 =

0.6213


x2 =

2.1899

>>

%%%%%%%%%%%% With initial condition x1=3, x2=-2 %%%%%%%%%

clc;
clear all;

N=2;

f1=@(x1,x2) x1^2-x2^2+2*x2;
f2=@(x1,x2) 2*x1+x2^2-6;
J=@(x1,x2)[2*x1 -2*x2+2;2 2*x2];
%intial conditions
x1(1)=3;
x2(1)=-2;
F=[f1(x1,x2);f2(x1,x2)];
%step 1
h=1/N;
b=-h*F;
% Step 2
for i=1:2
A=J(x1(i),x2(i));
K1=inv(A)*b;
%step 3
A1=J(x1(i)+K1(1)/2,x2(i)+K1(2)/2);
K2=inv(A1)*b;
%step 4
A2=J(x1(i)+K2(1)/2,x2(i)+K2(2)/2);
K3=inv(A2)*b;
%step 5
A3=J(x1(i)+K3(1),x2(i)+K3(2));
K4=inv(A3)*b;
x1(i+1)=x1(i)+(K1(1)+2*K2(1)+2*K3(1)+K4(1))/6;
x2(i+1)=x2(i)+(K1(2)+2*K2(2)+2*K3(2)+K4(2))/6;
end
x1=x1(end)
x2=x2(end)


%%%%%%%%%%%% Answer %%%%%%%%%%


x1 =

2.1095


x2 =

-1.3345

>>

Add a comment
Know the answer?
Add Answer to:
Given this pseudocode and problem (as an example), code the continuation algorithm in MATLAB. 1. The...
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
  • PLEASE USE MATLAB. The code is basically given to you with the algorithm above. Write a...

    PLEASE USE MATLAB. The code is basically given to you with the algorithm above. Write a program for solving the system Ar-b by using Gauss-Seidel iterative method discussed in class that uses a computer memory for one iterate only. This could be summarized as follows: Input n -- the size of the system, matrix A-(a(i,j), the vectoir b (b (1), . . . , b(n)), the intitial guess x (x(1), ..., x(n)) (you can use x=b) maximum number of iterations...

  • Use an algorithm that you would systematically follow to apply the technique and solve each set o...

    Use an algorithm that you would systematically follow to apply the technique and solve each set of systems of linear equations. For example, you may select the technique of finding the inverse of the coefficient matrix A, and then applying Theorem 1.6.2: x = A^-1 b. There are several ways that we have learned to find A^-1. Pick one of those ways to code or write as an algorithm. Or another example, you may select Cramer’s rule. Within Cramer’s rule,...

  • Let A = ( a1 0 ... 0 0 a2 ... 0 ... ... ... 0...

    Let A = ( a1 0 ... 0 0 a2 ... 0 ... ... ... 0 0 an) be an n * n matrix, where a1, a2, . . . , an are nonzero real numbers. (a) Find the general solution to the system of equations -> -> x'  = A * x (b) Solve the initial value problem x1(0) = x2(0) = · · · = xn(0) = k, for some constant k. (c) Solve the initial value problem (x1(0)  x2(0)...

  • MATLAB Coding Please state the right answer and give a little explanation why it's the right...

    MATLAB Coding Please state the right answer and give a little explanation why it's the right answer. Incorrect Question 9 0/1 pts A numerical algorithm is used to solve the following system of equations: x1 - x2 = 2 -2x1 + 5x2 = -1 The numerical results are x1 = 2.98 and x2 = 1.03. The Euclidean norm of the residuals is (to four decimal places): 0.0361 Incorrect Question 11 0/1 pts You have performed a curve fit to a...

  • I need help with the matlab code, thank you. The purpose of this assignment is to...

    I need help with the matlab code, thank you. The purpose of this assignment is to illustrate one important difference between linear and nonlinear models of oscillating systems. In an undamped, unforced linear system, the period of a periodic solution depends only on system parameters and not on the initial conditions, but in a nonlinear system the period can depend on the initial conditions Consider the following nonlinear differential equation, which models the free, undamped motion of a block attached...

  • Adams Fourth-Order Predictor-Corrector Python ONLY!! Please translate this pseudocode into Python code, thanks!! Adams Fourth-Order Predictor-Corrector...

    Adams Fourth-Order Predictor-Corrector Python ONLY!! Please translate this pseudocode into Python code, thanks!! Adams Fourth-Order Predictor-Corrector To approximate the solution of the initial-value problem y' = f(t, y), ast<b, y(a) = a, at (N + 1) equally spaced numbers in the interval [a, b]: INPUT endpoints a, b; integer N; initial condition a. OUTPUT approximation w to y at the (N + 1) values of t. Step 1 Set h = (b − a)/N; to = a; Wo = a;...

  • Use Newton's method to approximate the given number correct to eight decimal places. 20 Step 1...

    Use Newton's method to approximate the given number correct to eight decimal places. 20 Step 1 Note that x = V20 is a root of f(x) = x5 - 20. We need to find f'(x). Step 2 We know that xn+ 1 = xn- in +1 an f(x) . Therefore, f'(x) X n + 1 = xn-- Step 3 Since V32 = 2, and 32 is reasonably close to 20, we'll use x1 = 2. This gives us x2 =...

  • Please solve the above 4 questions. 1. Using the extended Euclidean Algorithm, find all solutions of the linear congrue...

    Please solve the above 4 questions. 1. Using the extended Euclidean Algorithm, find all solutions of the linear congruence 217x 133 (mod 329), where 0 x < 329 (Eg. if 5n, n 0,. ,6) 24 + 5n, п %3D 0, 1, . .., 6, type 24 + x< 11 2. Find all solutions of the congruence 7x = 5 (mod 11) where 0 (Eg. if 4,7 10, 13, type 4,7,10,13, none. or if there are no solutions, type I 3....

  • Using hand work for the parts with a paper next to them, and MatLab for the parts with the MatLab logo next to them, complete the following: Consider the linear BVP 4y " + 3y , + y = 0, 0<x&lt...

    Using hand work for the parts with a paper next to them, and MatLab for the parts with the MatLab logo next to them, complete the following: Consider the linear BVP 4y " + 3y , + y = 0, 0<x<1 y(0)1 You will define a set of linear equations for yi,0, (yi y(Xi), 1 = o,.. . ,n) and the set of nodes is with xi-ih, 1-0, . . . , n and h =-. n is a fixed...

  • Please answer this MATLAB questions when able. Thanks. 4. Laboratory Problem Description In this laboratory you...

    Please answer this MATLAB questions when able. Thanks. 4. Laboratory Problem Description In this laboratory you are required to Find the solution of the following systems of linear equation: 1) xl + x2 + x3 3 4x1 - x2 x3-2 x1 2x2 x3-2 2) 2 -1 3 A 1 3 -2. B-2 Given the following system 4x1+3x2+7x3- 3 3x1+2x2+1x3 1 2x1+3x2+4x3- 2 Using MATLAB commands solve the following system using Gaussian elimination with partial pivoting. Find P, L, and U...

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