Instantly share code, notes, and snippets.

Kazi Abu Rousan aburousan

Created December 7, 2022 15:44
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
 from math import floor, sqrt def lattice_inside(N):#give square of the radius,i.e., R = \sqrt(N) summ = 0; loop_no = int(N/3) + 2 for i in range(0,loop_no+1): a = floor(N/(3*i+1)) b = floor(N/(3*i+2)) # print(a,b,i) summ = summ + 6*(a-b) return summ + 1
Created August 5, 2022 10:47
check irrationality for any number using integral root theorem (IRT)
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
 from sympy import minimal_polynomial, Poly, root, divisors, pi def check_irrational(m): result = True p = minimal_polynomial(m) print("Minimal Polynomial of ",m , " is = ",p) pol = Poly(p) a_0 = pol.all_coeffs()[-1] print(" The a_0 is = ", a_0) div_p = divisors(a_0) div_n = [-1*i for i in div_p]
Created June 27, 2020 10:38
This shows a program to calculate Integration using Trapezoidal Rule with a desired Accuracy
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
 import numpy as np original_value = np.pi/4 def f(x): return 1/(1+x*x)#1st step is done def trapizoid(f,a,b,tol): fa = f(a); fb = f(b);I = 0 n =10; it = 1#Iteration number while True: h = (b-a)/n
Last active June 29, 2020 12:32
This is a program to Integrate using Trapezoidal Rule. Here you can also see the plot of the Trapezoids
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
 import numpy as np import matplotlib.pyplot as plt original = np.pi/4 def f(x): return 1/(1+(x*x)) x_real = np.linspace(0,1,1000)#This and the next line are used to create a plot of the curve represented by our f(x) function. y_real = f(x_real) def traezoid(f,n,a=0,b=1):