SHARE
TWEET

dichotomie

a guest Apr 1st, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function y = phi(x)   // la fonction de l'√©nonc√©
  2.     y = log(x) - log(x+1) + 1/x
  3. endfunction
  4.  
  5. function y = diff(x)  // ce qui doit s'annuler
  6.     y = phi(x) - 1
  7. endfunction
  8.  
  9. a = 1/3
  10. b = 1/2
  11.  
  12. disp([a, b])          // l'intervalle initial
  13.  
  14. while b-a > 10^-2     // tant que l'intervalle est trop long, on continue
  15.     m = (a+b)/2       // le milieu de l'intervalle
  16.     if diff(a) * diff(m) < 0
  17.         b = m         // il y a une solution entre a et c
  18.     else
  19.         a = m         // il y a une solution entre b et c
  20.     end
  21.     disp([a, b])
  22. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top