Skip to content

Instantly share code, notes, and snippets.

@nicoguaro
nicoguaro / complex_differentiation.py
Created February 11, 2026 13:49
Complex step differentiation evaluation for step size.
# -*- coding: utf-8 -*-
"""
Comparison of error in the derivative approximation as
a function of step size for different methods.
@author: Nicolás Guarín-Zapata
@date: February 2026
"""
import numpy as np
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.pyplot as plt
def assem(coords, elems, source):
"""
Ensambla la matriz de rigidez y el vector de cargas
Parámetros
----------
@nicoguaro
nicoguaro / pendulum_dae.py
Created February 1, 2026 01:12
Simple pendulum modeled as a differential-algebraic equation (DAE) instead of a ODE in the angle
# -*- coding: utf-8 -*-
"""
Solve the equations for a pendulum modeled as
a DAE
x' = u
y' = v
u' = λ x
v' = λ y - gy
λ' = 3g/L² v
@nicoguaro
nicoguaro / helm_dir.ipynb
Created March 12, 2025 03:28
Solución de la ecuación de Helmholtz inhomogénea para el problema de Dirichlet.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nicoguaro
nicoguaro / sherlock.png
Last active November 28, 2024 21:38
Wordcloud of Sherlock Holmes
sherlock.png
@nicoguaro
nicoguaro / cst_paper.mplstyle
Created September 9, 2024 20:55
Stylesheet for matplotlib for 2018 CCST paper
# Stylesheet for matplotlib
#
# Author: Nicolas Guarin-Zapata
# Date: September, 2018
### Math Text
mathtext.fontset : cm
### Text
text.color : 757575
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import trapezoid, simpson, quad
repo = "https://raw.githubusercontent.com/nicoguaro/matplotlib_styles/master"
style = repo + "/styles/clean.mplstyle"
plt.style.use(style)
plt.rcParams["font.size"] = 20
plt.rcParams["lines.linewidth"] = 3
@nicoguaro
nicoguaro / flips_coins.py
Created June 7, 2024 21:38
Flip a fair coin 100 times—it gives a sequence of heads (H) and tails (T). For each HH in the sequence of flips, Alice gets a point; for each HT, Bob does, so e.g. for the sequence THHHT Alice gets 2 points and Bob gets 1 point. Who is most likely to win?
# -*- coding: utf-8 -*-
"""
Flip a fair coin 100 times—it gives a sequence of heads (H)
and tails (T). For each HH in the sequence of flips, Alice
gets a point; for each HT, Bob does, so e.g. for the
sequence THHHT Alice gets 2 points and Bob gets 1 point.
Who is most likely to win?
https://x.com/littmath/status/1769044719034647001
@nicoguaro
nicoguaro / environment.yml
Last active June 18, 2024 02:04
Visualize origami configurations using Matplotlib.
name: ori-py
channels:
- conda-forge
dependencies:
- python
- numpy
- scipy
- matplotlib
- jupyterlab
- pyvista
@nicoguaro
nicoguaro / hermite_quintic.ipynb
Created May 17, 2024 22:49
Hermite interpolation using quintic polynomials
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.