Skip to content

Instantly share code, notes, and snippets.

View hamzaavvan's full-sized avatar
🎯
Focusing

Hamza Avvan hamzaavvan

🎯
Focusing
View GitHub Profile
@hamzaavvan
hamzaavvan / linear_eq.py
Created October 6, 2019 09:48
Python - Solving Linear Equeation Matrices
from sympy.interactive import printing
from sympy import Eq, solve_linear_system, Matrix
from numpy import linalg
import numpy as np
import sympy as sp
printing.init_printing(use_latex=True)
eq1 = sp.Function('eq1')
eq2 = sp.Function('eq2')
@hamzaavvan
hamzaavvan / matrix-operations.py
Created October 6, 2019 09:48
Python - Matrix Addition/Subtraction
def createMatrix():
_matrix = []
ms=int(input("Enter no. of matrices to create: "))
for i in range(ms):
print("\nMatrix %i"%(i+1))
r=int(input("\tEnter no. of rows: "))
c=int(input("\tEnter no. of columns: "))
@hamzaavvan
hamzaavvan / matrices_init.py
Created October 6, 2019 09:47
Python - Creating Dynamic Matrices
def createMatrix():
_matrix = []
ms=int(input("Enter no. of matrices to create: "))
for i in range(ms):
print("\nMatrix %i"%(i+1))
r=int(input("\tEnter no. of rows: "))
c=int(input("\tEnter no. of columns: "))
@hamzaavvan
hamzaavvan / newton-rapson.py
Created October 6, 2019 09:46
Python - Newton Method Code
import sympy as sp
from scipy.misc import derivative
x = sp.Symbol('x')
# y = sp.diff(3*x**2+1, x)
# print (y)
x = float(input("Enter x: "))
@hamzaavvan
hamzaavvan / derivate.py
Created October 6, 2019 09:45
Python Derivative Code (+ Plotting)
# method 1
import sympy as sp
x = sp.Symbol('x')
y = sp.diff(3*x**2+1, x)
print (y)
# method 2
from scipy.misc import derivative
@hamzaavvan
hamzaavvan / secant.py
Last active October 6, 2019 09:43
Python Secant Method Code
x1=int(input("Enter x1: "))
x2=int(input("Enter x2: "))
def f(x):
return x**4 - x - 10
def form(x1, x2):
return ((x1 * f(x2) - x2 * f(x1)) /
(f(x2) - f(x1)))
x1=int(input("Enter x1: "))
x2=int(input("Enter x2: "))
def f(x):
return x**4 - x - 10
def form(x1, x2):
return ((x1 * f(x2) - x2 * f(x1)) /
(f(x2) - f(x1)))