0% found this document useful (0 votes)
187 views

Laborator 2 Probabilitate Sandu

This document is a laboratory work from the Faculty of Mathematics and Computer Science at the State University of Moldova. It discusses calculating the definite integral of sin(x^2 + y^2) over the domain π^2 ≤ x^2 + y^2 ≤ 4π^2 using the Monte Carlo method. The student Cristian Sandu presents the C++ code used to estimate the integral and obtain a result of -59.1576, matching the actual value of -6π^2.

Uploaded by

Dan Celac
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
187 views

Laborator 2 Probabilitate Sandu

This document is a laboratory work from the Faculty of Mathematics and Computer Science at the State University of Moldova. It discusses calculating the definite integral of sin(x^2 + y^2) over the domain π^2 ≤ x^2 + y^2 ≤ 4π^2 using the Monte Carlo method. The student Cristian Sandu presents the C++ code used to estimate the integral and obtain a result of -59.1576, matching the actual value of -6π^2.

Uploaded by

Dan Celac
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Ministerul Educatiei al Republicii Moldova

Universitatea de Stat din Moldova

Facultatea de Matematica si Informatica

Lucrare de laborator
[ nr.II ]
Disciplina: Probabilitati
si Statistica
Tema: Calculul integralei definite prin metoda Monte-Carlo

Realizat : Sandu Cristian,


Studentul anului-II [Grupa I21]
Verificat : Topala Oleg
(dr.conf.,univer)

Chisinau 2015

Varianta 6
6.

sin
G

x 2 y 2 dxdy

, G: x 2 + y 2 42
(R: - 6 2) (-59.1576)

Graficul pentru domeniul G : x 2 + y 2 42 este

///*********************************************************
#include<stdlib.h>
#include<time.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<iostream>
using namespace std;
int main()
{
srand((unsigned int)time(NULL));
int nr_puncte;
float Suma=0;
float Integrala;
float pi=3.1415;
double x,y;
cout<<"\nIntroduceti numarul de puncte: ";
cin>>nr_puncte;
for(int i=0; i<nr_puncte; i++)

{
///**********************************************************
x=((double) rand() / (RAND_MAX+1)*12.566) ;//aruncam intre -2p si 2p
x-=6.283;
y=((double) rand() / (RAND_MAX+1)*12.566) ; //aruncam intre -2p si 2p
y-=6.283;
//cout<<"\n\tX=> "<<x<<"\tY=> "<<y<<endl;
///**********************************************************
if( ( pow(x,2)+pow(y,2)>=pow(pi,2) ) &&
( (pow(x,2)+pow(y,2)<=4*pow(pi,2)) ) )
///***********************************************************
Suma=Suma+(sin(sqrt(pow(x,2)+pow(y,2))));
///***********************************************************
Integrala=((Suma)/nr_puncte)*(pow(2*2*pi,2));
///***********************************************************
}
cout<<"\nSuma este egala cu => "<<Suma;
cout<<"\n\nIntegrala este egala cu => "<<Integrala;
getch();
}

Rezultat :

You might also like