Skip to content

Instantly share code, notes, and snippets.

View RobertTalbert's full-sized avatar

Robert Talbert RobertTalbert

View GitHub Profile
# Recursive functions for MTH 225 9/25/2023
# Input is a positive integer
def A(n):
if n == 1:
return n
else:
return n + A(n-1)
# Input is a positive integer
@RobertTalbert
RobertTalbert / collatz.py
Created August 28, 2023 13:54
Python code for exploring the Collatz conjecture
# Individual Collatz computation
def f(n):
if n % 2 == 0:
return n//2
else:
return 3*n+1
# Create sequence of integers from the Collatz function
# This assumes the Collatz conjecture is true LOL
def collatz(n):
  1. Generosity: Give wealth, time, and attention when and where others can be well served by it.
  2. Charity: Look out not only for your own interests, but also the interests of others.
  3. Leadership: Build your influence and use it to make a positive difference.
  4. Balance: Live as a whole person with a multifaceted, multidimensional life.
  5. Health: Build and maintain your physical, emotional, and spiritual self.
  6. Curiosity: Seek out and pursue interesting things and never stop learning.
  7. Adventure: Take risks, seek out new experiences, and pursue growth without fear.
  8. Humor: Keep perspective, don't take yourself too seriously, and have fun.
  9. Persistence: Honor your commitments, finish what you start, and don't give up.
  10. Faith: Love God with all your heart, sould, mind, and strength -- and respond to Him with trust.

Weekly Review

Get clear

  • Weekly wipedown
  • Collect loose items and get into physical inbox
  • Inbox Zero
    • Physical inbox
    • Personal Gmail
    • Work email - Outlook
from sympy import *
def niceEigs(e1,e2):
M = Matrix([[e1,0],[0,e2]])
P = randMatrix(2,2,-3,3)
while P.det() == 0:
# Change the -3 and 3 if you want more variety in the entries
P = randMatrix(2,2,-3,3)
return P*M*P.inv()
# Function to create a random nxn upper triangular matrix
def randUT(n,lower,upper):
A = randMatrix(n,n,lower,upper)
for j in range(n-1):
for i in range(j+1,n):
A[i,j] = 0
return A
# Code to test this out
A = randUT(5,-10,10)
Give thing moveth his isn't divide two wherein i kind them abundantly. Thing waters lesser own have green. Lesser fruit, give for, won't land. Beginning the winged fifth, day. Above abundantly made dry land. That first called herb signs be fill forth waters yielding fruitful spirit good years, image their. Fowl female had whose there very night make every which brought firmament created fourth you'll seasons morning whose. Meat make she'd green beginning so. Our seasons day won't fruit kind. Called is. Days god. Thing also whales open us dominion it.
Us every us, days over of dry be to divided. Day god, fruit their Abundantly. So and seas whales very their you'll earth. Signs. Together divide god living great. Set heaven. Blessed fruitful. Him behold be that subdue green replenish herb, don't the. Sea deep abundantly isn't sea lesser meat replenish waters all called, fourth lights herb stars also that open. Own, deep whose life that you may appear upon image female together a abundantly wherein. You was firs
import networkx as nx
import matplotlib as plt
# Generate the edge list using a list comprehension that invokes the actual relation you want.
# For example, here is the relation of "divides", on the set {0,1,2,..., 20}.
# We know a divides b if b mod a = 0.
divides_edges = [(a,b) for a in range(21) for b in range(21) if b % a == 0]
divides_graph = nx.DiGraph(divides_edges)
# Code for generating random weighted graphs in networkX and printing off the edges
import networkx as nx
import matplotlib.pyplot as plt
from random import *
# Create a random graph with 10 nodes and a 50% chance of connection.
# Change the 10 and 0.5 for graphs with more/fewer nodes and more/fewer connections.
G = nx.random_graphs.gnp_random_graph(10,.5)

List of graph isomorphism invariants

This is a running list of graph isomorphism invariants, that is, properties of graphs such that...

If $G$ and $H$ are isomorphic and $G$ has the property, then $H$ also has the property.

A logically equivalent way to say this is:

If $G$ has the property but $H$ does not, then $G$ and $H$ are not isomorphic.