Skip to content

Instantly share code, notes, and snippets.

@crbyxwpzfl
Last active April 15, 2024 05:14
Show Gist options
  • Save crbyxwpzfl/e6b8bf97e71b2204b4fda8f7fba4e058 to your computer and use it in GitHub Desktop.
Save crbyxwpzfl/e6b8bf97e71b2204b4fda8f7fba4e058 to your computer and use it in GitHub Desktop.
some python math browser
import sympy 
import numpy 
import scipy

x,y,z = sympy.symbols("x, y, z")
system = [
    sympy.Eq(3*x + 4*y, 7),
    sympy.Eq(5*x + 6*y, 8)
]

a = [
    [1,-1,-1,0],
    [0,0,1,-1],
    [1/2,3,0,0],
    [0,3,-1,-2],
    ]

b = [
    0,
    60,
    40,
    0
    ]

# numpy.triu(a) # upper triangular form
# scipy.linalg.lu(a) #gives plu # l is lower triangulal
# sympy.Matrix(a).T.columnspace()  # basis lines

# numpy.cross(a, b)
# numpy.dot(a, b)

numpy.linalg.solve(numpy.array(a), numpy.array(b))

# sympy.solve(system, [x, y])  # solve for x y

# sympy.integrate(x**2)
# sympy.diff(x**2)
# sympy.simplify((1/a)+(1/b))
# sympy.expand((1/(a+b)))
# ((a+b)/(a*b)).equals((1/a)+(1/b))
@crbyxwpzfl
Copy link
Author

run it in browser here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment