SlideShare a Scribd company logo
function[p]=langrange(x,xint,y)
x=[1 2 5];
y=[1 4 10];
xint=3;
n=size(x,2)
L=ones(n,size(xint,2));
if (size(x,2)~=size(y,2));
fprint('error x and y have same values')
else
for i=1:n
for j=1:n
if(i~=j)
L(i,:)=L(i,:)*(xint-x(j))/(x(i)-x(j));
end
end
end
p=0;
for i=1:n
p=p+y(i)*(L(i,:));
end
end
--------------------
Taimoor Gondal
Asim Zahid
Umar Cheema

More Related Content

What's hot

ML: A Strongly Typed Functional Language
ML: A Strongly Typed Functional LanguageML: A Strongly Typed Functional Language
ML: A Strongly Typed Functional Language
lijx127
 

What's hot (15)

Complex Integral
Complex IntegralComplex Integral
Complex Integral
 
PythonArtCode
PythonArtCodePythonArtCode
PythonArtCode
 
Program to reflecta triangle
Program to reflecta triangleProgram to reflecta triangle
Program to reflecta triangle
 
Gp
GpGp
Gp
 
Segundo Punto
Segundo PuntoSegundo Punto
Segundo Punto
 
Trapezoidal log log
Trapezoidal log logTrapezoidal log log
Trapezoidal log log
 
Session07 recursion
Session07 recursionSession07 recursion
Session07 recursion
 
حساب النهايات جبرياً
حساب النهايات جبرياًحساب النهايات جبرياً
حساب النهايات جبرياً
 
Interpolation graph c++
Interpolation graph c++Interpolation graph c++
Interpolation graph c++
 
Rolle's theorem
Rolle's theorem Rolle's theorem
Rolle's theorem
 
CAML考古学
CAML考古学CAML考古学
CAML考古学
 
متاپست (MetaPost)
متاپست (MetaPost)متاپست (MetaPost)
متاپست (MetaPost)
 
ML: A Strongly Typed Functional Language
ML: A Strongly Typed Functional LanguageML: A Strongly Typed Functional Language
ML: A Strongly Typed Functional Language
 
Math 3-H6
Math 3-H6Math 3-H6
Math 3-H6
 
Mac Interview Workshop 2021
Mac Interview Workshop 2021Mac Interview Workshop 2021
Mac Interview Workshop 2021
 

More from Taimoor Muzaffar Gondal

More from Taimoor Muzaffar Gondal (20)

Basics of Computer
Basics of ComputerBasics of Computer
Basics of Computer
 
Lecture 04: Errors During the Measurement Process
Lecture 04: Errors During the Measurement ProcessLecture 04: Errors During the Measurement Process
Lecture 04: Errors During the Measurement Process
 
Introduction to Measurements-Lecture 01
Introduction to Measurements-Lecture 01Introduction to Measurements-Lecture 01
Introduction to Measurements-Lecture 01
 
Updated Lecture 01- History of Atom
Updated Lecture 01- History of AtomUpdated Lecture 01- History of Atom
Updated Lecture 01- History of Atom
 
Heat and Its Transfer
Heat and Its TransferHeat and Its Transfer
Heat and Its Transfer
 
Low, Medium and High Frequency Current
Low, Medium and High Frequency CurrentLow, Medium and High Frequency Current
Low, Medium and High Frequency Current
 
Rectification and Electrotherapy
Rectification and ElectrotherapyRectification and Electrotherapy
Rectification and Electrotherapy
 
Applications of EM Waves
Applications of EM WavesApplications of EM Waves
Applications of EM Waves
 
Electromagnetism Fundamentals
Electromagnetism FundamentalsElectromagnetism Fundamentals
Electromagnetism Fundamentals
 
Effects of Currents and Type of Cells and Batteries
Effects of Currents and Type of Cells and BatteriesEffects of Currents and Type of Cells and Batteries
Effects of Currents and Type of Cells and Batteries
 
Current Electricity
Current ElectricityCurrent Electricity
Current Electricity
 
Static Electricity
Static ElectricityStatic Electricity
Static Electricity
 
Lecture 01- Atomic Structure
Lecture 01- Atomic StructureLecture 01- Atomic Structure
Lecture 01- Atomic Structure
 
An Overview of PLC
An Overview of PLCAn Overview of PLC
An Overview of PLC
 
Regula falsi MATLAB Code
Regula falsi MATLAB CodeRegula falsi MATLAB Code
Regula falsi MATLAB Code
 
Jacobi method for MATLAB
Jacobi method for MATLAB Jacobi method for MATLAB
Jacobi method for MATLAB
 
Gauss seidal Matlab Code
Gauss seidal Matlab CodeGauss seidal Matlab Code
Gauss seidal Matlab Code
 
Finite difference Matlab Code
Finite difference Matlab CodeFinite difference Matlab Code
Finite difference Matlab Code
 
Divided difference Matlab code
Divided difference Matlab codeDivided difference Matlab code
Divided difference Matlab code
 
Bisection methode alternate
Bisection methode alternateBisection methode alternate
Bisection methode alternate
 

Recently uploaded

Online blood donation management system project.pdf
Online blood donation management system project.pdfOnline blood donation management system project.pdf
Online blood donation management system project.pdf
Kamal Acharya
 
Digital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdfDigital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdf
AbrahamGadissa
 
Hall booking system project report .pdf
Hall booking system project report  .pdfHall booking system project report  .pdf
Hall booking system project report .pdf
Kamal Acharya
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
Kamal Acharya
 
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsRS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
Atif Razi
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdf
Kamal Acharya
 

Recently uploaded (20)

Online blood donation management system project.pdf
Online blood donation management system project.pdfOnline blood donation management system project.pdf
Online blood donation management system project.pdf
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical EngineeringIntroduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
 
Digital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdfDigital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdf
 
Hall booking system project report .pdf
Hall booking system project report  .pdfHall booking system project report  .pdf
Hall booking system project report .pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
Peek implant persentation - Copy (1).pdf
Peek implant persentation - Copy (1).pdfPeek implant persentation - Copy (1).pdf
Peek implant persentation - Copy (1).pdf
 
fundamentals of drawing and isometric and orthographic projection
fundamentals of drawing and isometric and orthographic projectionfundamentals of drawing and isometric and orthographic projection
fundamentals of drawing and isometric and orthographic projection
 
Toll tax management system project report..pdf
Toll tax management system project report..pdfToll tax management system project report..pdf
Toll tax management system project report..pdf
 
Construction method of steel structure space frame .pptx
Construction method of steel structure space frame .pptxConstruction method of steel structure space frame .pptx
Construction method of steel structure space frame .pptx
 
Furniture showroom management system project.pdf
Furniture showroom management system project.pdfFurniture showroom management system project.pdf
Furniture showroom management system project.pdf
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
İTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopİTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering Workshop
 
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsRS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdf
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
 
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
 

Langrange method for MATLAB Code

  • 1. function[p]=langrange(x,xint,y) x=[1 2 5]; y=[1 4 10]; xint=3; n=size(x,2) L=ones(n,size(xint,2)); if (size(x,2)~=size(y,2)); fprint('error x and y have same values') else for i=1:n for j=1:n if(i~=j) L(i,:)=L(i,:)*(xint-x(j))/(x(i)-x(j)); end end end p=0; for i=1:n p=p+y(i)*(L(i,:)); end end -------------------- Taimoor Gondal Asim Zahid Umar Cheema