Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
python-math
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Thibaut.Lunet
python-math
Commits
8986f6b3
Commit
8986f6b3
authored
7 years ago
by
Aitor Perez
Browse files
Options
Downloads
Patches
Plain Diff
sympy exercise
parent
bebb3a5b
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
exercises/5-Sympy/power-series-solution.py
+33
-0
33 additions, 0 deletions
exercises/5-Sympy/power-series-solution.py
exercises/5-Sympy/power-series.py
+30
-0
30 additions, 0 deletions
exercises/5-Sympy/power-series.py
with
63 additions
and
0 deletions
exercises/5-Sympy/power-series-solution.py
0 → 100644
+
33
−
0
View file @
8986f6b3
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# Exercise 5.1: Sympy power series - Solution
#
# Complete the function powerSeries to compute, given a natural number a,
# the value of the following series:
#
# oo 1
# Sum --------
# k = 1 k^(2*a)
#
# Use the functions Sum and limit of the sympy package:
# Sum: [http://docs.sympy.org/latest/_modules/sympy/concrete/summations.html#Sum]
# limit: [http://docs.sympy.org/latest/modules/series/series.html#sympy.series.limits.limit]
import
sympy
as
sy
def
powerSeries
(
a
):
k
=
sy
.
symbols
(
'
k
'
)
n
=
sy
.
symbols
(
'
n
'
)
Sn
=
sy
.
Sum
(
1
/
k
**
(
2
*
a
),
(
k
,
1
,
n
))
l
=
sy
.
limit
(
Sn
,
n
,
sy
.
oo
)
return
l
print
(
powerSeries
(
1
))
print
(
powerSeries
(
2
))
print
(
powerSeries
(
3
))
This diff is collapsed.
Click to expand it.
exercises/5-Sympy/power-series.py
0 → 100644
+
30
−
0
View file @
8986f6b3
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# Exercise 5.1: Sympy power series
#
# Complete the function powerSeries to compute, given a natural number a,
# the value of the following series:
#
# oo 1
# Sum --------
# k = 1 k^(2*a)
#
# Use the functions Sum and limit of the sympy package:
# Sum: [http://docs.sympy.org/latest/_modules/sympy/concrete/summations.html#Sum]
# limit: [http://docs.sympy.org/latest/modules/series/series.html#sympy.series.limits.limit]
import
sympy
as
sy
def
powerSeries
(
a
):
k
=
sy
.
symbols
(
'
k
'
)
n
=
sy
.
symbols
(
'
n
'
)
pass
# Your code here
print
(
powerSeries
(
1
))
print
(
powerSeries
(
2
))
print
(
powerSeries
(
3
))
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