Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
18 views
Zero Fonction - Py
Uploaded by
Yasser Rghaoui
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download now
Download
Save Zero Fonction.py For Later
Download
Save
Save Zero Fonction.py For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
18 views
Zero Fonction - Py
Uploaded by
Yasser Rghaoui
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download now
Download
Save Zero Fonction.py For Later
Carousel Previous
Carousel Next
Save
Save Zero Fonction.py For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 2
Search
Fullscreen
1 #~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
2 # UIASS > CPGE > MPSI >
[email protected]
3 #~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
4 #
5 # Zero de fonction
6 #
7 #~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
8 import numpy as np
9 import scipy.optimize as spo
10 import matplotlib.pyplot as plt
11 #~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
12 def f( x ): return (x-3)**3+4
13 #return (x*x+ np.cos(9*x))*np.sin(x)-2+1/np.exp(x)
14 #~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
15 def fp( x ): return 3*(x-3)**2
16 #~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
17 def dichotomie(f, a, b, epsl=10**-5):
18 if f(a)*f(b) > 0: return None
19 while True:
20 c = (a+b)/2
21 if abs(f(c)) < epsl : return c #if b-a < eps : return c
22 if f(a)*f(c) < 0: b = c
23 else : a = c
24 ## plt.plot(c, 0, ".", color="red")
25 #~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
26 def newton(f, x, fp, epsl=10**-5, maxIter=100):
27 k = 0
28 for i in range(maxIter):
29 #if fp(x) == 0: return None
30 z = x - f(x)/fp(x)
31 if abs(z-x) < epsl: break # if abs(f(z)) < epsl: return z
32 x = z
33 return z
34 ## plt.plot(z, 0, "*", color="green")
35 #~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
36 def Sequante(f, a, b, epsl=10**-5, maxIter=1000):
37 x = ( a*f(b)-b*f(a) ) / ( f(b)-f(a) )
38 for i in range(maxIter):
39 if abs( f(x) ) < epsl: return x
40 b, a = x, b
41 #if f(b)-f(a) == 0: return None
42 x = ( a*f(b) - b*f(a) ) / ( f(b)-f(a) )
43 ## W = np.linspace(0, f(x), 25)
44 ## plt.plot([x]*len(W), W, "--", color="cyan")
45 #~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
46 def Regula_Falsi(f, a, b, epsl=10**-5, maxIter=1000):
47 for i in range(maxIter):
48 x = ( a*f(b)-b*f(a) ) / ( f(b)-f(a) )
49 if abs(f(x)) < epsl : return x #if b-a < eps : return x
50 if f(a)*f(x) < 0: b = x
51 else : a = x
52 ## W = np.linspace(0, f(x), 25)
53 ## plt.plot([x]*len(W), W, "--", color="orange")
54 #~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
55 fig, ax = plt.subplots()
56 ax.grid(True, which='both')
57
58 ax.spines[ 'left'].set_position('zero') ; ax.spines['right'].set_color('none')
59 ax.spines['bottom'].set_position('zero') ; ax.spines[ 'top'].set_color('none')
60 ax.yaxis.tick_left() ; ax.xaxis.tick_bottom()
61
62 a, b = 0, 10 # a, b = -np.pi, np.pi #a, b = 0, 2.4
63 X = np.linspace( a, b, 200 ) ; Y = f(X) ; plt.plot(X, Y, lw=2, color="blue")
64
65 x0 = dichotomie(f, a, b) ; plt.plot(x0, f(x0), "*", lw=3, color="red")
66 x0 = spo.bisect(f, a, b) ; plt.plot(x0, f(x0), "*", lw=5, color="pink")
67
68 x1 = newton(f, b, fp) ; plt.plot(x1, f(x1), "D", lw=3, color="green")
69 x1 = spo.newton(f, b, fp) ; plt.plot(x1, f(x1), "D", lw=5, color="lime")
70
71 x2 = Sequante(f, a, b) ; plt.plot(x2, f(x2), "o", lw=3, color="cyan")
72 x2 = spo.newton(f, a) ; plt.plot(x2, f(x2), "o", lw=5, color="purple")
73
74 x3 = Regula_Falsi(f, a, b) ; plt.plot(x3, f(x3), "s", lw=3, color="orange")
75 plt.show() # plt.savefig("myPlot.png")
76
You might also like
Rogue Lineage Philo Script
PDF
No ratings yet
Rogue Lineage Philo Script
2 pages
Allen, S.M. - Encyclopedia of Materials - Science and Technology Spinodal Decomposition
PDF
No ratings yet
Allen, S.M. - Encyclopedia of Materials - Science and Technology Spinodal Decomposition
4 pages
applications_f(x)=0
PDF
No ratings yet
applications_f(x)=0
4 pages
Aris Pradipta - 23262011065.ipynb - Colaboratory
PDF
No ratings yet
Aris Pradipta - 23262011065.ipynb - Colaboratory
5 pages
EulerOrdre1 Py
PDF
No ratings yet
EulerOrdre1 Py
1 page
Sort Algorithms
PDF
No ratings yet
Sort Algorithms
2 pages
Python Max
PDF
No ratings yet
Python Max
7 pages
Determine determinant-2
PDF
No ratings yet
Determine determinant-2
17 pages
PseudoCodes HCL
PDF
No ratings yet
PseudoCodes HCL
10 pages
Øving 9-Merged
PDF
No ratings yet
Øving 9-Merged
9 pages
Teddy Mukadzambo R201998U Python Refresher
PDF
No ratings yet
Teddy Mukadzambo R201998U Python Refresher
8 pages
Nama: James Aditama Karya Putra (150534604193) : 1.) Metode Eliminasi Gauss Script Program
PDF
No ratings yet
Nama: James Aditama Karya Putra (150534604193) : 1.) Metode Eliminasi Gauss Script Program
6 pages
Record
PDF
No ratings yet
Record
3 pages
Int Fact (Int X) (If (X 1) Return 1 Else Return N Fact (n-1) )
PDF
No ratings yet
Int Fact (Int X) (If (X 1) Return 1 Else Return N Fact (n-1) )
5 pages
Assignment 1
PDF
No ratings yet
Assignment 1
6 pages
数据结构基础 (C语言版) FUNDAMENTALS OF DATA STRUCTURES IN C 部分习题英文版答案
PDF
No ratings yet
数据结构基础 (C语言版) FUNDAMENTALS OF DATA STRUCTURES IN C 部分习题英文版答案
171 pages
Worksheet Functions
PDF
No ratings yet
Worksheet Functions
12 pages
Three-Dimensional Plotting in Python Using Matplotlib
PDF
No ratings yet
Three-Dimensional Plotting in Python Using Matplotlib
5 pages
Assignment 2
PDF
No ratings yet
Assignment 2
9 pages
Assignment5 20243129
PDF
No ratings yet
Assignment5 20243129
6 pages
Master Hand FE Script
PDF
No ratings yet
Master Hand FE Script
15 pages
Derivatives
PDF
No ratings yet
Derivatives
2 pages
METODE NEWTON RAPHSON - E1E122103 - Jabal Nur
PDF
No ratings yet
METODE NEWTON RAPHSON - E1E122103 - Jabal Nur
4 pages
Nav
PDF
No ratings yet
Nav
2 pages
Def Main
PDF
No ratings yet
Def Main
3 pages
Python lab file
PDF
No ratings yet
Python lab file
43 pages
Taller 2 - Colaboratory
PDF
No ratings yet
Taller 2 - Colaboratory
10 pages
Fe Sniper
PDF
No ratings yet
Fe Sniper
12 pages
Taller 3 corte 3 (Clase 28 octubre).ipynb - Colab
PDF
No ratings yet
Taller 3 corte 3 (Clase 28 octubre).ipynb - Colab
3 pages
Lab Manual
PDF
No ratings yet
Lab Manual
18 pages
BISWAS49_HW3 (1)
PDF
No ratings yet
BISWAS49_HW3 (1)
12 pages
20BIT037_Data Analytics
PDF
No ratings yet
20BIT037_Data Analytics
30 pages
Python
PDF
No ratings yet
Python
16 pages
Code CMN by Amine
PDF
No ratings yet
Code CMN by Amine
6 pages
MATH lab final code
PDF
No ratings yet
MATH lab final code
10 pages
ML Lab
PDF
No ratings yet
ML Lab
24 pages
MainCodeBedwar
PDF
No ratings yet
MainCodeBedwar
68 pages
Python Course
PDF
No ratings yet
Python Course
6 pages
44DBD3C517136789270
PDF
No ratings yet
44DBD3C517136789270
21 pages
EAlab Codes
PDF
No ratings yet
EAlab Codes
6 pages
Maths 20 Lab
PDF
No ratings yet
Maths 20 Lab
13 pages
SCILAB Elementary Functions
PDF
No ratings yet
SCILAB Elementary Functions
25 pages
77 A05fza
PDF
No ratings yet
77 A05fza
18 pages
ROBLOX Shotgun Script
PDF
No ratings yet
ROBLOX Shotgun Script
24 pages
Problems: Be As and
PDF
No ratings yet
Problems: Be As and
4 pages
SPCC Adheesh
PDF
No ratings yet
SPCC Adheesh
16 pages
AI LAB file
PDF
No ratings yet
AI LAB file
16 pages
chako sir lab practical program (1)
PDF
No ratings yet
chako sir lab practical program (1)
8 pages
Python Note 2
PDF
No ratings yet
Python Note 2
11 pages
ai lab manual
PDF
No ratings yet
ai lab manual
28 pages
SlidesCourse 21 Oct
PDF
No ratings yet
SlidesCourse 21 Oct
10 pages
Code2pdf 6400c76826c9d
PDF
No ratings yet
Code2pdf 6400c76826c9d
3 pages
Final AI LAB FILE
PDF
No ratings yet
Final AI LAB FILE
20 pages
Arccos
PDF
No ratings yet
Arccos
2 pages
Graphing: Numpy NP Matplotlib - Pyplot PLT Scipy - Optimize
PDF
No ratings yet
Graphing: Numpy NP Matplotlib - Pyplot PLT Scipy - Optimize
11 pages
AutoFree(Copy)
PDF
No ratings yet
AutoFree(Copy)
96 pages
Slip NO - 8
PDF
No ratings yet
Slip NO - 8
9 pages
2021-civ-73-part-2 python
PDF
No ratings yet
2021-civ-73-part-2 python
19 pages
Rayan Workbook 6
PDF
No ratings yet
Rayan Workbook 6
16 pages
ЗарубаеваАК_HA2
PDF
No ratings yet
ЗарубаеваАК_HA2
26 pages
Analytic Geometry: Graphic Solutions Using Matlab Language
From Everand
Analytic Geometry: Graphic Solutions Using Matlab Language
Ing. Mario Castillo
No ratings yet
Cbse 10TH Notes
PDF
No ratings yet
Cbse 10TH Notes
2 pages
Option Trading Strategy in NIFTY, India
PDF
67% (3)
Option Trading Strategy in NIFTY, India
16 pages
Class 12th Maths Chapter 10 (Vector Algebra) Unsolved
PDF
No ratings yet
Class 12th Maths Chapter 10 (Vector Algebra) Unsolved
7 pages
Chapter 7
PDF
No ratings yet
Chapter 7
39 pages
Installation Instructions: Face2face Can Be Run Directly From The CD-ROM and Does Not Require Installation
PDF
No ratings yet
Installation Instructions: Face2face Can Be Run Directly From The CD-ROM and Does Not Require Installation
1 page
Simatic S7-1200 Simatic S7-200 To Simatic S7-1200 Software Conversion Tool V11
PDF
No ratings yet
Simatic S7-1200 Simatic S7-200 To Simatic S7-1200 Software Conversion Tool V11
36 pages
2014 2 Nine Weeks Study Guide: Answers
PDF
No ratings yet
2014 2 Nine Weeks Study Guide: Answers
47 pages
Coulson& Richardson - Cap.10 Liquid-Liquid Separation
PDF
No ratings yet
Coulson& Richardson - Cap.10 Liquid-Liquid Separation
7 pages
Digital Image Processing
PDF
No ratings yet
Digital Image Processing
23 pages
IBM Infosphere Change Data Capture
PDF
No ratings yet
IBM Infosphere Change Data Capture
9 pages
Scheme of Work Maths Stage 7
PDF
No ratings yet
Scheme of Work Maths Stage 7
14 pages
MP Zelta Ax5vmi
PDF
No ratings yet
MP Zelta Ax5vmi
8 pages
Chapwise Questions Maths Iit
PDF
No ratings yet
Chapwise Questions Maths Iit
50 pages
A2AS MATH PP January 2008 As Mark Scheme 3691
PDF
No ratings yet
A2AS MATH PP January 2008 As Mark Scheme 3691
40 pages
Chapter 5 Reactor Design and Reactor Network
PDF
100% (1)
Chapter 5 Reactor Design and Reactor Network
57 pages
German Basic Vocab
PDF
100% (3)
German Basic Vocab
6 pages
Distributed System Lab Manual
PDF
No ratings yet
Distributed System Lab Manual
36 pages
Heat Transfer in Rough Tubes
PDF
No ratings yet
Heat Transfer in Rough Tubes
3 pages
AIITS 2224 PT III JEEA Paper 1
PDF
No ratings yet
AIITS 2224 PT III JEEA Paper 1
18 pages
UNIT 3 Bhs Inggris Teknik Mesin Unimed
PDF
No ratings yet
UNIT 3 Bhs Inggris Teknik Mesin Unimed
19 pages
Chem Soc Rev: Tutorial Review
PDF
No ratings yet
Chem Soc Rev: Tutorial Review
11 pages
Aseptanios Ad Fiche Technique 00000 en
PDF
No ratings yet
Aseptanios Ad Fiche Technique 00000 en
2 pages
Thermo Chemistry
PDF
50% (2)
Thermo Chemistry
15 pages
Lab Equipment - CePPOME
PDF
No ratings yet
Lab Equipment - CePPOME
6 pages
Sri Lanka Grade 12 Combined Mathematics 2023 1st Term Test Paper 65543d6c1aa07
PDF
No ratings yet
Sri Lanka Grade 12 Combined Mathematics 2023 1st Term Test Paper 65543d6c1aa07
7 pages
Packing List: Ismail Awan-e-Science, Ferozpur Road Lahore PH# 111-786-645
PDF
No ratings yet
Packing List: Ismail Awan-e-Science, Ferozpur Road Lahore PH# 111-786-645
4 pages
Ais Prof 1 Chapter 5
PDF
No ratings yet
Ais Prof 1 Chapter 5
39 pages
Serres and Hallward - The Science of Relations - An Interview
PDF
No ratings yet
Serres and Hallward - The Science of Relations - An Interview
13 pages
JC 50
PDF
No ratings yet
JC 50
6 pages
Documents
Teaching Methods & Materials