Stitching together two functions is sometimes required as a way to transition from one dependence to another. The following schematic describes the idea pictorially:
A random walk through a subset of things I care about. Science, math, computing, higher education, open source software, economics, food etc.
Monday, December 7, 2020
Smooth Transition Between Functions
Monday, October 26, 2020
Trapezoidal rule in log-log space
Consider the problem described in this StackOverFlow post. You have a function with certain smoothness properties that are apparent on a log-log plot. This is often accompanied by a large domain of integration. It seems worthwhile to "integrate in logspace", whatever that means.
This Jupyter notebook probes this question and makes some recommendations.
Wednesday, May 20, 2020
Quicktip: Reindent Python Scripts
Suppose part of a python file uses spaces for indentation, while another part uses tabs. This will throw up exceptions at runtime. So the question is how to fix it.
One answer is to use the python script reindent.py. Stick it in some folder (~/bin/) in the default path and make it executable (chmod +x reindent.py).
The usage is straightforward:
reindent -n file.py
modifies the original file in place.
One answer is to use the python script reindent.py. Stick it in some folder (~/bin/) in the default path and make it executable (chmod +x reindent.py).
The usage is straightforward:
reindent -n file.py
modifies the original file in place.
Sunday, May 17, 2020
Matplotlib: Saving TIFF and JPG formats
With pillow installed, on my LinuxMint installation:
import matplotlib
matplotlib.use('TkAgg') # backend
x = np.linspace(0,1)
plt.plot(x, x**2)
plt.savefig('test.tiff', dpi=300, fmt="tiff", pil_kwargs={"compression": "tiff_lzw"})
import matplotlib
matplotlib.use('TkAgg') # backend
x = np.linspace(0,1)
plt.plot(x, x**2)
plt.savefig('test.tiff', dpi=300, fmt="tiff", pil_kwargs={"compression": "tiff_lzw"})
Monday, January 20, 2020
QuickTip: Catching array bounds violations in Fortran 90
With gfortran, you can check if array bounds are violated during runtime by,
gfortran -fbounds-check myProg.f90
gfortran -fbounds-check myProg.f90