Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
controle4
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ISC2
maths
controle4
Commits
fb5bce2d
Commit
fb5bce2d
authored
10 months ago
by
iliya.saroukha
Browse files
Options
Downloads
Patches
Plain Diff
feat: computing max theoretical error when interpolating
parent
c3638f84
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ISC_421_Controle_4_Saroukhanian_Iliya.py
+33
-4
33 additions, 4 deletions
ISC_421_Controle_4_Saroukhanian_Iliya.py
with
33 additions
and
4 deletions
ISC_421_Controle_4_Saroukhanian_Iliya.py
+
33
−
4
View file @
fb5bce2d
...
@@ -206,8 +206,25 @@ def ex2_taylor_poly():
...
@@ -206,8 +206,25 @@ def ex2_taylor_poly():
plt
.
show
()
plt
.
show
()
def
polerr
(
nb_points
,
interpolation_pts
,
plot_range
):
errs_range
=
[]
for
pt
in
plot_range
:
prod
=
1
for
inter_pt
in
interpolation_pts
:
prod
*=
pt
-
inter_pt
err
=
(
SD
.
Maximal_derivatives_values
[
nb_points
-
1
]
/
math
.
factorial
(
nb_points
+
1
))
*
np
.
abs
(
prod
)
errs_range
.
append
(
err
)
return
errs_range
def
ex3_lagrange_interpolation_poly
():
def
ex3_lagrange_interpolation_poly
():
nb_points
=
np
.
linspace
(
1
,
1
3
,
6
,
dtype
=
np
.
uint
64
)
nb_points
=
np
.
linspace
(
1
,
1
2
,
6
,
dtype
=
np
.
uint
8
)
fig
,
axes
=
plt
.
subplots
(
2
,
3
,
figsize
=
(
20
,
12
))
fig
,
axes
=
plt
.
subplots
(
2
,
3
,
figsize
=
(
20
,
12
))
t
=
np
.
linspace
(
SD
.
a
,
SD
.
b
,
Nmbre_pts
)
t
=
np
.
linspace
(
SD
.
a
,
SD
.
b
,
Nmbre_pts
)
...
@@ -225,14 +242,21 @@ def ex3_lagrange_interpolation_poly():
...
@@ -225,14 +242,21 @@ def ex3_lagrange_interpolation_poly():
l_poly_chebyshev_pts
=
lagrange
(
l_poly_chebyshev_pts
=
lagrange
(
chebyshev_points_mapped
,
SD
.
f
(
chebyshev_points_mapped
))
chebyshev_points_mapped
,
SD
.
f
(
chebyshev_points_mapped
))
uniform_err
=
polerr
(
nb_points
[
i
],
interpolate_pts
,
t
)
chebyshev_err
=
polerr
(
nb_points
[
i
],
chebyshev_points_mapped
,
t
)
ax
.
plot
(
t
,
SD
.
f
(
t
),
color
=
'
black
'
,
label
=
'
f
'
)
ax
.
plot
(
t
,
SD
.
f
(
t
),
color
=
'
black
'
,
label
=
'
f
'
)
ax
.
plot
(
t
,
l_poly_uniform
(
t
),
color
=
'
red
'
,
ax
.
plot
(
t
,
l_poly_uniform
(
t
),
color
=
'
red
'
,
label
=
'
$L_{f}$, intervalle équidistants
'
)
label
=
'
$L_{f}$, intervalle équidistants
'
)
ax
.
plot
(
t
,
np
.
abs
(
SD
.
f
(
t
)
-
l_poly_uniform
(
t
)),
'
--
'
,
color
=
'
red
'
,
# ax.plot(t, np.abs(SD.f(t) - l_poly_uniform(t)), '--', color='red',
# label='$L_{f}$, intervalle équidistants, erreur')
ax
.
plot
(
t
,
uniform_err
,
'
--
'
,
color
=
'
red
'
,
label
=
'
$L_{f}$, intervalle équidistants, erreur
'
)
label
=
'
$L_{f}$, intervalle équidistants, erreur
'
)
ax
.
plot
(
t
,
l_poly_chebyshev_pts
(
t
),
color
=
'
blue
'
,
ax
.
plot
(
t
,
l_poly_chebyshev_pts
(
t
),
color
=
'
blue
'
,
label
=
'
$L_{f}$, points de Chebyshev
'
)
label
=
'
$L_{f}$, points de Chebyshev
'
)
ax
.
plot
(
t
,
np
.
abs
(
SD
.
f
(
t
)
-
l_poly_chebyshev_pts
(
t
)),
'
--
'
,
color
=
'
blue
'
,
# ax.plot(t, np.abs(SD.f(t) - l_poly_chebyshev_pts(t)), '--', color='blue',
# label='$L_{f}$, points de Chebyshev, erreur')
ax
.
plot
(
t
,
chebyshev_err
,
'
--
'
,
color
=
'
blue
'
,
label
=
'
$L_{f}$, points de Chebyshev, erreur
'
)
label
=
'
$L_{f}$, points de Chebyshev, erreur
'
)
ax
.
plot
(
interpolate_pts
,
SD
.
f
(
interpolate_pts
),
'
o
'
,
color
=
'
red
'
,
ax
.
plot
(
interpolate_pts
,
SD
.
f
(
interpolate_pts
),
'
o
'
,
color
=
'
red
'
,
label
=
'
Points équidistants
'
)
label
=
'
Points équidistants
'
)
...
@@ -240,7 +264,7 @@ def ex3_lagrange_interpolation_poly():
...
@@ -240,7 +264,7 @@ def ex3_lagrange_interpolation_poly():
SD
.
f
(
chebyshev_points_mapped
[::
-
1
]),
'
o
'
,
color
=
'
blue
'
,
SD
.
f
(
chebyshev_points_mapped
[::
-
1
]),
'
o
'
,
color
=
'
blue
'
,
label
=
'
Points de Chebyshev
'
)
label
=
'
Points de Chebyshev
'
)
ax
.
set_title
(
f
'
n =
{
nb_points
[
i
]
}
'
)
ax
.
set_title
(
f
'
n =
{
nb_points
[
i
]
}
'
)
ax
.
set_ylim
([
-
1.2
,
1.2
])
#
ax.set_ylim([-1.2, 1.2])
ax
.
legend
()
ax
.
legend
()
...
@@ -250,7 +274,12 @@ def ex3_lagrange_interpolation_poly():
...
@@ -250,7 +274,12 @@ def ex3_lagrange_interpolation_poly():
plt
.
show
()
plt
.
show
()
def
caca
():
print
(
len
(
SD
.
Maximal_derivatives_values
))
ex3_lagrange_interpolation_poly
()
ex3_lagrange_interpolation_poly
()
# caca()
# def ex3_newton_interpolation_poly():
# def ex3_newton_interpolation_poly():
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment