How to Plot Partial Differentials?

Viewed 37

I am making a Python program that can calculate partial differential, the user can input the formula by himself, for example: x2+x*y+y2, I hope my program can calculate the result and plot it, I have now using Sympy to successfully calculate the result, but I don't know how to draw, how should I draw this graph?

1 Answers

I recommend you going deep inside the matplotlib (https://matplotlib.org/), it's an awesome python library to display graphs, for scientific porposes is very useful.

For example, you should do the following:

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 100, 100)
y = np.linspace(0, 100, 100)

def func(x, y):
    return x**2 + x*y + y**2

result = func(x,y)

plt.plot(x, result) # plot result function of x
plt.plot(y, result) # plot result function of y

It's a very basic example only showing you how to plot.

Related