Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
pythonmath
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Thibaut.Lunet
pythonmath
Commits
835a5a27
Commit
835a5a27
authored
Mar 19, 2018
by
Aitor Perez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
example diff eqns
parent
d548d421
Changes
1
Hide whitespace changes
Inline
Sidebyside
Showing
1 changed file
with
31 additions
and
0 deletions
+31
0
examples/scipy/solvediffeqns.py
examples/scipy/solvediffeqns.py
+31
0
No files found.
examples/scipy/solvediffeqns.py
0 → 100644
View file @
835a5a27
#!/usr/bin/env python2
# * coding: utf8 *
"""
Sympy example: How to solve a differential equation using sympy
@author: a.perez
"""
import
sympy
as
sy
# Define a generic function u and its variable, t
u
=
sy
.
Function
(
'u'
)
t
=
sy
.
symbols
(
't'
)
# We want to solve the differential equation u''(t)  u(t) = exp(t)
u_tt
=
sy
.
diff
(
u
(
t
),
t
,
t
)
# Second derivative of u wrt t
# (symbolic, since u is a generic function)
lhs
=
u_tt

u
(
t
)
# Left handside of the equation
rhs
=
sy
.
exp
(
t
)
# Right handside of the equation
eq
=
sy
.
Eq
(
lhs
,
rhs
)
# We create the equation
sol
=
sy
.
dsolve
(
eq
,
u
(
t
))
# And we solve it using the function dsolve,
# wrt the function u(t)
# Now sol is the equation:
# u(t) = C2*exp(t) + (C1 + t/2)*exp(t)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment