-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f06ea63
commit 7f1ba67
Showing
6 changed files
with
142 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,3 +173,4 @@ poetry.toml | |
# User defined | ||
*.png | ||
.vscode/ | ||
*tmp* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,25 @@ | ||
from datetime import datetime | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
from math import * | ||
from sympy import * | ||
|
||
string = input("Enter Function to be Plot\n\tf(x) = ") | ||
|
||
func_str = "lambda x: " + string.replace("^", "**") | ||
func = eval(func_str) | ||
x = symbols("x") | ||
|
||
x = np.linspace(-10, 10, 100) | ||
y = np.apply_along_axis(np.vectorize(func), 0, x) | ||
|
||
plt.plot(x, y) | ||
plt.ylabel(string) | ||
plt.xlabel("x") | ||
plt.show() | ||
# file_name = str(datetime.now()).split(".")[0].replace(":", "-") + ".png" | ||
# plt.savefig(file_name, bbox_inches='tight') | ||
def graph_compute_points(func, start=-3.14, end=3.14): | ||
x_axis = np.linspace(start, end, 50) | ||
y_axis = np.vectorize(lambda value: float(func.subs(x, value)))(x_axis) | ||
|
||
return x_axis, y_axis | ||
|
||
|
||
def graph(func, start=-3.14, end=3.14): | ||
x_axis, y_axis = graph_compute_points(func, start, end) | ||
|
||
plt.plot(x_axis, y_axis) | ||
plt.show() | ||
|
||
|
||
if __name__ == "__main__": | ||
func = input("f(x): ") | ||
graph(eval(func)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from collections.abc import Iterable | ||
from sympy import * | ||
|
||
|
||
def convert_to_latex(item): | ||
if not isinstance(item, Iterable): | ||
return latex(item) | ||
|
||
item_latex = [] | ||
for i in item: | ||
item_latex.append(latex(i)) | ||
|
||
return item_latex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters