longueur_cf.py

Created by cent20

Created on October 14, 2019

399 Bytes

2nde TDG 04
Exercice 5


from math import sqrt

def f(x):
    return .........  # ecrire une f° ici

def dist(x1,y1,x2,y2):
    return sqrt((x1-x2)**2 + (y1-y2)**2)

def longueur(a,b,n):
    long = ...     # ecrire une valeur ici
    x1,y1 = a,f(a)
    h = (b-a)/n
    for i in range(n):
        x2 = x1 + h
        y2 = f(x2)
        long = long + dist(x1,y1,x2,y2)
        x1,y1 = x2,y2
    return long

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.