SlideShare a Scribd company logo
Damascus University 
Faculty of Information Technology Engineering 
Simpson and Lagranje Dalambair math methods
CODE: 
#include<iostream> 
#include<cmath> 
#include"graphics.h" 
using namespace std; 
void simpson(double x0,double xn,int en, double f[100][100],double& sum1) 
{ 
double h; 
double* b= new double[en] ; // F( Xi) 
h=(xn-x0)/en; // h 
//Find points 
cout<<"Now put for each point Xi .. its F(xi): n;" 
for(int i=0; i<=en;i)++ 
{ 
cout<<"F( "<<x0+(i*h;" = )"<<) 
cin>>b[i;] 
} 
//calculate the INTEGRATION!!!! 
//double sum1; 
sum1=b[0]+b[en]; // sum=f0 + fn 
for(int i=1; i<en; i)++ 
{ 
if(i % 2 !=0) 
sum1=sum1+4*b[i;] 
else 
sum1=sum1+2*b[i;] 
} 
sum1=sum1*(h/3) ;// I= h/3 [f0 + 4f1+ 2f2 + 4f3+ 2f4+ .... +fn] 
// copy to the F array 
for(int i=0;i<=en;i)++ 
{ 
f[1][i]=b[i;] 
f[0][i]=x0+i*h; 
} 
} 
void fillarr(double a[][100] , int n) 
{ 
for(int i=0; i<=1; i++) // first row X0 
for(int j=0; j<=n ; j++) //second row Y0 
{
if( i==0) 
cout<<"X "<<j;" = "<< 
else 
cout<<"Y "<<j;" = "<< 
cin>>a[i][j;] 
} 
} 
double p(double a[][100],int n , double x) 
{ 
double res,sum,temp; 
sum=0; 
for(int i=0; i<=n; i)++ 
{ 
res=1; 
for(int j=0; j<=n ; j)++ 
{ 
if(j != i) 
res=res*(x-a[0][j;)] 
} 
temp=1; 
for(int k=0;k<=n; k)++ 
{ 
if(k!=i) 
temp=temp*(a[0][i]-a[0][k;)] 
} 
res=res/temp ; 
res=res*a[1][i]; // * (y0,y1..., 
sum=sum+res; 
} 
return sum; 
} 
void print(double a[][100] , int n) 
{ 
cout<<"P"<<n<<"(x;" =) 
double temp; 
for(int i=0; i<=n;i)++ 
{ 
temp=1; 
for(int j=0; j<=n;j)++ 
{ 
if(j!=i)
temp=temp*(a[0][i]-a[0][j;)] 
} 
temp=a[1][i]/temp; 
if(temp>0 && i!=0) 
cout<<"+"<<temp; 
else if (temp==0) 
cout<<"0;" 
else 
cout<<temp; 
if(temp!=0) 
{ 
for(int k=0; k<= n ; k)++ 
{ 
if(k!= i) 
{ 
if(a[0][k]<0) 
cout<<"(x + "<<fabs(a[0][k;" )"<<)] 
else if(a[0][k]>0) 
cout<<"(x - "<<a[0][k;" )"<<] 
else 
cout<<"( x;") 
} 
} 
} 
} 
cout<<endl; 
} 
void get_xy(double wxb ,double wyb ,double wxt ,double wyt ,int vxt ,int vyt ,int vxb ,int vyb ,double wx ,double wy ,int& vx, int & vy) 
{ 
double sx,sy; 
sx=abs((vxb-vxt)/(wxt-wxb;) ) 
sy=abs((vyb-vyt)/(wyt-wyb;) ) 
vx=(vxt+( wx-wxb)*sx;) 
vy=(vyb-( wy-wyb)*sy;) 
} 
void draw_function (double a[][100] , int n) 
{ 
// Variables for graphics 
initwindow(1000, 650, "Function Ploting"); //initilize windows 
int maxx=getmaxx;)( 
int maxy=getmaxy;)( 
double x1,x2,y1,y2; 
int nx1,nx2,ny1,ny2;
double x00=-70 ,xm=70, n_graph=2000; //domain of x [x00, xm] 
double wyb=-49.8, wyt=50; 
double dx; dx=abs(xm-x00)/n_graph; 
x1=x00 ; 
y1=p(a,n-1,x1;) 
get_xy(x00,wyb,xm,wyt,0,0,maxx,maxy,x1,y1,nx1,ny1); // get x y after appropriate coordinates 
for(int i=1; i<=n_graph; i)++ 
{ 
x2=x00+(i*dx;) 
y2=p(a,n-1,x2;) 
get_xy(x00,wyb,xm,wyt,0,0,maxx,maxy,x2,y2,nx2,ny2;) 
line(nx1,ny1,nx2,ny2;) 
nx1=nx2; 
ny1=ny2; 
} 
outtextxy(30,0,"Approximetely Drawing");outtextxy(maxx-200,maxy-30,"Student:kinan-keshkeh;)" 
*/ draw Ordinates */ setcolor(10); line(0, maxy/ 2,maxx,maxy / 2); line(maxx / 2,0,maxx / 2,maxy ;) 
} 
void main_menu(int & q) 
{ 
cout<<"|----------------------------------------------------------------------|n;" 
cout<<"| CHOICE MENU |n; " 
cout<<"|-----|----|-----------------------------------------------------------|n;" 
cout<<"| |(1)-| (Interpolation)Lagranje Dalambair 'press (1) ' |n;" 
cout<<"| --|----|------------------------------------------- |n;" 
cout<<"| |(2)-| (Integration )Simpson 'press (2) ' |n;" 
cout<<"| --|----|------------------------------------------- |n;" 
cout<<"| |(0)-| Exit 'press (0) ' |n ;" 
cout<<"| --|----|------------------------------------------- |n;" 
cin>>q; 
} 
void menu2(int & q1) 
{ 
cout<<"|----------------------------------------------------------------------|n;"
cout<<"| CHOICE MENU |n; " 
cout<<"|-----|----|-----------------------------------------------------------|n;" 
cout<<"| |(1)-| calculate (Integration )Simpson 'press (1) ' |n;" 
cout<<"| --|----|------------------------------------------- |n;" 
cout<<"| |(2)-| Draw F(x) 'press (2) ' |n;" 
cout<<"| --|----|------------------------------------------- |n;" 
cout<<"| |(00)| to Main_Menu.. 'press (00) ' |n;" 
cout<<"| --|----|------------------------------------------- |n;" 
cin>>q1; 
} 
void menu(int & y) 
{ 
cout<<"|----------------------------------------------------------------------|n;" 
cout<<"| CHOICE MENU |n; " 
cout<<"|-----|----|-----------------------------------------------------------|n;" 
cout<<"| |(1)-| Put the Xi / Yi 'press (1) ' |n;" 
cout<<"| --|----|------------------------------------------- |n;" 
cout<<"| |(2)-| print the Lagranj Function for this points 'press (2) ' |n;" 
cout<<"| --|----|------------------------------------------- |n;" 
cout<<"| |(3)-| Find Pn(b) 'press (3) ' |n;" 
cout<<"| --|----|------------------------------------------- |n;" 
cout<<"| |(4)-| Draw F(x) 'press (4) ' |n;" 
cout<<"| --|----|------------------------------------------- |n;" 
cout<<"| |(0)-| to Main_Menu.. 'press (0) ' |n;" 
cout<<"|-----|----|-----------------------------------------------------------|n;" 
cout<<"|----------------------------------------------------------------------|n;" 
cout<<"enter your choice;" : 
cin>>y; 
} 
void main)( 
{ 
//double v1,v2; //for draw domain [v1,v2] 
cout.setf(ios::fixed); // to print just 4 numbers after the Point 
cout.setf(ios::showpoint;) 
cout.precision(2;) 
int q; main_menu(q;) 
while (q!=0) 
{ 
switch(q) 
{
case 1{ : 
//////////////////////////////////////////////////////Lagranj///////////////////////////////////////////////////// 
int n,y; double a[100][100;] 
double x; 
menu(y); //Print the menu and get choice y 
while (y!=0) 
{ 
switch(y) 
{ 
case 1 : { cout<<" How many points?? n;" 
cout<<"put the number of points : N= n; " 
cin>>n; 
fillarr(a,n-1;) 
menu(y ;) 
break; 
} 
case 2{ : 
cout<<"Two numbers after POINT: ex (0.00) (!!more than 2 may not seen!!! )n;" 
print(a,n-1 ;) 
menu(y ;) 
break; 
} 
case 3{ : 
cout<<"Put the X0 : f(x0)....n"; cin>>x; 
cout<<"P"<<n-1<<"("<<x<<") = "<<p(a,n-1,x)<<endl; 
menu(y ;) 
break; 
} 
case 4: 
{ 
draw_function(a,n-1;) 
menu(y ;) 
break; 
} 
case 0 : { cout<<" :) :) End program My wishes :) :) !! n;" 
menu(y ;) 
break } ; 
default:{ cout<<"Error in choice !!! n ;" 
menu(y); //Print the menu and get choice y
break} ; 
// }switch 
cout<<".................................... n;" 
} 
main_menu(q;) 
break;}//case 1 
//////////////////////////////////////////////////////Simpson///////////////////////////////////////////////////// 
case 2: 
{ 
int q1; double x0,xn; int en; double sum1,sum2; 
double f[100][100;] 
menu2(q1;) 
while (q1!=0) 
{ 
switch(q1) 
{ 
case 1: 
{ 
cout<<" Put the Domain [ X0, Xn ]n;" 
cout<<" X0 = "; cin>>x0; cout<<" Xn = "; cin>>xn; 
cout<<" Put the NUmber of Domains u want to Divide into them(even) : n"; cin>>en; 
if(en %2 !=0) // en isn't Even 
{ 
cout<<"YOUR "<<en<<" is not Even and i will calculat by another way !! n;" 
cout<<"simpson(fo -->fn-1) + simpson(fn-1-->fn)n;" 
simpson(x0,xn-((xn-x0)/en),en-1,f,sum1); //fo -->fn-1 
simpson(xn-((xn-x0)/en),xn,en-1,f,sum2); //fn-1-->fn 
cout<<"The Integration fo -->fn-1 = I1 = "<<sum1<<endl; 
cout<<"The Integration fn-1-->fn = I2 = "<<sum2<<endl; 
cout<<"The Integration = I = "<<sum1+sum2<<endl; 
} 
else 
{ 
simpson(x0,xn,en,f,sum1;) 
cout<<"The Integration = I = "<<sum1<<endl; 
} 
menu2(q1;) 
break; 
}
case 2: { draw_function(f,en-1);menu2(q1); break}; 
case 00 : { break} ; 
default:{ cout<<"Error choice!!!n"; menu2(q1); break} ; 
//}switch 
} 
main_menu(q;) 
break; 
//}case 2 
case 0 : 
{ 
cout<<":) Best wishes >>>End Program>>>>>>>>>>>>>>>> n;" 
break}; 
default:{ cout<<"Error In choice!!!!!!!!! n"; main_menu(q); break } ; 
} 
} 
//while q != 0 
system("pause;)" 
}

More Related Content

PDF
C++ TUTORIAL 6
Farhan Ab Rahman
 
PDF
C++ TUTORIAL 10
Farhan Ab Rahman
 
PDF
C++ TUTORIAL 9
Farhan Ab Rahman
 
PDF
C++ TUTORIAL 7
Farhan Ab Rahman
 
PPTX
Super Advanced Python –act1
Ke Wei Louis
 
PDF
ES6, WTF?
James Ford
 
KEY
cocos2d 事例編 HungryMasterの実装から
Yuichi Higuchi
 
PDF
C++ TUTORIAL 1
Farhan Ab Rahman
 
C++ TUTORIAL 6
Farhan Ab Rahman
 
C++ TUTORIAL 10
Farhan Ab Rahman
 
C++ TUTORIAL 9
Farhan Ab Rahman
 
C++ TUTORIAL 7
Farhan Ab Rahman
 
Super Advanced Python –act1
Ke Wei Louis
 
ES6, WTF?
James Ford
 
cocos2d 事例編 HungryMasterの実装から
Yuichi Higuchi
 
C++ TUTORIAL 1
Farhan Ab Rahman
 

What's hot (18)

PDF
C++ TUTORIAL 5
Farhan Ab Rahman
 
PDF
Myraytracer
kedar nath
 
PDF
C++ TUTORIAL 3
Farhan Ab Rahman
 
PDF
C++ TUTORIAL 4
Farhan Ab Rahman
 
PDF
Página 115
Ludwig Varg Lombardo
 
PPTX
Bank management system project in c++ with graphics
Vtech Academy of Computers
 
DOCX
Code
Fran Orton
 
PDF
dplyr
Romain Francois
 
TXT
Railwaynew
Arsh Vishwakarma
 
PDF
ゲーム理論NEXT 線形計画問題第3回 -関連定理の証明-
ssusere0a682
 
DOCX
Mosaic plot in R.
Dr. Volkan OBAN
 
PDF
Part2 from math import * from simpson import * k=1 def f(x): return (exp(-(x...
hwbloom25
 
ODP
Creating masterpieces with raphael
Pippi Labradoodle
 
PDF
C++ Programming - 14th Study
Chris Ohk
 
DOCX
Programa en C++ ( escriba 3 números y diga cual es el mayor))
Alex Penso Romero
 
DOCX
imager package in R and examples..
Dr. Volkan OBAN
 
PPTX
Print input-presentation
Martin McBride
 
C++ TUTORIAL 5
Farhan Ab Rahman
 
Myraytracer
kedar nath
 
C++ TUTORIAL 3
Farhan Ab Rahman
 
C++ TUTORIAL 4
Farhan Ab Rahman
 
Bank management system project in c++ with graphics
Vtech Academy of Computers
 
Railwaynew
Arsh Vishwakarma
 
ゲーム理論NEXT 線形計画問題第3回 -関連定理の証明-
ssusere0a682
 
Mosaic plot in R.
Dr. Volkan OBAN
 
Part2 from math import * from simpson import * k=1 def f(x): return (exp(-(x...
hwbloom25
 
Creating masterpieces with raphael
Pippi Labradoodle
 
C++ Programming - 14th Study
Chris Ohk
 
Programa en C++ ( escriba 3 números y diga cual es el mayor))
Alex Penso Romero
 
imager package in R and examples..
Dr. Volkan OBAN
 
Print input-presentation
Martin McBride
 
Ad

Viewers also liked (17)

ODP
Algorithms
Olga Fedoseeva
 
PPTX
Recursion transformer
lnikolaeva
 
PPTX
Recursive Function
Kamal Acharya
 
PPTX
Union in C programming
Kamal Acharya
 
PPTX
Secondary storage structure
Priya Selvaraj
 
DOCX
The Algebra of Functions
Christopher Gratton
 
PPTX
Learning C++ - Functions in C++ 3
Ali Aminian
 
PPT
Secondary storage structure-Operating System Concepts
Arjun Kaimattathil
 
PPT
Disk scheduling
Agnas Jasmine
 
PPTX
4. Recursion - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
PPTX
Numerical integration
Mohammed_AQ
 
PPT
Functions in C++
Sachin Sharma
 
PPT
Numerical integration
Sunny Chauhan
 
PPT
Ch10
ushaindhu
 
PPT
PowerPoint Tutorial Presentation - 100 Pictures
Niezette -
 
PPT
Pandi
Pandi C
 
PPTX
Recursion
Jesmin Akhter
 
Algorithms
Olga Fedoseeva
 
Recursion transformer
lnikolaeva
 
Recursive Function
Kamal Acharya
 
Union in C programming
Kamal Acharya
 
Secondary storage structure
Priya Selvaraj
 
The Algebra of Functions
Christopher Gratton
 
Learning C++ - Functions in C++ 3
Ali Aminian
 
Secondary storage structure-Operating System Concepts
Arjun Kaimattathil
 
Disk scheduling
Agnas Jasmine
 
4. Recursion - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
Numerical integration
Mohammed_AQ
 
Functions in C++
Sachin Sharma
 
Numerical integration
Sunny Chauhan
 
Ch10
ushaindhu
 
PowerPoint Tutorial Presentation - 100 Pictures
Niezette -
 
Pandi
Pandi C
 
Recursion
Jesmin Akhter
 
Ad

Similar to Simpson and lagranje dalambair math methods (20)

PDF
C++ manual Report Full
Thesis Scientist Private Limited
 
PDF
C programs
Adnan Vallippadan
 
DOCX
Interpolation graph c++
rpiitcbme
 
PDF
C# Assignmet Help
Programming Homework Help
 
PDF
#ifndef RATIONAL_H   if this compiler macro is not defined #def.pdf
exxonzone
 
DOCX
Oops lab manual
Vivek Kumar Sinha
 
PDF
Please follow the cod eand comments for description CODE #incl.pdf
annaielectronicsvill
 
PDF
Shapes and calculate (area and contour) / C++ oop concept
kinan keshkeh
 
PDF
I wrote the following change it to having a header, main and cpp fi.pdf
rishteygallery
 
PDF
Rkf
faintcardy
 
DOCX
cosc 281 hw3
Brian Goggins
 
PDF
Will th ebelow code work andif not please help me fix it. Basically .pdf
michaelazach6427
 
PDF
Here is The code in C language .pdf
geetakannupillai1
 
DOCX
Listing modul 4
indraatmaja
 
PDF
Please write it in C not python .pdf
abhisheksharmasre
 
PDF
#include iostream #include deque #include stdio.h   scan.pdf
anandmobile
 
PDF
Fraction.h #include iostream #ifndef FRACTION #define FR.pdf
ravikapoorindia
 
PDF
Modify the code in C Please .pdf
adityaenterprise32
 
C++ manual Report Full
Thesis Scientist Private Limited
 
C programs
Adnan Vallippadan
 
Interpolation graph c++
rpiitcbme
 
C# Assignmet Help
Programming Homework Help
 
#ifndef RATIONAL_H   if this compiler macro is not defined #def.pdf
exxonzone
 
Oops lab manual
Vivek Kumar Sinha
 
Please follow the cod eand comments for description CODE #incl.pdf
annaielectronicsvill
 
Shapes and calculate (area and contour) / C++ oop concept
kinan keshkeh
 
I wrote the following change it to having a header, main and cpp fi.pdf
rishteygallery
 
cosc 281 hw3
Brian Goggins
 
Will th ebelow code work andif not please help me fix it. Basically .pdf
michaelazach6427
 
Here is The code in C language .pdf
geetakannupillai1
 
Listing modul 4
indraatmaja
 
Please write it in C not python .pdf
abhisheksharmasre
 
#include iostream #include deque #include stdio.h   scan.pdf
anandmobile
 
Fraction.h #include iostream #ifndef FRACTION #define FR.pdf
ravikapoorindia
 
Modify the code in C Please .pdf
adityaenterprise32
 

More from kinan keshkeh (20)

PDF
10 Little Tricks to Get Your Class’s Attention (and Hold It)
kinan keshkeh
 
PDF
Shapes and calculate (area and contour) / C++ oop concept
kinan keshkeh
 
PDF
GeneticAlgorithms_AND_CuttingWoodAlgorithm
kinan keshkeh
 
PDF
Algorithm in discovering and correcting words errors in a dictionary or any w...
kinan keshkeh
 
PDF
2Bytesprog2 course_2014_c9_graph
kinan keshkeh
 
PDF
2Bytesprog2 course_2014_c8_units
kinan keshkeh
 
PDF
2Bytesprog2 course_2014_c7_double_lists
kinan keshkeh
 
PDF
2Bytesprog2 course_2014_c6_single linked list
kinan keshkeh
 
PDF
2Bytesprog2 course_2014_c5_pointers
kinan keshkeh
 
PDF
2Bytesprog2 course_2014_c4_binaryfiles
kinan keshkeh
 
PDF
2Bytesprog2 course_2014_c3_txtfiles
kinan keshkeh
 
PDF
2Bytesprog2 course_2014_c2_records
kinan keshkeh
 
PDF
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
PDF
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
PDF
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
PDF
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
PDF
2 BytesC++ course_2014_c13_ templates
kinan keshkeh
 
PDF
2 BytesC++ course_2014_c12_ polymorphism
kinan keshkeh
 
PDF
2 BytesC++ course_2014_c11_ inheritance
kinan keshkeh
 
PDF
2 BytesC++ course_2014_c10_ separate compilation and namespaces
kinan keshkeh
 
10 Little Tricks to Get Your Class’s Attention (and Hold It)
kinan keshkeh
 
Shapes and calculate (area and contour) / C++ oop concept
kinan keshkeh
 
GeneticAlgorithms_AND_CuttingWoodAlgorithm
kinan keshkeh
 
Algorithm in discovering and correcting words errors in a dictionary or any w...
kinan keshkeh
 
2Bytesprog2 course_2014_c9_graph
kinan keshkeh
 
2Bytesprog2 course_2014_c8_units
kinan keshkeh
 
2Bytesprog2 course_2014_c7_double_lists
kinan keshkeh
 
2Bytesprog2 course_2014_c6_single linked list
kinan keshkeh
 
2Bytesprog2 course_2014_c5_pointers
kinan keshkeh
 
2Bytesprog2 course_2014_c4_binaryfiles
kinan keshkeh
 
2Bytesprog2 course_2014_c3_txtfiles
kinan keshkeh
 
2Bytesprog2 course_2014_c2_records
kinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
2 BytesC++ course_2014_c13_ templates
kinan keshkeh
 
2 BytesC++ course_2014_c12_ polymorphism
kinan keshkeh
 
2 BytesC++ course_2014_c11_ inheritance
kinan keshkeh
 
2 BytesC++ course_2014_c10_ separate compilation and namespaces
kinan keshkeh
 

Recently uploaded (20)

PDF
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
PPTX
Odoo Integration Services by Candidroot Solutions
CandidRoot Solutions Private Limited
 
PPTX
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
PPTX
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
PPTX
Visualising Data with Scatterplots in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
PDF
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
PDF
Protecting the Digital World Cyber Securit
dnthakkar16
 
PDF
Teaching Reproducibility and Embracing Variability: From Floating-Point Exper...
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
PPTX
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
PPTX
Presentation about variables and constant.pptx
safalsingh810
 
PDF
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
PPTX
oapresentation.pptx
mehatdhavalrajubhai
 
PDF
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
PDF
Bandai Playdia The Book - David Glotz
BluePanther6
 
PPTX
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
PDF
Key Features to Look for in Arizona App Development Services
Net-Craft.com
 
PDF
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
PPTX
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
PDF
Appium Automation Testing Tutorial PDF: Learn Mobile Testing in 7 Days
jamescantor38
 
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
Odoo Integration Services by Candidroot Solutions
CandidRoot Solutions Private Limited
 
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
Visualising Data with Scatterplots in IBM SPSS Statistics.pptx
Version 1 Analytics
 
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
Protecting the Digital World Cyber Securit
dnthakkar16
 
Teaching Reproducibility and Embracing Variability: From Floating-Point Exper...
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
Presentation about variables and constant.pptx
safalsingh810
 
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
oapresentation.pptx
mehatdhavalrajubhai
 
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
Bandai Playdia The Book - David Glotz
BluePanther6
 
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
Key Features to Look for in Arizona App Development Services
Net-Craft.com
 
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
Appium Automation Testing Tutorial PDF: Learn Mobile Testing in 7 Days
jamescantor38
 

Simpson and lagranje dalambair math methods

  • 1. Damascus University Faculty of Information Technology Engineering Simpson and Lagranje Dalambair math methods
  • 2. CODE: #include<iostream> #include<cmath> #include"graphics.h" using namespace std; void simpson(double x0,double xn,int en, double f[100][100],double& sum1) { double h; double* b= new double[en] ; // F( Xi) h=(xn-x0)/en; // h //Find points cout<<"Now put for each point Xi .. its F(xi): n;" for(int i=0; i<=en;i)++ { cout<<"F( "<<x0+(i*h;" = )"<<) cin>>b[i;] } //calculate the INTEGRATION!!!! //double sum1; sum1=b[0]+b[en]; // sum=f0 + fn for(int i=1; i<en; i)++ { if(i % 2 !=0) sum1=sum1+4*b[i;] else sum1=sum1+2*b[i;] } sum1=sum1*(h/3) ;// I= h/3 [f0 + 4f1+ 2f2 + 4f3+ 2f4+ .... +fn] // copy to the F array for(int i=0;i<=en;i)++ { f[1][i]=b[i;] f[0][i]=x0+i*h; } } void fillarr(double a[][100] , int n) { for(int i=0; i<=1; i++) // first row X0 for(int j=0; j<=n ; j++) //second row Y0 {
  • 3. if( i==0) cout<<"X "<<j;" = "<< else cout<<"Y "<<j;" = "<< cin>>a[i][j;] } } double p(double a[][100],int n , double x) { double res,sum,temp; sum=0; for(int i=0; i<=n; i)++ { res=1; for(int j=0; j<=n ; j)++ { if(j != i) res=res*(x-a[0][j;)] } temp=1; for(int k=0;k<=n; k)++ { if(k!=i) temp=temp*(a[0][i]-a[0][k;)] } res=res/temp ; res=res*a[1][i]; // * (y0,y1..., sum=sum+res; } return sum; } void print(double a[][100] , int n) { cout<<"P"<<n<<"(x;" =) double temp; for(int i=0; i<=n;i)++ { temp=1; for(int j=0; j<=n;j)++ { if(j!=i)
  • 4. temp=temp*(a[0][i]-a[0][j;)] } temp=a[1][i]/temp; if(temp>0 && i!=0) cout<<"+"<<temp; else if (temp==0) cout<<"0;" else cout<<temp; if(temp!=0) { for(int k=0; k<= n ; k)++ { if(k!= i) { if(a[0][k]<0) cout<<"(x + "<<fabs(a[0][k;" )"<<)] else if(a[0][k]>0) cout<<"(x - "<<a[0][k;" )"<<] else cout<<"( x;") } } } } cout<<endl; } void get_xy(double wxb ,double wyb ,double wxt ,double wyt ,int vxt ,int vyt ,int vxb ,int vyb ,double wx ,double wy ,int& vx, int & vy) { double sx,sy; sx=abs((vxb-vxt)/(wxt-wxb;) ) sy=abs((vyb-vyt)/(wyt-wyb;) ) vx=(vxt+( wx-wxb)*sx;) vy=(vyb-( wy-wyb)*sy;) } void draw_function (double a[][100] , int n) { // Variables for graphics initwindow(1000, 650, "Function Ploting"); //initilize windows int maxx=getmaxx;)( int maxy=getmaxy;)( double x1,x2,y1,y2; int nx1,nx2,ny1,ny2;
  • 5. double x00=-70 ,xm=70, n_graph=2000; //domain of x [x00, xm] double wyb=-49.8, wyt=50; double dx; dx=abs(xm-x00)/n_graph; x1=x00 ; y1=p(a,n-1,x1;) get_xy(x00,wyb,xm,wyt,0,0,maxx,maxy,x1,y1,nx1,ny1); // get x y after appropriate coordinates for(int i=1; i<=n_graph; i)++ { x2=x00+(i*dx;) y2=p(a,n-1,x2;) get_xy(x00,wyb,xm,wyt,0,0,maxx,maxy,x2,y2,nx2,ny2;) line(nx1,ny1,nx2,ny2;) nx1=nx2; ny1=ny2; } outtextxy(30,0,"Approximetely Drawing");outtextxy(maxx-200,maxy-30,"Student:kinan-keshkeh;)" */ draw Ordinates */ setcolor(10); line(0, maxy/ 2,maxx,maxy / 2); line(maxx / 2,0,maxx / 2,maxy ;) } void main_menu(int & q) { cout<<"|----------------------------------------------------------------------|n;" cout<<"| CHOICE MENU |n; " cout<<"|-----|----|-----------------------------------------------------------|n;" cout<<"| |(1)-| (Interpolation)Lagranje Dalambair 'press (1) ' |n;" cout<<"| --|----|------------------------------------------- |n;" cout<<"| |(2)-| (Integration )Simpson 'press (2) ' |n;" cout<<"| --|----|------------------------------------------- |n;" cout<<"| |(0)-| Exit 'press (0) ' |n ;" cout<<"| --|----|------------------------------------------- |n;" cin>>q; } void menu2(int & q1) { cout<<"|----------------------------------------------------------------------|n;"
  • 6. cout<<"| CHOICE MENU |n; " cout<<"|-----|----|-----------------------------------------------------------|n;" cout<<"| |(1)-| calculate (Integration )Simpson 'press (1) ' |n;" cout<<"| --|----|------------------------------------------- |n;" cout<<"| |(2)-| Draw F(x) 'press (2) ' |n;" cout<<"| --|----|------------------------------------------- |n;" cout<<"| |(00)| to Main_Menu.. 'press (00) ' |n;" cout<<"| --|----|------------------------------------------- |n;" cin>>q1; } void menu(int & y) { cout<<"|----------------------------------------------------------------------|n;" cout<<"| CHOICE MENU |n; " cout<<"|-----|----|-----------------------------------------------------------|n;" cout<<"| |(1)-| Put the Xi / Yi 'press (1) ' |n;" cout<<"| --|----|------------------------------------------- |n;" cout<<"| |(2)-| print the Lagranj Function for this points 'press (2) ' |n;" cout<<"| --|----|------------------------------------------- |n;" cout<<"| |(3)-| Find Pn(b) 'press (3) ' |n;" cout<<"| --|----|------------------------------------------- |n;" cout<<"| |(4)-| Draw F(x) 'press (4) ' |n;" cout<<"| --|----|------------------------------------------- |n;" cout<<"| |(0)-| to Main_Menu.. 'press (0) ' |n;" cout<<"|-----|----|-----------------------------------------------------------|n;" cout<<"|----------------------------------------------------------------------|n;" cout<<"enter your choice;" : cin>>y; } void main)( { //double v1,v2; //for draw domain [v1,v2] cout.setf(ios::fixed); // to print just 4 numbers after the Point cout.setf(ios::showpoint;) cout.precision(2;) int q; main_menu(q;) while (q!=0) { switch(q) {
  • 7. case 1{ : //////////////////////////////////////////////////////Lagranj///////////////////////////////////////////////////// int n,y; double a[100][100;] double x; menu(y); //Print the menu and get choice y while (y!=0) { switch(y) { case 1 : { cout<<" How many points?? n;" cout<<"put the number of points : N= n; " cin>>n; fillarr(a,n-1;) menu(y ;) break; } case 2{ : cout<<"Two numbers after POINT: ex (0.00) (!!more than 2 may not seen!!! )n;" print(a,n-1 ;) menu(y ;) break; } case 3{ : cout<<"Put the X0 : f(x0)....n"; cin>>x; cout<<"P"<<n-1<<"("<<x<<") = "<<p(a,n-1,x)<<endl; menu(y ;) break; } case 4: { draw_function(a,n-1;) menu(y ;) break; } case 0 : { cout<<" :) :) End program My wishes :) :) !! n;" menu(y ;) break } ; default:{ cout<<"Error in choice !!! n ;" menu(y); //Print the menu and get choice y
  • 8. break} ; // }switch cout<<".................................... n;" } main_menu(q;) break;}//case 1 //////////////////////////////////////////////////////Simpson///////////////////////////////////////////////////// case 2: { int q1; double x0,xn; int en; double sum1,sum2; double f[100][100;] menu2(q1;) while (q1!=0) { switch(q1) { case 1: { cout<<" Put the Domain [ X0, Xn ]n;" cout<<" X0 = "; cin>>x0; cout<<" Xn = "; cin>>xn; cout<<" Put the NUmber of Domains u want to Divide into them(even) : n"; cin>>en; if(en %2 !=0) // en isn't Even { cout<<"YOUR "<<en<<" is not Even and i will calculat by another way !! n;" cout<<"simpson(fo -->fn-1) + simpson(fn-1-->fn)n;" simpson(x0,xn-((xn-x0)/en),en-1,f,sum1); //fo -->fn-1 simpson(xn-((xn-x0)/en),xn,en-1,f,sum2); //fn-1-->fn cout<<"The Integration fo -->fn-1 = I1 = "<<sum1<<endl; cout<<"The Integration fn-1-->fn = I2 = "<<sum2<<endl; cout<<"The Integration = I = "<<sum1+sum2<<endl; } else { simpson(x0,xn,en,f,sum1;) cout<<"The Integration = I = "<<sum1<<endl; } menu2(q1;) break; }
  • 9. case 2: { draw_function(f,en-1);menu2(q1); break}; case 00 : { break} ; default:{ cout<<"Error choice!!!n"; menu2(q1); break} ; //}switch } main_menu(q;) break; //}case 2 case 0 : { cout<<":) Best wishes >>>End Program>>>>>>>>>>>>>>>> n;" break}; default:{ cout<<"Error In choice!!!!!!!!! n"; main_menu(q); break } ; } } //while q != 0 system("pause;)" }