Solving Partial Differential Equations in Python
Skills:
AI Pair Programming80%
Key Takeaways
Solving Partial Differential Equations in Python using SymPy
Full Transcript
what is going on guys welcome back in this video today we're going to learn how to solve partial differential equations in Python so let us get right into [Music] it all right so another math Focus tutorial we're going to learn how to solve partial differential equations in Python today and as always I'm not going to focus too much on the mathematics I'm a computer scientist a programmer not a mathematician I want to focus on how to actually solve them in Python using code and the reason I think this is a useful tutorial is because the ways to solve partial differential equations without doing it yourself by hand um I didn't find so many ways to do that wolf from alpha doesn't seem to be very capable of doing that and the software the only software that I found that uh does that Maple is actually costing money so it's not free of course here you can just enter a partial differential equation you can use PD solve you can also use it with an initial condition uh which unfortunately we're not going to be able to do in this video today I try to make it work but just doing a simple solve on the equation and an initial condition to get the exact solution doesn't work as easily in python or at least with a senpai package we would probably have to implement some mechanism uh ourselves there but we can get at least to the general solution quite quickly and we can do that for free using the python package simpai which is for symbolic mathematics so you can open up your terminal install simpai by using pip so pip P three install simpi and then we can go ahead and solve this uh partial differential equation here in this case it's x * the partial derivative of U with respect to x minus uh 3 * y * the partial derivative of U with respect to Y is equal to 2x^2 * U and we also have this initial condition U um of T and T ^2 is equal to e to the^ of t^2 so that is basically it and as I said we're not going to be able to do that easily we have to do it by hand or we have to code some mechanism around it but the general solution can be uh can be found easily which is very useful if you're studying for a Calculus exam and you want to quickly check your Solutions and you don't want to spend money on software so we're going to say here import simpai SSP and we're going to Define our partial or actually first of all we need to define the symbols we're going to define the symbols first X and Y are our symbols or our variables uh so we need to Define them an SSP symbols X and Y and then we also Define our function U SP function it's the function U which is a function of X and Y so this is how we do that and then we just have to Define our partial differential equation by saying it's an SP equation and here we pass the left side and the right side so we say x times diff or actually SP diff um of U with respect to x - 3 * Y and since we defined these now as symbols and functions multiplying and subtracting and so on is done symbolically and not as a calculation uh so 3 * y * SPD of U with respect to Y and then we use a comma to say the right hand side is 2 * x^2 * U all right so this is our equation and now getting a solution is very very easy we just say solution equals and then SP uh PD solve same name as in Maple PD and then we can look at the solution and you can see this is our general solution we can also only get the right hand side solution. rhs and you can see that basically the solution is e to the power of x to the power of 2 so e to the E to the^ of x^2 um times some function that takes X to the^ 3 and Y is input now as I said we don't have an easy way or at least I don't know one if you know one let me know in the comment section down below I would be very interested in that uh but as far as I know there's not an easy way to just go ahead plug in in initial condition especially not one where you have a placeholder like T um or a variable like T and easily find the exact solution so from here you could go ahead and try to substitute X and Y with t and t^2 which I try to do I have a bunch of code written that I don't think is very useful to show you guys but what you can do is you can just keep going here yourself so what you see is that the um condition here says if you plug in T and t^2 you get e t^2 so that's basically just e x^2 um and yeah basically you can see that then the function of of x to the^ 3 and Y is equal to nothing so to it's basically just one um and yeah that basically leaves us with with this but this is manually so this is not automated in Python but to me this is a very useful thing again because I didn't find um a lot of software that can solve partial differential equations easily the only one that can do it very good or very well is maple but Maple is not free so this is a very nice free alternative in Python so that's it for today's video I hope you enjoyed it and hope you learned something if so let me know by hitting a like button and leaving a comment in the comment section down below and of course don't forget to subscribe to this Channel and hit the notification Bell to not miss a single future video for free other than that thank you much for watching see you in the next video and bye
Original Description
In this video, we learn how to solve Partial Differential Equations (PDEs) in Python using SymPy.
◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
📚 Programming Books & Merch 📚
🐍 The Python Bible Book: https://www.neuralnine.com/books/
💻 The Algorithm Bible Book: https://www.neuralnine.com/books/
👕 Programming Merch: https://www.neuralnine.com/shop
💼 Services 💼
💻 Freelancing & Tutoring: https://www.neuralnine.com/services
🌐 Social Media & Contact 🌐
📱 Website: https://www.neuralnine.com/
📷 Instagram: https://www.instagram.com/neuralnine
🐦 Twitter: https://twitter.com/neuralnine
🤵 LinkedIn: https://www.linkedin.com/company/neuralnine/
📁 GitHub: https://github.com/NeuralNine
🎙 Discord: https://discord.gg/JU4xr8U3dm
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from NeuralNine · NeuralNine · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Visualizing Stock Data With Candlestick Charts in Python
NeuralNine
Python Beginner Tutorial #1 - Installation and First Program
NeuralNine
Python Beginner Tutorial #2 - Variables and Data Types
NeuralNine
Python Beginner Tutorial #3 - Operators and User Input
NeuralNine
Python Beginner Tutorial #4 - If Statements and Conditions
NeuralNine
Python Beginner Tutorial #5 - Loops
NeuralNine
Python Beginner Tutorial #6 - Sequences and Collections
NeuralNine
Python Beginner Tutorial #7 - Functions
NeuralNine
Python Beginner Tutorial #8 - Exception Handling
NeuralNine
Python Beginner Tutorial #9 - File Operations
NeuralNine
Python Beginner Tutorial #10 - String Functions
NeuralNine
Python Intermediate Tutorial #1 - Classes and Objects
NeuralNine
Python Intermediate Tutorial #2 - Inheritance
NeuralNine
Python Intermediate Tutorial #3 - Multithreading
NeuralNine
Python Intermediate Tutorial #4 - Synchronizing Threads
NeuralNine
Python Intermediate Tutorial #5 - Events and Daemon Threads
NeuralNine
Python Intermediate Tutorial #6 - Queues
NeuralNine
Python Intermediate Tutorial #7 - Sockets and Network Programming
NeuralNine
Python Intermediate Tutorial #8 - Database Programming
NeuralNine
Python Intermediate Tutorial #9 - Recursion
NeuralNine
Python Intermediate Tutorial #10 - XML Processing
NeuralNine
Python Intermediate Tutorial #11 - Logging
NeuralNine
Python Data Science Tutorial #1 - Anaconda and PyCharm Setup
NeuralNine
Python Data Science Tutorial #2 - NumPy Arrays
NeuralNine
Python Data Science Tutorial #3 - Numpy Functions
NeuralNine
Python Data Science Tutorial #4 - Plotting Functions With Matplotlib
NeuralNine
Python Data Science Tutorial #5 - Subplots and Multiple Windows
NeuralNine
Python Data Science Tutorial #6 - Matplotlib Styling
NeuralNine
Python Data Science Tutorial #7 - Bar Charts with Matplotlib
NeuralNine
Python Data Science Tutorial #8 - Pie Charts with Matplotlib
NeuralNine
Python Data Science Tutorial #9 - Plotting Histograms with Matplotlib
NeuralNine
Python Data Science Tutorial #10 - Scatter Plots with Matplotlib
NeuralNine
Python Data Science Tutorial #11 - 3D Plotting with Matplotlib
NeuralNine
Python Data Science Tutorial #12 - Pandas Series
NeuralNine
Python Data Science Tutorial #13 - Pandas Data Frames
NeuralNine
Python Data Science Tutorial #14 - Pandas Statistics
NeuralNine
Python Data Science Tutorial #15 - Pandas Sorting and Functions
NeuralNine
Python Data Science Tutorial #16 - Pandas Merging Data Frames
NeuralNine
Python Data Science Tutorial #17 - Pandas Queries
NeuralNine
Python Machine Learning Tutorial #1 - What is Machine Learning?
NeuralNine
Python Machine Learning Tutorial #2 - Linear Regression
NeuralNine
Python Machine Learning Tutorial #3 - K-Nearest Neighbors Classification
NeuralNine
Python Machine Learning #4 - Support Vector Machines
NeuralNine
Python Machine Learning Tutorial #5 - Decision Trees and Random Forest Classification
NeuralNine
Python Machine Learning Tutorial #6 - K-Means Clustering
NeuralNine
Python Machine Learning Tutorial #7 - Neural Networks
NeuralNine
Python Machine Learning Tutorial #8 - Handwritten Digit Recognition with Tensorflow
NeuralNine
Generating Poetic Texts with Recurrent Neural Networks in Python
NeuralNine
Stock Portfolio Visualization with Matplotlib in Python
NeuralNine
Analyzing Coronavirus with Python (COVID-19)
NeuralNine
Making Text Images Readable Again with Python and OpenCV
NeuralNine
Neural Networks Simply Explained (Theory)
NeuralNine
Motion Filtering with OpenCV in Python
NeuralNine
Top 5 Programming Languages To Learn in 2020
NeuralNine
Simple TCP Chat Room in Python
NeuralNine
Image Classification with Neural Networks in Python
NeuralNine
Edge Detection with OpenCV in Python
NeuralNine
S&P 500 Web Scraping with Python
NeuralNine
Simple Sentiment Text Analysis in Python
NeuralNine
Introduction - Algorithms & Data Structures #1
NeuralNine
More on: AI Pair Programming
View skill →
🎓
Tutor Explanation
DeepCamp AI