Commit 9554ff45 authored by Thibaut.Lunet's avatar Thibaut.Lunet

TL: last sympy example

parent 8f7dc86d
......@@ -9,6 +9,10 @@ This script is a basic example of how to solve a differential equation using sym
In particular, the equation u''(t) - u(t) = exp(t) is solved, using the sympy function [dsolve](http://docs.sympy.org/latest/modules/solvers/ode.html).
## [blockMatrixComputation.py](blockMatrixComputation.py)
Performs block matrix computation with non-comuutative blocks, and print latex output for the results
## [generalMidPointInterpolation.py](generalMidPointInterpolation.py)
This script compute the general formula of mid-point interpolation on one-dimensionnal uniform grids.
......
# -*- coding: utf-8 -*-
"""
Performs block matrix computations, and print latex formula
"""
import sympy as sy
sy.init_printing()
# Define symbolds
A, B, C = sy.symbols('A, B, C', commutative=False)
D = sy.symbols('D', commutative=True)
M = sy.Matrix([[D, B, 0],
[C, D, 0],
[0, 0, A]])
# Compute symbolic operations
M1 = M**2
M1.simplify()
M2 = (M-sy.eye(3))*M
M2.simplify()
# Print latex formula
print('M1 = ')
print(sy.latex(M1))
print('M2 = ')
print(sy.latex(M2))
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 19 18:54:50 2016
@author: t.lunet
Compute the analytical mid-point interpolation formula, for any order,
on uniform 1D grids
"""
import sympy as sy
from time import time
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment