{ "cells": [ { "cell_type": "markdown", "id": "a69ceb22", "metadata": {}, "source": [ "# A simple SymPy example" ] }, { "cell_type": "markdown", "id": "3c43c88e", "metadata": {}, "source": [ "First we import SymPy and initialize printing:" ] }, { "cell_type": "code", "execution_count": null, "id": "7b561917", "metadata": { "jupyter": { "outputs_hidden": false } }, "outputs": [], "source": [ "from sympy import diff, init_printing, integrate, sin, symbols" ] }, { "cell_type": "code", "execution_count": null, "id": "d6454356-d5a6-481f-aaac-9abcc101026a", "metadata": {}, "outputs": [], "source": [ "init_printing()" ] }, { "cell_type": "markdown", "id": "fbe0a2f3", "metadata": {}, "source": [ "Create a few symbols:" ] }, { "cell_type": "code", "execution_count": null, "id": "c99d7f17", "metadata": { "jupyter": { "outputs_hidden": false } }, "outputs": [], "source": [ "x, y, z = symbols(\"x y z\")" ] }, { "cell_type": "markdown", "id": "f61dddac", "metadata": {}, "source": [ "Here is a basic expression:" ] }, { "cell_type": "code", "execution_count": null, "id": "0cfde73c", "metadata": { "jupyter": { "outputs_hidden": false } }, "outputs": [], "source": [ "e = x**2 + 2.0 * y + sin(z)\n", "e" ] }, { "cell_type": "code", "execution_count": null, "id": "cb7eb1ad", "metadata": { "jupyter": { "outputs_hidden": false } }, "outputs": [], "source": [ "diff(e, x)" ] }, { "cell_type": "code", "execution_count": null, "id": "07441ea9", "metadata": { "jupyter": { "outputs_hidden": false } }, "outputs": [], "source": [ "integrate(e, z)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.10" } }, "nbformat": 4, "nbformat_minor": 5 }