SlideShare uma empresa Scribd logo
1 de 9
Baixar para ler offline
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;)" 
}

Mais conteúdo relacionado

Mais procurados

Bank management system project in c++ with graphics
Bank management system project in c++ with graphicsBank management system project in c++ with graphics
Bank management system project in c++ with graphicsVtech Academy of Computers
 
ゲーム理論NEXT 線形計画問題第3回 -関連定理の証明-
ゲーム理論NEXT 線形計画問題第3回 -関連定理の証明-ゲーム理論NEXT 線形計画問題第3回 -関連定理の証明-
ゲーム理論NEXT 線形計画問題第3回 -関連定理の証明-ssusere0a682
 
Part2 from math import * from simpson import * k=1 def f(x): return (exp(-(x...
Part2 from math import * from simpson import *  k=1 def f(x): return (exp(-(x...Part2 from math import * from simpson import *  k=1 def f(x): return (exp(-(x...
Part2 from math import * from simpson import * k=1 def f(x): return (exp(-(x...hwbloom25
 
Creating masterpieces with raphael
Creating masterpieces with raphaelCreating masterpieces with raphael
Creating masterpieces with raphaelPippi Labradoodle
 
C++ Programming - 14th Study
C++ Programming - 14th StudyC++ Programming - 14th Study
C++ Programming - 14th StudyChris Ohk
 
Programa en C++ ( escriba 3 números y diga cual es el mayor))
Programa en C++ ( escriba 3 números y diga cual es el mayor))Programa en C++ ( escriba 3 números y diga cual es el mayor))
Programa en C++ ( escriba 3 números y diga cual es el mayor))Alex Penso Romero
 
imager package in R and examples..
imager package in R and examples..imager package in R and examples..
imager package in R and examples..Dr. Volkan OBAN
 
Print input-presentation
Print input-presentationPrint input-presentation
Print input-presentationMartin McBride
 

Mais procurados (18)

C++ TUTORIAL 5
C++ TUTORIAL 5C++ TUTORIAL 5
C++ TUTORIAL 5
 
Myraytracer
MyraytracerMyraytracer
Myraytracer
 
C++ TUTORIAL 3
C++ TUTORIAL 3C++ TUTORIAL 3
C++ TUTORIAL 3
 
C++ TUTORIAL 4
C++ TUTORIAL 4C++ TUTORIAL 4
C++ TUTORIAL 4
 
Página 115
Página 115Página 115
Página 115
 
Bank management system project in c++ with graphics
Bank management system project in c++ with graphicsBank management system project in c++ with graphics
Bank management system project in c++ with graphics
 
Code
CodeCode
Code
 
dplyr
dplyrdplyr
dplyr
 
Railwaynew
RailwaynewRailwaynew
Railwaynew
 
ゲーム理論NEXT 線形計画問題第3回 -関連定理の証明-
ゲーム理論NEXT 線形計画問題第3回 -関連定理の証明-ゲーム理論NEXT 線形計画問題第3回 -関連定理の証明-
ゲーム理論NEXT 線形計画問題第3回 -関連定理の証明-
 
Mosaic plot in R.
Mosaic plot in R.Mosaic plot in R.
Mosaic plot in R.
 
Part2 from math import * from simpson import * k=1 def f(x): return (exp(-(x...
Part2 from math import * from simpson import *  k=1 def f(x): return (exp(-(x...Part2 from math import * from simpson import *  k=1 def f(x): return (exp(-(x...
Part2 from math import * from simpson import * k=1 def f(x): return (exp(-(x...
 
Creating masterpieces with raphael
Creating masterpieces with raphaelCreating masterpieces with raphael
Creating masterpieces with raphael
 
Vcs9
Vcs9Vcs9
Vcs9
 
C++ Programming - 14th Study
C++ Programming - 14th StudyC++ Programming - 14th Study
C++ Programming - 14th Study
 
Programa en C++ ( escriba 3 números y diga cual es el mayor))
Programa en C++ ( escriba 3 números y diga cual es el mayor))Programa en C++ ( escriba 3 números y diga cual es el mayor))
Programa en C++ ( escriba 3 números y diga cual es el mayor))
 
imager package in R and examples..
imager package in R and examples..imager package in R and examples..
imager package in R and examples..
 
Print input-presentation
Print input-presentationPrint input-presentation
Print input-presentation
 

Destaque

Recursion transformer
Recursion transformerRecursion transformer
Recursion transformerlnikolaeva
 
Union in C programming
Union in C programmingUnion in C programming
Union in C programmingKamal Acharya
 
Secondary storage structure
Secondary storage structureSecondary storage structure
Secondary storage structurePriya Selvaraj
 
Learning C++ - Functions in C++ 3
Learning C++ - Functions  in C++ 3Learning C++ - Functions  in C++ 3
Learning C++ - Functions in C++ 3Ali Aminian
 
Secondary storage structure-Operating System Concepts
Secondary storage structure-Operating System ConceptsSecondary storage structure-Operating System Concepts
Secondary storage structure-Operating System ConceptsArjun Kaimattathil
 
4. Recursion - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patil4. Recursion - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
Numerical integration
Numerical integrationNumerical integration
Numerical integrationMohammed_AQ
 
Numerical integration
Numerical integrationNumerical integration
Numerical integrationSunny Chauhan
 
PowerPoint Tutorial Presentation - 100 Pictures
PowerPoint Tutorial Presentation - 100 PicturesPowerPoint Tutorial Presentation - 100 Pictures
PowerPoint Tutorial Presentation - 100 PicturesNiezette -
 

Destaque (17)

Algorithms
AlgorithmsAlgorithms
Algorithms
 
Recursion transformer
Recursion transformerRecursion transformer
Recursion transformer
 
Recursive Function
Recursive FunctionRecursive Function
Recursive Function
 
Union in C programming
Union in C programmingUnion in C programming
Union in C programming
 
Secondary storage structure
Secondary storage structureSecondary storage structure
Secondary storage structure
 
The Algebra of Functions
The Algebra of FunctionsThe Algebra of Functions
The Algebra of Functions
 
Learning C++ - Functions in C++ 3
Learning C++ - Functions  in C++ 3Learning C++ - Functions  in C++ 3
Learning C++ - Functions in C++ 3
 
Secondary storage structure-Operating System Concepts
Secondary storage structure-Operating System ConceptsSecondary storage structure-Operating System Concepts
Secondary storage structure-Operating System Concepts
 
Disk scheduling
Disk schedulingDisk scheduling
Disk scheduling
 
4. Recursion - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patil4. Recursion - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patil
 
Numerical integration
Numerical integrationNumerical integration
Numerical integration
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Numerical integration
Numerical integrationNumerical integration
Numerical integration
 
Ch10
Ch10Ch10
Ch10
 
PowerPoint Tutorial Presentation - 100 Pictures
PowerPoint Tutorial Presentation - 100 PicturesPowerPoint Tutorial Presentation - 100 Pictures
PowerPoint Tutorial Presentation - 100 Pictures
 
Pandi
PandiPandi
Pandi
 
Recursion
RecursionRecursion
Recursion
 

Semelhante a Simpson and lagranje dalambair math methods

Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptkinan keshkeh
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptkinan keshkeh
 
Chainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみたChainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみたAkira Maruoka
 
Modificacion del programa
Modificacion del programaModificacion del programa
Modificacion del programaMario José
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloadingkinan keshkeh
 
DS & Algo 1 - C++ and STL Introduction
DS & Algo 1 - C++ and STL IntroductionDS & Algo 1 - C++ and STL Introduction
DS & Algo 1 - C++ and STL IntroductionMohammad Imam Hossain
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101premrings
 
Ee 3122 numerical methods and statistics sessional credit
Ee 3122 numerical methods and statistics sessional  creditEe 3122 numerical methods and statistics sessional  credit
Ee 3122 numerical methods and statistics sessional creditRaihan Bin-Mofidul
 
C++ Lambda and concurrency
C++ Lambda and concurrencyC++ Lambda and concurrency
C++ Lambda and concurrency명신 김
 
Program(Output)
Program(Output)Program(Output)
Program(Output)princy75
 
ZeroMQ: Messaging Made Simple
ZeroMQ: Messaging Made SimpleZeroMQ: Messaging Made Simple
ZeroMQ: Messaging Made SimpleIan Barber
 
Tugas praktikukm pemrograman c++
Tugas praktikukm  pemrograman c++Tugas praktikukm  pemrograman c++
Tugas praktikukm pemrograman c++Dendi Riadi
 

Semelhante a Simpson and lagranje dalambair math methods (20)

Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop concept
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop concept
 
week-2x
week-2xweek-2x
week-2x
 
Chainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみたChainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみた
 
Modificacion del programa
Modificacion del programaModificacion del programa
Modificacion del programa
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
 
C++ file
C++ fileC++ file
C++ file
 
C++ file
C++ fileC++ file
C++ file
 
DS & Algo 1 - C++ and STL Introduction
DS & Algo 1 - C++ and STL IntroductionDS & Algo 1 - C++ and STL Introduction
DS & Algo 1 - C++ and STL Introduction
 
CPP Homework Help
CPP Homework HelpCPP Homework Help
CPP Homework Help
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
 
12
1212
12
 
Ee 3122 numerical methods and statistics sessional credit
Ee 3122 numerical methods and statistics sessional  creditEe 3122 numerical methods and statistics sessional  credit
Ee 3122 numerical methods and statistics sessional credit
 
C++ Lambda and concurrency
C++ Lambda and concurrencyC++ Lambda and concurrency
C++ Lambda and concurrency
 
Program(Output)
Program(Output)Program(Output)
Program(Output)
 
Tu1
Tu1Tu1
Tu1
 
Ch4
Ch4Ch4
Ch4
 
ZeroMQ: Messaging Made Simple
ZeroMQ: Messaging Made SimpleZeroMQ: Messaging Made Simple
ZeroMQ: Messaging Made Simple
 
Tugas praktikukm pemrograman c++
Tugas praktikukm  pemrograman c++Tugas praktikukm  pemrograman c++
Tugas praktikukm pemrograman c++
 
Project in programming
Project in programmingProject in programming
Project in programming
 

Mais de kinan keshkeh

10 Little Tricks to Get Your Class’s Attention (and Hold It)
10 Little Tricks to Get Your  Class’s Attention (and Hold It)10 Little Tricks to Get Your  Class’s Attention (and Hold It)
10 Little Tricks to Get Your Class’s Attention (and Hold It)kinan keshkeh
 
GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm  GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm kinan keshkeh
 
Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...kinan keshkeh
 
2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graphkinan keshkeh
 
2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_unitskinan keshkeh
 
2Bytesprog2 course_2014_c7_double_lists
2Bytesprog2 course_2014_c7_double_lists2Bytesprog2 course_2014_c7_double_lists
2Bytesprog2 course_2014_c7_double_listskinan keshkeh
 
2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked list2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked listkinan keshkeh
 
2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointerskinan keshkeh
 
2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfiles2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfileskinan keshkeh
 
2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfiles2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfileskinan keshkeh
 
2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_records2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_recordskinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_setskinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_setskinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_setskinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_setskinan keshkeh
 
2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templateskinan keshkeh
 
2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphism2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphismkinan keshkeh
 
2 BytesC++ course_2014_c11_ inheritance
2 BytesC++ course_2014_c11_ inheritance2 BytesC++ course_2014_c11_ inheritance
2 BytesC++ course_2014_c11_ inheritancekinan keshkeh
 
2 BytesC++ course_2014_c10_ separate compilation and namespaces
2 BytesC++ course_2014_c10_ separate compilation and namespaces 2 BytesC++ course_2014_c10_ separate compilation and namespaces
2 BytesC++ course_2014_c10_ separate compilation and namespaces kinan keshkeh
 
2 BytesC++ course_2014_c9_ pointers and dynamic arrays
2 BytesC++ course_2014_c9_ pointers and dynamic arrays 2 BytesC++ course_2014_c9_ pointers and dynamic arrays
2 BytesC++ course_2014_c9_ pointers and dynamic arrays kinan keshkeh
 

Mais de kinan keshkeh (20)

10 Little Tricks to Get Your Class’s Attention (and Hold It)
10 Little Tricks to Get Your  Class’s Attention (and Hold It)10 Little Tricks to Get Your  Class’s Attention (and Hold It)
10 Little Tricks to Get Your Class’s Attention (and Hold It)
 
GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm  GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm
 
Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...
 
2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph
 
2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units
 
2Bytesprog2 course_2014_c7_double_lists
2Bytesprog2 course_2014_c7_double_lists2Bytesprog2 course_2014_c7_double_lists
2Bytesprog2 course_2014_c7_double_lists
 
2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked list2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked list
 
2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers
 
2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfiles2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfiles
 
2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfiles2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfiles
 
2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_records2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_records
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates
 
2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphism2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphism
 
2 BytesC++ course_2014_c11_ inheritance
2 BytesC++ course_2014_c11_ inheritance2 BytesC++ course_2014_c11_ inheritance
2 BytesC++ course_2014_c11_ inheritance
 
2 BytesC++ course_2014_c10_ separate compilation and namespaces
2 BytesC++ course_2014_c10_ separate compilation and namespaces 2 BytesC++ course_2014_c10_ separate compilation and namespaces
2 BytesC++ course_2014_c10_ separate compilation and namespaces
 
2 BytesC++ course_2014_c9_ pointers and dynamic arrays
2 BytesC++ course_2014_c9_ pointers and dynamic arrays 2 BytesC++ course_2014_c9_ pointers and dynamic arrays
2 BytesC++ course_2014_c9_ pointers and dynamic arrays
 

Último

Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...OnePlan Solutions
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptxVinzoCenzo
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITmanoharjgpsolutions
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jNeo4j
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
Data modeling 101 - Basics - Software Domain
Data modeling 101 - Basics - Software DomainData modeling 101 - Basics - Software Domain
Data modeling 101 - Basics - Software DomainAbdul Ahad
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfkalichargn70th171
 

Último (20)

Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptx
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh IT
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
Data modeling 101 - Basics - Software Domain
Data modeling 101 - Basics - Software DomainData modeling 101 - Basics - Software Domain
Data modeling 101 - Basics - Software Domain
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
 

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;)" }