static double IntegrationRectangleGauche(fctAIntegrer f, double bg, double bd, int n) { double Aire = 0; double x = bg; double p = (bd - bg) / n; for (int i = 0; i < n; i++) { Aire += p * f(x); x += p; } return(Aire); }
private void btnCosinus_Click(object sender, EventArgs e) { double a, b; int nbInt; if (double.TryParse(tbGauche.Text, out a) && double.TryParse(tbDroite.Text, out b) && int.TryParse(tbIntervalle.Text, out nbInt)) { lbResultats.Items.Clear(); fctAIntegrer f = new fctAIntegrer(fctCosins); for (int i = 0; i < 5; i++) { lbResultats.Items.Add("Nb int= " + nbInt + " => " + IntegrationRectangleGauche(f, a, b, nbInt)); nbInt *= 2; } } else { MessageBox.Show("Verifier vos entrees"); } }