static double IntegrationRectangleGauche(Fct_AIntegrer 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 Btn_Cosinus_Click(object sender, EventArgs e) { if (double.TryParse(Tb_Gauche.Text, out double a) && double.TryParse(TB_Droite.Text, out double b) && int.TryParse(TB_Intervalle.Text, out int Nb_Int)) { LB_Resultat.Items.Clear(); Fct_AIntegrer f = new Fct_AIntegrer(Fct_Cosinus); for (int i = 0; i < 5; i++) { LB_Resultat.Items.Add("Nb int = " + Nb_Int + " => " + IntegrationRectangleGauche(f, a, b, Nb_Int)); Nb_Int += 2; } } else { MessageBox.Show("Vérifiez vos entrées"); } }