I've been writing a few programs that, given a math expression (provided as a string in a file), would evaluate f(x) for a given x, using py_expression_eval
Example:
input.txt
x^2 + 1
func.py
from py_expression_eval import Parser
parser = Parser()
file = open("input.txt")
func = file.readline().strip()
f_of_5 = parser.parse(func).evaluate({'x': 2})
output
5
Is there any way I can get the derivative of a function provided as a string like that?