notebook1.ipynb
188 lines
| 5.6 KiB
| text/plain
|
TextLexer
Jonathan Frederic
|
r11478 | { | |
MinRK
|
r18580 | "cells": [ | |
Jonathan Frederic
|
r11478 | { | |
MinRK
|
r18596 | "cell_type": "markdown", | |
MinRK
|
r18580 | "metadata": {}, | |
"source": [ | |||
MinRK
|
r18596 | "# A simple SymPy example" | |
MinRK
|
r18580 | ] | |
}, | |||
{ | |||
"cell_type": "markdown", | |||
"metadata": {}, | |||
"source": [ | |||
"First we import SymPy and initialize printing:" | |||
] | |||
}, | |||
{ | |||
"cell_type": "code", | |||
MinRK
|
r18587 | "execution_count": 2, | |
MinRK
|
r18580 | "metadata": { | |
"collapsed": false | |||
}, | |||
"outputs": [], | |||
"source": [ | |||
"from sympy import init_printing\n", | |||
"from sympy import *\n", | |||
" init_printing()" | |||
] | |||
}, | |||
{ | |||
"cell_type": "markdown", | |||
"metadata": {}, | |||
"source": [ | |||
"Create a few symbols:" | |||
] | |||
}, | |||
{ | |||
"cell_type": "code", | |||
MinRK
|
r18587 | "execution_count": 4, | |
MinRK
|
r18580 | "metadata": { | |
"collapsed": false | |||
}, | |||
"outputs": [], | |||
"source": [ | |||
"x,y,z = symbols('x y z')" | |||
] | |||
}, | |||
{ | |||
"cell_type": "markdown", | |||
"metadata": {}, | |||
"source": [ | |||
"Here is a basic expression:" | |||
] | |||
}, | |||
{ | |||
"cell_type": "code", | |||
MinRK
|
r18587 | "execution_count": 6, | |
MinRK
|
r18580 | "metadata": { | |
"collapsed": false | |||
}, | |||
"outputs": [ | |||
Jonathan Frederic
|
r11478 | { | |
MinRK
|
r18589 | "data": { | |
"image/png": [ | |||
"iVBORw0KGgoAAAANSUhEUgAAAKMAAAAZBAMAAACvE4OgAAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\n", | |||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAEHarIkSJZt3NVLsy\n", | |||
"me8Q6PJIAAACz0lEQVRIDa1UTWjUQBT+ZpvdzW7TGlrxItjYSg/C6vbiDwjmoCgUpHioPYhdqig9\n", | |||
"FJYiPYmW4klB14NgFGnw4EHpj7UgUtTFXhSEBgVBxIOFggWVrrUqiMY3mZkkLNIK7oN575vvvfky\n", | |||
"8yYJIGzgkSlRrULKrivVSkvq6LbxtcaSjV3aSo0lgWyl5pK69V+SRlEsPxNTGYhhDrV3M2Ue2etc\n", | |||
"EDmuMmM+IjolrCuHXNoLoQDNSAXdzbjsfFVKTY1vCgFXFIxenG4cFSSzRewAPnN0FugXjPDr45MQ\n", | |||
"JwoKtitgXL9zT+CsJeIHYG+Z4H1gwhRU4G/FcAQbbYU3KdDo+0sCK8lRU0guA72uKqMYk9RehHxP\n", | |||
"iDIu0NS2v90KGShJYi7T7tgvkrQ2vIT2XtRISWNra6lzGc8/PW3ji4PL7Vmge095YIX0iB71NCaZ\n", | |||
"5N3XyM0VCuNIyFNIyY3AMG/KDUvjn90DGmwq9wpIl5AyU5WsTYy0aJf6JFGB5An3Der5jExKHjNR\n", | |||
"4JKPge/EXqDBoOXpkxkmkJHFfAFRVhDIveWA0S57N2Me6yw+DSX1n1uCq3sIfCF2IcjNkjeWyKli\n", | |||
"ginHubboOB4vSNAjyaiXE26ygrkyTfod55Lj3CTE+n2P73ImJpnk6wJJKjYJSwt3OQbNJu4icM5s\n", | |||
"KGGbzMuD70N6JSbJD44x7pLDyJrbkfiLpOEhYVMJSVEj83x5YFLyNrAzJsmvJ+uhLrieXvcJDshy\n", | |||
"HtQuD54c2IWWEnSXfUTDZJJfAjcpOW5imp9aHvw4ZZ4NDV4FGjw0tzadKgbFwinJUd//AT0P1tdW\n", | |||
"BtuRU39oKdk9ONQ163fM+nvu/s4D/FX30otdQIZGlSnJKpq6KUxKVqV1WxGHFIhishjhEO1Gi3r4\n", | |||
"kZCMg+hH1henV8EjmFoly1PTMs/Uadaox+FceY2STpmvt9co/Pe0Jvt1GvgDK/Osw/4jQ4wAAAAA\n", | |||
"SUVORK5CYII=\n" | |||
], | |||
"text/latex": [ | |||
"$$x^{2} + 2.0 y + \\sin{\\left (z \\right )}$$" | |||
], | |||
"text/plain": [ | |||
" 2 \n", | |||
"x + 2.0\u22c5y + sin(z)" | |||
] | |||
}, | |||
MinRK
|
r18587 | "execution_count": 6, | |
Jonathan Frederic
|
r11478 | "metadata": {}, | |
MinRK
|
r18589 | "output_type": "execute_result" | |
MinRK
|
r18580 | } | |
], | |||
"source": [ | |||
"e = x**2 + 2.0*y + sin(z); e" | |||
] | |||
}, | |||
{ | |||
"cell_type": "code", | |||
MinRK
|
r18587 | "execution_count": 7, | |
MinRK
|
r18580 | "metadata": { | |
"collapsed": false | |||
}, | |||
"outputs": [ | |||
Jonathan Frederic
|
r11478 | { | |
MinRK
|
r18589 | "data": { | |
"image/png": [ | |||
"iVBORw0KGgoAAAANSUhEUgAAABQAAAAOBAMAAADd6iHDAAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\n", | |||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAIpm7MhCriUTv3c12\n", | |||
"VGZoascqAAAAgElEQVQIHWNgVDJ2YICAMAb2H1BmKgPDTChzFgNDvgOEvT8AzgQKrA9gPZPYUwNk\n", | |||
"cXxnCGd4dWA1kMllwFDKUB9wEchUZmAIYNgMZDDwJIDIPyDiEgOjAAPLFwZWBhYFBh6BqzwfGI4y\n", | |||
"SJUXZXH8Zf7A+IBh////v1hzjh5/xwAAW80hUDE8HYkAAAAASUVORK5CYII=\n" | |||
], | |||
"text/latex": [ | |||
"$$2 x$$" | |||
], | |||
"text/plain": [ | |||
"2\u22c5x" | |||
] | |||
}, | |||
MinRK
|
r18587 | "execution_count": 7, | |
Jonathan Frederic
|
r11478 | "metadata": {}, | |
MinRK
|
r18589 | "output_type": "execute_result" | |
MinRK
|
r18580 | } | |
], | |||
"source": [ | |||
"diff(e, x)" | |||
] | |||
}, | |||
{ | |||
"cell_type": "code", | |||
MinRK
|
r18587 | "execution_count": 8, | |
MinRK
|
r18580 | "metadata": { | |
"collapsed": false | |||
}, | |||
"outputs": [ | |||
Jonathan Frederic
|
r11478 | { | |
MinRK
|
r18589 | "data": { | |
"image/png": [ | |||
"iVBORw0KGgoAAAANSUhEUgAAALsAAAAZBAMAAACbakK8AAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\n", | |||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAEHarIkSJZt3NVLsy\n", | |||
"me8Q6PJIAAADAklEQVRIDbVVS2gTURQ90/wmk0k6tCJCsR1SKShIsxE3CgNWBKUxq9qFmqFqShfF\n", | |||
"UKQrkaDiF0pcCKYgBBcuBLV+wIWKARe6kQ4UhNKKWdiF4KIptmA/xPvmzZuMxdYUzIPcd+655568\n", | |||
"vLlJAL6G32oOasQWNHz5Rvg6nrKh/mygfSzlX2ygPaBUGmov6//NXs1yq4sex2EPrsHemTd2snNg\n", | |||
"tkb+Cx1zBL6SqwxZLvQAKYHzKZaPY4fh4TeHd0S5Nox9OClItm/jiU9DrEwwVEawpiVis9VkimqX\n", | |||
"AOr4o2cCs/0BT2I5+FYJRhJbePQxgzcD7QLEqtV5gdnu2Icr3L45gcCyt74Z7neL4SLQ0nm4S+dM\n", | |||
"YCz1gSPHnhKZDWyHhcCCNKwjqaF/TkwGl0L6nClie/wc1D1xdoNsSLhT0IJkhi7Lzr22xb8keE/N\n", | |||
"Pm0Sc9yEuhRUyuiG9HzvFNeImCyq39SriOhtQI7IV/TiTqE8glqwohjE0NJwiANxOZTdZoxtfzSa\n", | |||
"x2tI8DtHcKQoQFmV6f1XT2swibxFL+6k5EgenhBCqKLTPX3ULnaYdDlaTMcCSd8zuXTvBq2bJUJr\n", | |||
"lE4WgSV5ZRdBzLFgO6nzhJp1ltvrlB2HCoWxQuG+jTvt2GxBWUZaU2mMApZNuSHA3vJpCliRhqqs\n", | |||
"ZtvbTrb9ZIk+i70Ut1OcnpgeKskTCFUwjaYy8Jhr3eiefq0HIfa7yC6HOwVyULRuNDn21JngbcL+\n", | |||
"E8A+MNnSxb+w59+Cj2tELJBbjEZr8SGwn0j2aLkTPdp08R2OcKV6fXB3ikPH3n8tM5WTfrETtZcw\n", | |||
"g3QWH0dH7nKNiMkszqo/EDafaHhJ5Bm6ee4UtdAabxnMcmUUl0SnYx+uVqs5XAGN9QGgdeCrASv0\n", | |||
"3TmCsJcOdhnozexD38goK9HXynEKr1OKDs9guhQD039kGySyIQpJAdbvJ9YTlPvyUl3/aLUf34G/\n", | |||
"uGxIyXpE37DoLbAHwJaU53t9MRCfrU8o/k4iRn36Lar8Wd5wAfgN4R6xelyy/ssAAAAASUVORK5C\n", | |||
"YII=\n" | |||
], | |||
"text/latex": [ | |||
"$$x^{2} z + 2.0 y z - \\cos{\\left (z \\right )}$$" | |||
], | |||
"text/plain": [ | |||
" 2 \n", | |||
"x \u22c5z + 2.0\u22c5y\u22c5z - cos(z)" | |||
] | |||
}, | |||
MinRK
|
r18587 | "execution_count": 8, | |
Jonathan Frederic
|
r11478 | "metadata": {}, | |
MinRK
|
r18589 | "output_type": "execute_result" | |
Jonathan Frederic
|
r11478 | } | |
], | |||
MinRK
|
r18580 | "source": [ | |
"integrate(e, z)" | |||
] | |||
}, | |||
{ | |||
"cell_type": "code", | |||
MinRK
|
r18587 | "execution_count": null, | |
MinRK
|
r18580 | "metadata": { | |
"collapsed": false | |||
}, | |||
"outputs": [], | |||
"source": [] | |||
Jonathan Frederic
|
r11478 | } | |
MinRK
|
r18580 | ], | |
"metadata": {}, | |||
"nbformat": 4, | |||
"nbformat_minor": 0 | |||
Jonathan Frederic
|
r11478 | } |