Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View Exoutia's full-sized avatar
🍈
Great mood

Bibek Jha Exoutia

🍈
Great mood
View GitHub Profile
@Exoutia
Exoutia / first_order_derivation.py
Last active August 23, 2022 04:06
First order derivation of standard algebraic polynomial in python
import re
x = "x**4 + 33*x**3 - 23*x**2 + 2*x + 1"
def first_order(x):
res = ''
for sign, coef, expo in re.findall("([\+-]?)\s?(\d+?)?\*?x\*?\*?(\d?)", '+' + x):
if coef == "":
coef = "1"
coef = int(sign + coef)
if expo == "":
expo = "1"