Posted
on 20 March, 2009, 11:39 pm,
by Jason Francis,
under
Uncategorized.
I gave my APS talk this morning and spent the rest of the day working on my thesis. I was uploading the latest version tonight (almost done!) when I noticed some old python code I had written to numerically solve first order ODEs using Euler’s method.
Perhaps this is an indication that I should get to work on the ODE solver portion of the C# code I’ve been (not) working on.
Posted
on 26 January, 2009, 10:07 pm,
by Jason Francis,
under
Science.
I’ve added a function to determine the trace of a matrix, since even though it doesn’t come up that often, it does come up occasionally, and it only takes about thirty seconds to code.
public static double trace(double[,] matrix)
{
int n = Convert.ToInt32(Math.Sqrt(matrix.Length));
double trace = 0;
for(int i = 0; i< n; i++)
trace += matrix[i,i];
return trace;
}
You may be wondering about the square root part. C#’s Length function returns the total number of elements in a matrix. Since we’re passing in a square matrix, taking the square root gives the number of rows/columns. At some point I should add code to check that the matrix is indeed square and error out gracefully if it isn’t.
I’ve also upgraded the site to Wordpress 2.7 and changed the theme to something nice and simple. The 2.7 migration shouldn’t result in any appearance or functionality changes, but the admin section is much nicer now.
Posted
on 25 January, 2009, 11:56 pm,
by Jason Francis,
under
Science.
I’ve continued working on the C# code and currently have the ability to do a couple types of approximations/interpolations and find matrix determinants quickly.
I think the next thing I’m going to work on is finding the matrix inverses (probably via the Faddeev-Leverrier method) so I can find eigenvalues and eigenvectors.
There are, of course, countless libraries and software packages that could do these types of calculations me, and in practice I would in all likelihood use them. Nonetheless, I think it’s useful to understand how those libraries work and thus, perhaps, when it is appropriate to use them as opposed to writing my own specialized code. And of course, doing this is just plain fun.
Posted
on 14 January, 2009, 1:25 am,
by Jason Francis,
under
Science.
In an effort to learn more C#, entertain myself, and prepare for a future sitting behind a computer doing simulations (assuming I get into graduate school), I started working on a C# library to help out with doing (discrete) numerical problems in physics. The current plan is to have it do
- Physical constants
- Function approximation
- Derivatives
- Integrals
- ODEs
- PDEs
- Matrices (eigenvalue problems)
- Spectral analysis (fast fourier transforms, etc)
So far, I’ve mostly completed the physical constants bit, since that’s trivial and requires no real effort, and have started working on the approximation code, which is necessary to properly handle some of the latter things (e.g. determining slope at boundaries).
The basic idea is to make something that would cut down on the time required to write quick and dirty simulations. It’s not intended to be the fastest or most elegant code, but simply something that works and gives correct answers.
Posted
on 27 October, 2008, 10:26 pm,
by Jason Francis,
under
Uncategorized.
I’m switching back to Wordpress again, for good this time. Maybe someday I’ll post something here.