{ "cells": [ { "cell_type": "markdown", "id": "0", "metadata": {}, "source": [ "# A simple SymPy example" ] }, { "cell_type": "markdown", "id": "1", "metadata": {}, "source": [ "First we import SymPy and initialize printing:" ] }, { "cell_type": "code", "execution_count": null, "id": "2", "metadata": { "jupyter": { "outputs_hidden": false } }, "outputs": [], "source": [ "from sympy import diff, init_printing, integrate, sin, symbols" ] }, { "cell_type": "code", "execution_count": null, "id": "3", "metadata": {}, "outputs": [], "source": [ "init_printing()" ] }, { "cell_type": "markdown", "id": "4", "metadata": {}, "source": [ "Create a few symbols:" ] }, { "cell_type": "code", "execution_count": null, "id": "5", "metadata": { "jupyter": { "outputs_hidden": false } }, "outputs": [], "source": [ "x, y, z = symbols(\"x y z\")" ] }, { "cell_type": "markdown", "id": "6", "metadata": {}, "source": [ "Here is a basic expression:" ] }, { "cell_type": "code", "execution_count": null, "id": "7", "metadata": { "jupyter": { "outputs_hidden": false } }, "outputs": [], "source": [ "e = x**2 + 2.0 * y + sin(z)\n", "e" ] }, { "cell_type": "code", "execution_count": null, "id": "8", "metadata": { "jupyter": { "outputs_hidden": false } }, "outputs": [], "source": [ "diff(e, x)" ] }, { "cell_type": "code", "execution_count": null, "id": "9", "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 }