Skip to content

Instantly share code, notes, and snippets.

View dylanjm's full-sized avatar
💻
code is life

Dylan McDowell dylanjm

💻
code is life
  • Idaho National Laboratory (@idaholab)
  • North Western United States
View GitHub Profile
#!/usr/bin/env python3
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from tabulate import tabulate
def amort(principal, rate, n):
return principal * (rate * ((1 + rate) ** n)) / ((1 + rate) ** n - 1)
@dylanjm
dylanjm / tent_map_cobweb.py
Created March 14, 2024 18:29
A python script that plots the cobweb diagrams of the iterative tent map. This script uses the python 'decimal' library to avoid floating point arithmetic error propagation. This plot will run until the iteration values "escapes" (i.e. reaches a value > 1)
from decimal import Decimal, getcontext
import matplotlib.pyplot as plt
# Set the desired precision
getcontext().prec = 28
# Define the tent map function using Decimal for high precision
def tent_map(x, r):
half = Decimal('0.5')
return r*x if x < half else r*(1-x)