A computer algebra system written in pure Python http://sympy.org/ . To get started to with contributing https://github.com/sympy/sympy/wiki/Introduction-to-contributing
oscarbenjamin on master
fix(core): support unpickling o… Merge pull request #22306 from … (compare)
oscarbenjamin on 1.9
fix(core): support unpickling o… Merge pull request #22245 from … (compare)
sympy.preview(expr, output="pdf", viewer="file", filename="DFN_equations.pdf", dvioptions=['-D', '1100'], euler=False)
I wanted to expand on my question from earlier since it may be too specific.
I am working through some equations from the theory of elasticity.
The differential equation I am trying to work with is the equation
for compatibility of small displacements in a strained isotropic elastic body.
This is written as
$(1 - 2\eta) v^i|^j_j + v^j|^i_j = 0$
where
$f^i|_j$
represents the covariant derivative of f with respect to j, and
$f^i|^j$
represents the covariant derivative of f with respect to j
with the j index raised (this convention is from Green and Zerna -
I don't know if this is a standard notation).
We can use solutions of the above differential equation to compute
the stress tensor as follows:
$\frac{\tau^{ij}}{\mu} = g^{js} v^i|_s + g^{ir} v^j|_r + \frac{2 \eta}{1 - 2 \eta} g^{ij} v^r|_r$
One of the solutions to the displacement equation is as follows:
$v_i = F|_i$
where F is a harmonic function.
What's a good way to
\limits
is.
\limits
puts them directly above or below the integral sign. That does seem better for non-inline mode, especially if the limits can be long.
I am working in a simple QFT calculation and would like to do it using Sympy to learn (and also check my result). I have found the Quantum Mechanics module but cannot see how to start using it for my purpose. I have defined these quantities:
import sympy.physics.quantum as Q
vacuum = Q.OrthogonalKet(0)
annihilation_op = Q.Operator('a')
creation_op = Q.Dagger(annihilation_op)
and now I want to tell Sympy that $a |n\rangle = \sqrt{n} | n-1 \rangle$ if $n>0$ else $0$ and $a^\dagger | n \rangle = \sqrt{n+1} | n+1 \rangle$. How would I do this? Also, how do I impose the commutation relations between $a$ and $a^\dagger$?
Hi all,
I am just a new user for SymPy. I am self learning this library for my undergrauate research. But in the middle of the process I am stucked with one code.
So I have defined a function with a subscript.
U_n= x^n + 1/x^n
When I consider (U_1)^3 I get (substitute n=1)
(U_1)^3 = (x+1/x)^3
Then after simplifying this I get
(U_1)^3 = (x^3 + 1/x^3) + 3(x+ 1/x)
But one can see this answer as
(U_1)^3 = U_3 + 3U_1
How to get the output in terms of U_n 's ?
Can someone please give an idea how to build this code using SymPy. It would be a very big help for my research.
Thank you very much.
Gayanath Chandrasena.
dr*(k-1) < dr*(k+1)
, which is obviously true, since dr = symbols('Delta',real=True,positive=True,nonzero=True)
and k = symbols('k',integer=True,real=True)
, yet sympy doesn't seem to thing this is the case. Am I doing something wrong?
Also I get
In [54]: print(ask(dr*(k-1) < dr*(k+1)))
None
but
In [55]: print(ask(dr*k-dr < dr*k+dr))
True
@ThePauliPrinciple
My function is
U_n= x^n + 1/x^n.
As an example when I compute (U_1)^3 I get (x^3 + 1/x^3) + 3(x+ 1/x).---------(i)
And if I compute (U_2)^2 I get x^4 + 1/x^4 + 2---------(ii)
But since in (i), (x^3 + 1/x^3)= U_3 and 3(x+ 1/x)=3U_1 I want to get the answer U_3+3U_1.
In (ii) I want to get the answer U_4 +2 since x^4 + 1/x^4 = U_4.
aman@amanUBUNTU:~/Desktop$ python3 Un.py
Enter Value of n and k as in (U_n)^k
n = 1
k = 3
3*U_1 + U_3
aman@amanUBUNTU:~/Desktop$ python3 Un.py
Enter Value of n and k as in (U_n)^k
n = 1
k = 2
U_2 + 2
aman@amanUBUNTU:~/Desktop$ python3 Un.py
Enter Value of n and k as in (U_n)^k
n = 2
k = 10
45*U_12 + 10*U_16 + U_20 + 210*U_4 + 120*U_8 + 252
@mostlyaman Yes.This is kind of same what I want.But in my case it is bit advanced.
U(n)=x^n + 1/x^n
V(n)=x^n - 1/x^n
So if I ask for any expression I should get the answer in U(n)'s and V(n)'s.I have buil it for U(n) and V(n) separately but cannot combine them.
ex: u(1)v(1)=v(2)
v(2)u(1)-v(1)=v(3)
v(1)^2 - u(1)^2 =2*u(2)
This is the program which I want.
@mostlyaman is your program executable in jupyter notebook?. If you have an idea please let me know.