SlideShare a Scribd company logo
1 of 3
Download to read offline
Write 2 function files in matlab : one for fixed-point iteration for a system of equations and one
for Newton’s method for a system of equations. Determine what your inputs and outputs should
be. Test the code on the following system. the code must also take convergence into
consideration.
x2- y
x- y2
Solution
Matlab codes;
Main function;
%clearing window, variables and figures
clear all;
close all;
clf;
clc;
fixed()
newton()
%fixed approach function
function fixed()
fprintf(' Fixed point approach ');
syms x;
f1=x; %first function
f2=sqrt(x); %second function
%for function 1;
%equation is in terms of x,x=0;
x=sym(0);
fprintf(' Value of function is 0 as x is already at zero ');
%Checking convergence;
f1dash=1 %Finding derivative f1 w.r.t x
x=sym(0);
fprintf(' The first function converge as f1dash is constant ');
fprintf(' Value of function is 0 as x is already at zero');
%for function 2;
%equation is in terms of x,x=0;
x=sym(0);
%Checking convergence;
f2dash=(1/2)*(1/sqrt(x)); %Finding derivative w.r.t x
fprintf(' The second function converges as for negative infinity, absolute of f2dash is =0 or <1
');
fprintf(' Value of function is 0 as x is already at zero');
%Newton raphson method approach
function newton()
fprintf(' Newton raphson approach ');
syms x;
f1=x; %first function
f2=sqrt(x); %second function
%for function 1;
xo=sym(1);
error=5;
while(error>.01)
f1dash=diff(f1,x);
x=sym(xo);
dx=-eval(f1)/f1dash;
x1=xo+dx;
x=sym(x1);
fc=eval(f1);
x=sym(xo);
fe=eval(f1);
error=fc-fe;
xo=x1;
end
xo
f2=sqrt(x); %second function
%for function 1;
xo=sym(1);
error=5;
while(error>.01)
f2dash=diff(f2,x);
x=sym(xo);
dx=-eval(f2)/f2dash;
x1=xo+dx;
x=sym(x1);
fc=eval(f2);
x=sym(xo);
fe=eval(f2);
error=fc-fe;
x0=x1;
end
xo
fprintf(' Both the functions converges for any value of x ');
Result;
Value of function is 0 as x is already at zero
f1dash =
1
The first function converge as f1dash is constant
Value of function is 0 as x is already at zero
The second function converges as for negative infinity, absolute of f2dash is =0 or <1
Value of function is 0 as x is already at zero
Newton raphson approach
xo =
0
xo =
1
Both the functions converges for any value of x

More Related Content

Similar to Matlab functions for fixed point iteration and Newton's method to solve a system of equations

Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabMohan Raj
 
Matlab for beginners, Introduction, signal processing
Matlab for beginners, Introduction, signal processingMatlab for beginners, Introduction, signal processing
Matlab for beginners, Introduction, signal processingDr. Manjunatha. P
 
Control Structures in C
Control Structures in CControl Structures in C
Control Structures in Csana shaikh
 
Chapter 5 Balagurusamy Programming ANSI in c
Chapter 5 Balagurusamy Programming ANSI  in cChapter 5 Balagurusamy Programming ANSI  in c
Chapter 5 Balagurusamy Programming ANSI in cBUBT
 
คำสั่ง Switch
คำสั่ง Switchคำสั่ง Switch
คำสั่ง Switchkramsri
 
Matlab practical file
Matlab practical fileMatlab practical file
Matlab practical fileArchita Misra
 
Check the output of the following code then recode it to eliminate fu
 Check the output of the following code then recode it to eliminate fu Check the output of the following code then recode it to eliminate fu
Check the output of the following code then recode it to eliminate fulicservernoida
 
Csci101 lect02 selection_andlooping
Csci101 lect02 selection_andloopingCsci101 lect02 selection_andlooping
Csci101 lect02 selection_andloopingElsayed Hemayed
 
02 iec t1_s1_oo_ps_session_02
02 iec t1_s1_oo_ps_session_0202 iec t1_s1_oo_ps_session_02
02 iec t1_s1_oo_ps_session_02Pooja Gupta
 
eee2-day4-structures engineering college
eee2-day4-structures engineering collegeeee2-day4-structures engineering college
eee2-day4-structures engineering college2017eee0459
 
curve fitting or regression analysis-1.pptx
curve fitting or regression analysis-1.pptxcurve fitting or regression analysis-1.pptx
curve fitting or regression analysis-1.pptxabelmeketa
 
Scilab for real dummies j.heikell - part 2
Scilab for real dummies j.heikell - part 2Scilab for real dummies j.heikell - part 2
Scilab for real dummies j.heikell - part 2Scilab
 

Similar to Matlab functions for fixed point iteration and Newton's method to solve a system of equations (20)

Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Matlab for beginners, Introduction, signal processing
Matlab for beginners, Introduction, signal processingMatlab for beginners, Introduction, signal processing
Matlab for beginners, Introduction, signal processing
 
Correlation
CorrelationCorrelation
Correlation
 
Control Structures in C
Control Structures in CControl Structures in C
Control Structures in C
 
Chapter 5 Balagurusamy Programming ANSI in c
Chapter 5 Balagurusamy Programming ANSI  in cChapter 5 Balagurusamy Programming ANSI  in c
Chapter 5 Balagurusamy Programming ANSI in c
 
คำสั่ง Switch
คำสั่ง Switchคำสั่ง Switch
คำสั่ง Switch
 
EPE821_Lecture3.pptx
EPE821_Lecture3.pptxEPE821_Lecture3.pptx
EPE821_Lecture3.pptx
 
Matlab-3.pptx
Matlab-3.pptxMatlab-3.pptx
Matlab-3.pptx
 
Matlab practical file
Matlab practical fileMatlab practical file
Matlab practical file
 
Check the output of the following code then recode it to eliminate fu
 Check the output of the following code then recode it to eliminate fu Check the output of the following code then recode it to eliminate fu
Check the output of the following code then recode it to eliminate fu
 
Csci101 lect02 selection_andlooping
Csci101 lect02 selection_andloopingCsci101 lect02 selection_andlooping
Csci101 lect02 selection_andlooping
 
02 iec t1_s1_oo_ps_session_02
02 iec t1_s1_oo_ps_session_0202 iec t1_s1_oo_ps_session_02
02 iec t1_s1_oo_ps_session_02
 
Lr4 math cad
Lr4 math cadLr4 math cad
Lr4 math cad
 
eee2-day4-structures engineering college
eee2-day4-structures engineering collegeeee2-day4-structures engineering college
eee2-day4-structures engineering college
 
05 dataflow
05 dataflow05 dataflow
05 dataflow
 
curve fitting or regression analysis-1.pptx
curve fitting or regression analysis-1.pptxcurve fitting or regression analysis-1.pptx
curve fitting or regression analysis-1.pptx
 
Quiz
QuizQuiz
Quiz
 
Scilab for real dummies j.heikell - part 2
Scilab for real dummies j.heikell - part 2Scilab for real dummies j.heikell - part 2
Scilab for real dummies j.heikell - part 2
 
Week 4
Week 4Week 4
Week 4
 
scientific computing
scientific computingscientific computing
scientific computing
 

More from neetuarya13

Find the total cost of making a triangular sail that has a base dime.pdf
Find the total cost of making a triangular sail that has a base dime.pdfFind the total cost of making a triangular sail that has a base dime.pdf
Find the total cost of making a triangular sail that has a base dime.pdfneetuarya13
 
Explain Charge, Current, Volta Power and Energy. Also explain relatio.pdf
Explain Charge, Current, Volta Power and Energy. Also explain relatio.pdfExplain Charge, Current, Volta Power and Energy. Also explain relatio.pdf
Explain Charge, Current, Volta Power and Energy. Also explain relatio.pdfneetuarya13
 
Define Managerial Accounting. Why do managers utilize managerial acc.pdf
Define Managerial Accounting. Why do managers utilize managerial acc.pdfDefine Managerial Accounting. Why do managers utilize managerial acc.pdf
Define Managerial Accounting. Why do managers utilize managerial acc.pdfneetuarya13
 
Describe how a third-generation language (3GL) programming language .pdf
Describe how a third-generation language (3GL) programming language .pdfDescribe how a third-generation language (3GL) programming language .pdf
Describe how a third-generation language (3GL) programming language .pdfneetuarya13
 
Biologists have very specific terminology (thats one of the things.pdf
Biologists have very specific terminology (thats one of the things.pdfBiologists have very specific terminology (thats one of the things.pdf
Biologists have very specific terminology (thats one of the things.pdfneetuarya13
 
Bacteria Characteristics Indole oxidase VP Cell Catalase reaction Sha.pdf
Bacteria Characteristics Indole oxidase VP Cell Catalase reaction Sha.pdfBacteria Characteristics Indole oxidase VP Cell Catalase reaction Sha.pdf
Bacteria Characteristics Indole oxidase VP Cell Catalase reaction Sha.pdfneetuarya13
 
All of the following interactions can help hold the tertiary structur.pdf
All of the following interactions can help hold the tertiary structur.pdfAll of the following interactions can help hold the tertiary structur.pdf
All of the following interactions can help hold the tertiary structur.pdfneetuarya13
 
According to the figure below, which of the following statements reg.pdf
According to the figure below, which of the following statements reg.pdfAccording to the figure below, which of the following statements reg.pdf
According to the figure below, which of the following statements reg.pdfneetuarya13
 
3. A plant breeder crosses an inbred soybean cultivar with herbicide.pdf
3. A plant breeder crosses an inbred soybean cultivar with herbicide.pdf3. A plant breeder crosses an inbred soybean cultivar with herbicide.pdf
3. A plant breeder crosses an inbred soybean cultivar with herbicide.pdfneetuarya13
 
A mirror faces a cliff located some distance away. Mounted on the cli.pdf
A mirror faces a cliff located some distance away. Mounted on the cli.pdfA mirror faces a cliff located some distance away. Mounted on the cli.pdf
A mirror faces a cliff located some distance away. Mounted on the cli.pdfneetuarya13
 
Why is it important to identify Classes early in the Unified Process.pdf
Why is it important to identify Classes early in the Unified Process.pdfWhy is it important to identify Classes early in the Unified Process.pdf
Why is it important to identify Classes early in the Unified Process.pdfneetuarya13
 
A male Drosophila melanogaster has the genotype Aa; Bb; Cc; XDY..pdf
A male Drosophila melanogaster has the genotype Aa; Bb; Cc; XDY..pdfA male Drosophila melanogaster has the genotype Aa; Bb; Cc; XDY..pdf
A male Drosophila melanogaster has the genotype Aa; Bb; Cc; XDY..pdfneetuarya13
 
Which of the following facilitated the endosymbiotic acquisition of .pdf
Which of the following facilitated the endosymbiotic acquisition of .pdfWhich of the following facilitated the endosymbiotic acquisition of .pdf
Which of the following facilitated the endosymbiotic acquisition of .pdfneetuarya13
 
Which of the following is true about replication    The lagging s.pdf
Which of the following is true about replication    The lagging s.pdfWhich of the following is true about replication    The lagging s.pdf
Which of the following is true about replication    The lagging s.pdfneetuarya13
 
Which is a common trait among all land plantsVascular tissues tra.pdf
Which is a common trait among all land plantsVascular tissues tra.pdfWhich is a common trait among all land plantsVascular tissues tra.pdf
Which is a common trait among all land plantsVascular tissues tra.pdfneetuarya13
 
Which of the following is an example of company whose business model .pdf
Which of the following is an example of company whose business model .pdfWhich of the following is an example of company whose business model .pdf
Which of the following is an example of company whose business model .pdfneetuarya13
 
what role(s) played by the Equatorial Segment Protein 1 (ESP1) durin.pdf
what role(s) played by the Equatorial Segment Protein 1 (ESP1) durin.pdfwhat role(s) played by the Equatorial Segment Protein 1 (ESP1) durin.pdf
what role(s) played by the Equatorial Segment Protein 1 (ESP1) durin.pdfneetuarya13
 
What are the similarities and differences between simple linear regr.pdf
What are the similarities and differences between simple linear regr.pdfWhat are the similarities and differences between simple linear regr.pdf
What are the similarities and differences between simple linear regr.pdfneetuarya13
 
What does it mean if a human female oocyte is no longer arrested in .pdf
What does it mean if a human female oocyte is no longer arrested in .pdfWhat does it mean if a human female oocyte is no longer arrested in .pdf
What does it mean if a human female oocyte is no longer arrested in .pdfneetuarya13
 
What is so important about the cells in the HeLo cell cultureWhat.pdf
What is so important about the cells in the HeLo cell cultureWhat.pdfWhat is so important about the cells in the HeLo cell cultureWhat.pdf
What is so important about the cells in the HeLo cell cultureWhat.pdfneetuarya13
 

More from neetuarya13 (20)

Find the total cost of making a triangular sail that has a base dime.pdf
Find the total cost of making a triangular sail that has a base dime.pdfFind the total cost of making a triangular sail that has a base dime.pdf
Find the total cost of making a triangular sail that has a base dime.pdf
 
Explain Charge, Current, Volta Power and Energy. Also explain relatio.pdf
Explain Charge, Current, Volta Power and Energy. Also explain relatio.pdfExplain Charge, Current, Volta Power and Energy. Also explain relatio.pdf
Explain Charge, Current, Volta Power and Energy. Also explain relatio.pdf
 
Define Managerial Accounting. Why do managers utilize managerial acc.pdf
Define Managerial Accounting. Why do managers utilize managerial acc.pdfDefine Managerial Accounting. Why do managers utilize managerial acc.pdf
Define Managerial Accounting. Why do managers utilize managerial acc.pdf
 
Describe how a third-generation language (3GL) programming language .pdf
Describe how a third-generation language (3GL) programming language .pdfDescribe how a third-generation language (3GL) programming language .pdf
Describe how a third-generation language (3GL) programming language .pdf
 
Biologists have very specific terminology (thats one of the things.pdf
Biologists have very specific terminology (thats one of the things.pdfBiologists have very specific terminology (thats one of the things.pdf
Biologists have very specific terminology (thats one of the things.pdf
 
Bacteria Characteristics Indole oxidase VP Cell Catalase reaction Sha.pdf
Bacteria Characteristics Indole oxidase VP Cell Catalase reaction Sha.pdfBacteria Characteristics Indole oxidase VP Cell Catalase reaction Sha.pdf
Bacteria Characteristics Indole oxidase VP Cell Catalase reaction Sha.pdf
 
All of the following interactions can help hold the tertiary structur.pdf
All of the following interactions can help hold the tertiary structur.pdfAll of the following interactions can help hold the tertiary structur.pdf
All of the following interactions can help hold the tertiary structur.pdf
 
According to the figure below, which of the following statements reg.pdf
According to the figure below, which of the following statements reg.pdfAccording to the figure below, which of the following statements reg.pdf
According to the figure below, which of the following statements reg.pdf
 
3. A plant breeder crosses an inbred soybean cultivar with herbicide.pdf
3. A plant breeder crosses an inbred soybean cultivar with herbicide.pdf3. A plant breeder crosses an inbred soybean cultivar with herbicide.pdf
3. A plant breeder crosses an inbred soybean cultivar with herbicide.pdf
 
A mirror faces a cliff located some distance away. Mounted on the cli.pdf
A mirror faces a cliff located some distance away. Mounted on the cli.pdfA mirror faces a cliff located some distance away. Mounted on the cli.pdf
A mirror faces a cliff located some distance away. Mounted on the cli.pdf
 
Why is it important to identify Classes early in the Unified Process.pdf
Why is it important to identify Classes early in the Unified Process.pdfWhy is it important to identify Classes early in the Unified Process.pdf
Why is it important to identify Classes early in the Unified Process.pdf
 
A male Drosophila melanogaster has the genotype Aa; Bb; Cc; XDY..pdf
A male Drosophila melanogaster has the genotype Aa; Bb; Cc; XDY..pdfA male Drosophila melanogaster has the genotype Aa; Bb; Cc; XDY..pdf
A male Drosophila melanogaster has the genotype Aa; Bb; Cc; XDY..pdf
 
Which of the following facilitated the endosymbiotic acquisition of .pdf
Which of the following facilitated the endosymbiotic acquisition of .pdfWhich of the following facilitated the endosymbiotic acquisition of .pdf
Which of the following facilitated the endosymbiotic acquisition of .pdf
 
Which of the following is true about replication    The lagging s.pdf
Which of the following is true about replication    The lagging s.pdfWhich of the following is true about replication    The lagging s.pdf
Which of the following is true about replication    The lagging s.pdf
 
Which is a common trait among all land plantsVascular tissues tra.pdf
Which is a common trait among all land plantsVascular tissues tra.pdfWhich is a common trait among all land plantsVascular tissues tra.pdf
Which is a common trait among all land plantsVascular tissues tra.pdf
 
Which of the following is an example of company whose business model .pdf
Which of the following is an example of company whose business model .pdfWhich of the following is an example of company whose business model .pdf
Which of the following is an example of company whose business model .pdf
 
what role(s) played by the Equatorial Segment Protein 1 (ESP1) durin.pdf
what role(s) played by the Equatorial Segment Protein 1 (ESP1) durin.pdfwhat role(s) played by the Equatorial Segment Protein 1 (ESP1) durin.pdf
what role(s) played by the Equatorial Segment Protein 1 (ESP1) durin.pdf
 
What are the similarities and differences between simple linear regr.pdf
What are the similarities and differences between simple linear regr.pdfWhat are the similarities and differences between simple linear regr.pdf
What are the similarities and differences between simple linear regr.pdf
 
What does it mean if a human female oocyte is no longer arrested in .pdf
What does it mean if a human female oocyte is no longer arrested in .pdfWhat does it mean if a human female oocyte is no longer arrested in .pdf
What does it mean if a human female oocyte is no longer arrested in .pdf
 
What is so important about the cells in the HeLo cell cultureWhat.pdf
What is so important about the cells in the HeLo cell cultureWhat.pdfWhat is so important about the cells in the HeLo cell cultureWhat.pdf
What is so important about the cells in the HeLo cell cultureWhat.pdf
 

Recently uploaded

What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 

Recently uploaded (20)

ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 

Matlab functions for fixed point iteration and Newton's method to solve a system of equations

  • 1. Write 2 function files in matlab : one for fixed-point iteration for a system of equations and one for Newton’s method for a system of equations. Determine what your inputs and outputs should be. Test the code on the following system. the code must also take convergence into consideration. x2- y x- y2 Solution Matlab codes; Main function; %clearing window, variables and figures clear all; close all; clf; clc; fixed() newton() %fixed approach function function fixed() fprintf(' Fixed point approach '); syms x; f1=x; %first function f2=sqrt(x); %second function %for function 1; %equation is in terms of x,x=0; x=sym(0); fprintf(' Value of function is 0 as x is already at zero '); %Checking convergence; f1dash=1 %Finding derivative f1 w.r.t x x=sym(0); fprintf(' The first function converge as f1dash is constant '); fprintf(' Value of function is 0 as x is already at zero'); %for function 2; %equation is in terms of x,x=0;
  • 2. x=sym(0); %Checking convergence; f2dash=(1/2)*(1/sqrt(x)); %Finding derivative w.r.t x fprintf(' The second function converges as for negative infinity, absolute of f2dash is =0 or <1 '); fprintf(' Value of function is 0 as x is already at zero'); %Newton raphson method approach function newton() fprintf(' Newton raphson approach '); syms x; f1=x; %first function f2=sqrt(x); %second function %for function 1; xo=sym(1); error=5; while(error>.01) f1dash=diff(f1,x); x=sym(xo); dx=-eval(f1)/f1dash; x1=xo+dx; x=sym(x1); fc=eval(f1); x=sym(xo); fe=eval(f1); error=fc-fe; xo=x1; end xo f2=sqrt(x); %second function %for function 1; xo=sym(1); error=5; while(error>.01) f2dash=diff(f2,x); x=sym(xo); dx=-eval(f2)/f2dash;
  • 3. x1=xo+dx; x=sym(x1); fc=eval(f2); x=sym(xo); fe=eval(f2); error=fc-fe; x0=x1; end xo fprintf(' Both the functions converges for any value of x '); Result; Value of function is 0 as x is already at zero f1dash = 1 The first function converge as f1dash is constant Value of function is 0 as x is already at zero The second function converges as for negative infinity, absolute of f2dash is =0 or <1 Value of function is 0 as x is already at zero Newton raphson approach xo = 0 xo = 1 Both the functions converges for any value of x