Created
April 27, 2017 20:12
-
-
Save anonymous/1fd6788bfbe144ea0fd73abea57d1b21 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def lairalgebriqueapproximationrectangle(): | |
A=input("Entrez la forme de la fonction avec variable x : ") | |
print('f(x)=',A) | |
n=int(input("Entrez le nombre de pas n ,de préference il doit etre grand : ")) | |
a=float(input("l'intervalle commence de : ")) | |
b=float(input("l'intervalle fini par : ")) | |
somme=0 | |
for k in range(0,n): | |
fonction='' | |
for elm in A : | |
if elm =='x': | |
fonction += str(a+(k*((b-a)/n))) | |
else : | |
fonction+= elm | |
res = fonction | |
somme +=eval(res) | |
return ((b-a)/n) * somme |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment