grapher

Compare any number of Mathematical Equations and their graphs to see the level of similarity betweeb them in just one line of code. Eg: Taylor Polynomial


Keywords
maths, equations, graphs, Compare, plot, mathematics, graph, comparision, comparing
License
MIT
Install
pip install grapher==v1.8

Documentation

Grapher

This is a Graphing Library for

  • Educations
  • Scientific/Mathematical Research
  • Graph Analysis

It helps you to graph any number of equations onto one single graph. This makes it easy for determining the relation between some graphs and understaing better solutions.

New

Now you can Differenciate any function you want.

Installation

pip install grapher
Then you can access it using:

from grapher import Grapher
g = Grapher(['sinx', 'cosx'])
g.plot()

# Example

Code for it:

g = Grapher(['cos(x)', '1 - ((x^2)/factorial(2)) + (x^4)/factorial(4)'], lb=-3, ub=3, lol='lower center', title='Taylor Polynomial for cos(x)')
g.plot()

Features

  • Now you can differenciate any function you want and see its graph.
  • Code Tolerance. So, sin(x) is the best way to write but sinx is also acceptable. Similar for all Trignometriic Functions.
  • Build in functions for commonly used Mathmatical Operations. Eg: sin, cos, tan, cosec, sec, cot, log, ln, factorial, sqrt, cbrt and constants like pi and e.

Usage

Grapher(fx, lb=-10, ub=10, y_lim=[None, None], step=0.01, label=True, grid=False, xlabel='x', title=None, lol='upper left', linestyle='-', mode='light', style=None)

fx = An Array for functions to be graphed.
Eg:
['sinx', 'cosx']
This is the only required argument.

Output:

g = Grapher(['sinx', 'cosx'])
g.plot()

# ```lb=-10, ub=10``` They define the Lower Bound and the Upper Bound of the Function. Mathematically the domain of the function.
```y_lim=[None, None]``` This is to make the graph spread across only a certain part of y.
You can use to get closer to any section along y axis.

```step=0.01```
This is by how much the next number is more than the other. Try to keep it low for a better and more accurate result.
Step of 0.01 is a preety good step for accuracy. But 0.001 is even better. But decreasing it too low may cause the program to slow down as a lot of computation needs to be done.
Therefore 0.01 is probably the sweet spot. But you know better for your own given equation and comutational speed.

#### Now Comes the features for customization of the looks of the graph. ```label=True```
It is just the legend on the Graph. It helps to keep track of the function by color coding them.
```grid=False```
This makes grid on the graph for better precision.
```xlabel='x', title=None```
xlabel is the label of the X-axis of the graph. When set to some value Eg: 'Month', ylabel is set to f (Month) automatically.
To change the ylabel, do g.ylabel = 'Your Y Label here.'
Title is the overall title of the page. Eg: 'Comparing cos(x) with its 4th order Taylor Polynomial.'
``` ```lol='upper left'```
lol stands for Location of Legend. It takes standard values as by matplotlib.

linestyle='-'
This is the style of line that you want to have for your graph. (Values same as matplotlib.)
mode='light'
This has 2 Options. light/dark. Dark will make it with a black background and light text and graph lines.
style=None
If you want more customization, then you can give a string of any style available for matplotlib. This can be used to make your Graphs look beautiful.

Functions Available

There is a list of predefined common functions that you can use from.
If you want more functionality, then you can use your command with np.command or math.command.

Functions available to you.

  • sin(x)
  • cos(x)
  • tan(x)
  • cosec(x)
  • sec(x)
  • tan(x)
  • log(x, base=10)
  • ln(x)
  • sqtr(x)
  • cbrt(x)
  • d("func")

While using d (derivative as in d("cosx")), pass the function to be diffenciated within QUOTES. Technically, it should be a string. Otherwise it will throw an error.

Some Commonly used constants

  • pi
  • e

You can use them all easily just by typing them, without even thinking about how are they getting called.
# Sample: some equations like, ` ['sinx', 'cosx', 'e^x', 'pi^tan(x)'] ` will work without any issue.

Contribution

You have a lot of ways to contribute to this library. It doesnt work with multiple variables, just x and f(x).
We still dont have 3d graphs, you can help in implimeneting it. Just clone this repo, add featues and request for a Merge.

Support

Well, just keep thinking, innovating, graphing and analysing and share. Thats it for support.

I Dont Drink Coffee ! So, wont ask to buy me one ;)