Skip to content

Commit 39f5157

Browse files
authored
Merge pull request sanscript-tech#223 from kritikaparmar-programmer/sympy
Added Sympy
2 parents 270f292 + 3655f73 commit 39f5157

File tree

3 files changed

+400
-0
lines changed

3 files changed

+400
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"import sympy"
10+
]
11+
},
12+
{
13+
"cell_type": "code",
14+
"execution_count": 2,
15+
"metadata": {},
16+
"outputs": [],
17+
"source": [
18+
"from sympy.solvers import solve\n",
19+
"from sympy import Symbol\n",
20+
"from sympy import Eq"
21+
]
22+
},
23+
{
24+
"cell_type": "code",
25+
"execution_count": 4,
26+
"metadata": {},
27+
"outputs": [
28+
{
29+
"data": {
30+
"text/plain": [
31+
"[-1, 1]"
32+
]
33+
},
34+
"execution_count": 4,
35+
"metadata": {},
36+
"output_type": "execute_result"
37+
}
38+
],
39+
"source": [
40+
"x = Symbol('x')\n",
41+
"eq = (x**2 - 1, x)\n",
42+
"solve(eq)"
43+
]
44+
},
45+
{
46+
"cell_type": "code",
47+
"execution_count": 8,
48+
"metadata": {},
49+
"outputs": [
50+
{
51+
"data": {
52+
"text/plain": [
53+
"[-11]"
54+
]
55+
},
56+
"execution_count": 8,
57+
"metadata": {},
58+
"output_type": "execute_result"
59+
}
60+
],
61+
"source": [
62+
"y = Symbol('y')\n",
63+
"eq = Eq(y + 3 + 8)\n",
64+
"solve(eq)"
65+
]
66+
},
67+
{
68+
"cell_type": "code",
69+
"execution_count": 15,
70+
"metadata": {},
71+
"outputs": [
72+
{
73+
"data": {
74+
"text/latex": [
75+
"$\\displaystyle -\\infty < x \\wedge x < 3$"
76+
],
77+
"text/plain": [
78+
"(-oo < x) & (x < 3)"
79+
]
80+
},
81+
"execution_count": 15,
82+
"metadata": {},
83+
"output_type": "execute_result"
84+
}
85+
],
86+
"source": [
87+
"solve(x < 3)"
88+
]
89+
},
90+
{
91+
"cell_type": "code",
92+
"execution_count": 16,
93+
"metadata": {},
94+
"outputs": [
95+
{
96+
"data": {
97+
"text/plain": [
98+
"([x, y], {(-sqrt(3), 1), (sqrt(3), 1)})"
99+
]
100+
},
101+
"execution_count": 16,
102+
"metadata": {},
103+
"output_type": "execute_result"
104+
}
105+
],
106+
"source": [
107+
"solve([x**2 - 3, y - 1], set=True)"
108+
]
109+
},
110+
{
111+
"cell_type": "code",
112+
"execution_count": 17,
113+
"metadata": {},
114+
"outputs": [
115+
{
116+
"data": {
117+
"text/latex": [
118+
"$\\displaystyle \\sin^{2}{\\left(x \\right)} + \\cos^{2}{\\left(x \\right)}$"
119+
],
120+
"text/plain": [
121+
"sin(x)**2 + cos(x)**2"
122+
]
123+
},
124+
"execution_count": 17,
125+
"metadata": {},
126+
"output_type": "execute_result"
127+
}
128+
],
129+
"source": [
130+
"c = sympy.sin(x)**2 + sympy.cos(x)**2\n",
131+
"c"
132+
]
133+
},
134+
{
135+
"cell_type": "code",
136+
"execution_count": 14,
137+
"metadata": {},
138+
"outputs": [
139+
{
140+
"name": "stdout",
141+
"output_type": "stream",
142+
"text": [
143+
"Enter the quation in terms of x: \n",
144+
"\n",
145+
"x**2-1\n"
146+
]
147+
},
148+
{
149+
"data": {
150+
"text/latex": [
151+
"$\\displaystyle \\left\\{-1, 1\\right\\}$"
152+
],
153+
"text/plain": [
154+
"FiniteSet(-1, 1)"
155+
]
156+
},
157+
"execution_count": 14,
158+
"metadata": {},
159+
"output_type": "execute_result"
160+
}
161+
],
162+
"source": [
163+
"from sympy import solveset\n",
164+
"x = Symbol('x')\n",
165+
"print(\"Enter the quation in terms of x: \\n\")\n",
166+
"equation = input()\n",
167+
"solveset(equation)"
168+
]
169+
}
170+
],
171+
"metadata": {
172+
"kernelspec": {
173+
"display_name": "Python 3",
174+
"language": "python",
175+
"name": "python3"
176+
},
177+
"language_info": {
178+
"codemirror_mode": {
179+
"name": "ipython",
180+
"version": 3
181+
},
182+
"file_extension": ".py",
183+
"mimetype": "text/x-python",
184+
"name": "python",
185+
"nbconvert_exporter": "python",
186+
"pygments_lexer": "ipython3",
187+
"version": "3.7.6"
188+
}
189+
},
190+
"nbformat": 4,
191+
"nbformat_minor": 4
192+
}

Python/Sympy/README.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Sympy
2+
https://www.sympy.org/en/index.html
3+
4+
SymPy is an open-source Python library for symbolic computation. It provides computer algebra capabilities either as a standalone application, as a library to other applications, or live on the web as SymPy Live or SymPy Gamma
5+
6+
# Installing Sympy
7+
```
8+
pip install sympy
9+
```
10+
- For Anaconda
11+
```
12+
conda update sympy
13+
```
14+
15+
## How to use sympy
16+
The Jupyter Notebook in this folder show examples on how to use Sympy to solve algaebric problems.

0 commit comments

Comments
 (0)