Archive for February, 2005

Installing TeTeX latex packages

Monday, February 28th, 2005

Installing LaTeX packages under MikTeX, the windows distro I use, is painless: you just select them in a gui; consequently, I have all the available packages installed. On the other hand, you have to manually install LaTeX packages when you’re using TeTeX, the major *Nix TeX distribution. Since I barely know enough LaTeX as it is, without getting into the specifics of how kpathsea works, I’ve never installed any packages under TeTeX, even the ones that I really feel are necessary. Today, my laziness triumphed and I forced myself to learn how to install packages: I was working on my algebra homework, and was dreading typsetting polynomial long divison, when I realized that there is a package (polynom) which will handle it for you: you call it like (\polylongdivision{\frac{1}{2}x^2 + 2x}{x+1}} ) and it typesets the long division process for you! Hmm, hours of messing with spacing in tables, or learning how to install packages?

So here’s how to install latex packages, as gleaned (i.e. plagiarized) from the UK TeX FAQ:
(more…)

Convexity

Monday, February 28th, 2005

A function f is convex iff for every two points a,b in its domain,  \frac{f(a)+f(b)}{2} \geq f\left(\frac{a+b}{2}\right). Geometrically speaking, f is convex if every line joining two points on its graph lies completely above or on the graph of f.

I have always wondered what the point of convexity was: why do you care? What use is it, practically, to say that a function is convex? Since I’ve never seen any applications of it, or gotten far enough into the few analysis books I’ve started to read on my own, I never knew that convexity is a sufficient condition for continuity. How cool is that?

Also, it does have other practical uses: like for instance, showing that the \Gamma function is the only positive function on (0,\infty) with certain properties (which I am too lazy to write here), and furthermore, as a side-effect of that proof, you get the intimidating identity

 \displaystyle \Gamma[x] = \lim_{n\rightarrow \infty} \frac{n!n^x}{x(x+1)\cdots(x+n)}.

And who doesn’t love magical looking identities, especially when they combine the factorial and exponentiation?

What other strange sufficiency conditions are there for continuity?

the Ideal Graphing Calculator

Thursday, February 24th, 2005

Why isn’t there an open source project (at least not one I am aware of) for the design of a graphing calculator? There’s open source beer and cola, but not a graphing calculator, one of the modern icons of geekdom? Who will step up to remedy this– what intrepid engineer/mathematician desires to become a legend in his or her own time?

Some features the greatest calculator of all time must needs possess:

  1. programmable in Scheme, the best of languages.
  2. >1Gb memory, for storage of programs and emulators (one of the best features of Scheme is that it can easily emulate other languages such as the disgusting BASIC-like trash used by TIs :) )— if a lowly iPod has 3Gb, why not a graphing calculator.
  3. USB ports are a must have.
  4. A Mathematica quality CAS— you thought people actually used graphing calculators for graphing?; once again, look to Scheme for our salvation.
  5. Color!
  6. A detachable keyboard, in addition to the standard keypad– with all the power you’ll be packing, you might want to run a Scheme-based wordprocessor, after all.
  7. The ability to export stuff (very precise, I know) to LaTeX/MathML format.
  8. >1GHz, 512Mb RAM.

No claims are made of this list being exhaustive. Get to work, NOW!

Scheming out loud

Tuesday, February 22nd, 2005

I’ve been trying to implement a polynomial factorization program in Scheme, but it’s not coming along. It seems like the routines work fine when I’m testing them separately, but when they start calling each other, the bugs come out of the woodwork. I’m about to scrap it and start over…

On the up side, I found yet another wonderful piece of software, JScheme, a Java-based scheme interpreter/compiler. It can be used as a standard REPL/non-interactive Scheme interpreter, call Java object methods from within scripts, and compile Scheme code to .java files which can then be compiled to bytecode or used as Java packages. Seems like a perfect way to delegate tasks Scheme handles best to Scheme, and those Java handles best to Java. I love it, and I haven’t even used it yet.

I wonder if anyone out there is working on a Swing GUI for it?

Today in complex analysis…

Tuesday, February 22nd, 2005

I completed the proof that I’ve been working on for about two weeks— if a sequence s_0, s_1, \ldots is bounded, and z is such that |z|<1, then the series \sum_{k=0}^\infty s_k z^k converges. The proposition itself didn’t interest me too much, it was the tools necessary to prove it that I wanted: the triangle inequality, the existence of supremums and infimums, and the nested interval theorem. After having taken 2 other upper level courses with Dr. Johnson, those (except the triangle inequality) are topics that we spend a lot of time on— we managed to free up a significant amount of time this semester for new material by proving all that stuff early on.

Dr. Johnson made two important observations that added further tools to the kit: first, in the process, we had shown that any infinite bounded set has a limit point, and second, as a consequence, Cauchy sequences converge. At least, Cauchy sequences converge if in the concerned number system it is true that every set bounded above has a least upper bound.

He also defined the Stieljes integral today, and gave a nice introductory/motivatory talk on it. Here’s my paraphrasal of his definition:

Let f,g: \C \rightarrow \C be such that [a,b] is within the intial set of f,g. Then f is said to be g integrable on [a,b] iff there is a number M and a subdivision S of [a,b] such that given c>0, for all subdivisions R of S,
 \left| M - \sum_{t=1}^m f(r_{2t}) \left[ g(r_{2t+1}) - g(r_{2t-1}) \right] \right| < c.

I think that gets the gist of it. One sweet thing about this integral is that it makes some of the vague mathematical statements made in the sciences more precise; his example was  m = \int \rho\, dv . If we’re considering a rod whose volume v(x) and density p(x) vary along its length, how would we do that integration except via the Stieljes integral? I almost wished I hadn’t completed all my required mechanics classes, so I could bust out with that one on a homework assignment :).

Actually, since we’re dealing with a physical phenomena, I suspect all the concerned functions would be differentiable, and the Stieljes integral could be reduced to the form m = \int \rho\, dv = \int \rho \frac{\partial v}{\partial x} dx . I suspect this mainly because as that difference between the g(r_i) decreases, the difference term would approach g^\prime (r) \Delta r. We’ll see; supposedly he’s going to add derivatives to the toolbox sometime soon.

Moore’s method is such a neat way to learn math.

Kronecker’s Method of Factoring Polynomials over \Q[x]

Saturday, February 19th, 2005

Kronecker’s method is beautiful: it’s simple, and it always works. Here’s the idea:

Given a polynomial f \neq 0 \in \Z[x], we are trying to decide if f is reducible (can be expressed as the product of two polynomials in \Z[x], neither of which is 1 or -1), and if so to determine its factors, or irreducible (any factorization of f is trivial, in that it involves factoring out 1 or -1).

Note that if f is of degree n and we assume it is reducible to  f = g \cdot h , without loss we can assume that g has degree less than or equal to \lfloor \frac{n}{2} \rfloor — because if not, we would just switch g with the associated h.

Next, find \{z_i\}_{i=1,\ldots,\lfloor \frac{n}{2} \rfloor} \subset \Z such that \forall_i f(z_i) \neq 0. Then g(z_i) \mid f(z_i).

Construct all g of degrees 0 (excluding -1 and 1) through \lfloor \frac{n}{2} \rfloor such that g(z_i) is a divisor of f(z_i) for i=1,\ldots, \deg(g); you can use Lagrange polynomial interpolation to do this. Then test (using synthetic divison, for example) all these candidate g to find which divide f.

Pretty neat! Just reading the algorithm makes you want to program it up— in Scheme, no less!

To extend this algorithm for use in factorizing polynomials in \Q[x] is left as an exercise for the reader :).

Update
As I started to code this up, I realized synthetic division only applies when you are dividing by a linear factor— no biggie, just use polynomial long division. Here’s a simple algorithm to calculate (Q,R)=\text{Div}(a,b), where Q,R are such that a = Q\cdot b + R:

  1. if \deg(b) > \deg(a), then return (Q=0, R=a)
  2. else,
    •  p= \frac{a_{\deg(a)}}{b_{\deg(b)}}
    •  P=(p,\ldots,0) such that  \deg(P)=\deg(a)-\deg(b)
    • a^\prime = a - b \cdot P
    • (Q^\prime, R^\prime) = \text{Div}(a^\prime, b)
    • (Q,R) = (Q^\prime+P, R^\prime)

Biblical acccuracy

Friday, February 18th, 2005

Why is it that some people refuse to consider the fact that the Bible was redacted, if not written, by Man? Why is it that when asked why they consider the King James’ version of the Bible to be authorative, accurate in its translation, and most importantly complete they avoid the question? Can there be a real reason, or is this a case of said people deceiving themselves?

I was just talking to my mother, who was in Bible reading mode (alternately holier-than-thou mode), and asked her these questions, minus the rhetorical emphasis. Her first response was that she doesn’t see why she should worry about the Bible being incomplete: there’s already so much of it to handle. Her second response was that if you have such an issue with the completeness of the Bible, it’s because you’re straying. And that was the end of the discussion.

If she had simply said that she had faith in the completeness and accuracy of her chosen version of the Bible because she believed she had been led to it by God, for example, that would be a logically unassailable position, and probably the only one that makes any kind of sense. But she didn’t— what does it indicate that she didn’t?

A mathematical kind of day

Friday, February 18th, 2005

I’ve had a good day, the kind I imagined that I would have every day when I was in high school thinking about college. The kind I now imagine I will have every day when I’m in grad school… :)

I spent all day thinking about math, talking about it, doing it. Now I have a new project; I was talking to a friend taking a stochastic processes class. He’s been trying to convince me to take it when it’s offered again, but while I can see that it is a practical subject, and would like to know how to use Markov fields to create realistic images— I won’t be taking it, because it has a lot of probability and statistics. I would read a book on it, but not take a class. Then he told me about a non-linear dynamics class that UH used to offer, and mentioned a neat illustration that the prof gave:

A dog is in the center of an equilateral triangle with three trainers at each corner. When a trainer blows the whistle the dog travels in a straight line toward the trainer; when it reaches half-way, a different trainer (a random one of the other two) blows his whistle.

My project is to: think about this problem and see if I can prove something interesting about the dog’s behavior. Also, to write a program that lets you visualize the dog’s behavior– supposedly it is very interesting.

Here’s a Postscript program that simulates the dog’s travels after 101 whistles: (the conversion really loses a lot of information, but you can see there is a definite pattern; if you download the actual program, you can see it much better)

%PS
% visualize the dog training problem
/dogpnts 1 array def
/sidelength 4 def
/nummoves 1000 def
/ptrad 1 def
/triangle [ [0 0] [sidelength 0] [ 60 cos sidelength mul 60 sin sidelength mul] ] def
dogpnts 0 [sidelength 60 cos mul sidelength 60 sin mul 3 div] put
/lastmoveindex 0 def
/curtrainer 0 def
/unit 36 def
/setup {
	20 srand
	unit unit scale
	8.5 sidelength sub 2 div  11 sidelength sin 60 mul sub 2 div translate
	1 unit div setlinewidth
} def
/drawtriangle {
	/x1 triangle 0 get 0 get def
	/y1 triangle 0 get 1 get def
	/x2 triangle 1 get 0 get def
	/y2 triangle 1 get 1 get def
	/x3 triangle 2 get 0 get def
	/y3 triangle 2 get 1 get def
	newpath
	x1 y1 moveto
	x2 y2 lineto
	x3 y3 lineto
	closepath
	stroke
} def
/drawdot {
	dup
	0 get /x exch def
	1 get /y exch def
	gsave
	%1 0 0 setrgbcolor
	newpath
	x y ptrad unit div 0 360 arc
	closepath
	fill
	grestore
} def
/getnewtrainer {
	rand 3 mod
} def
/drawdogmove {
	/lastmoveindex dogpnts length 1 sub def
	/lastpnt dogpnts lastmoveindex get def
	{
		/nexttrainer getnewtrainer def
		nexttrainer curtrainer ne
		{
                  /curtrainer nexttrainer def
                  exit
		} if
	} loop
	/newtrainerloc triangle nexttrainer get def
	% calculate halfway to next trainer
	/newx lastpnt 0 get newtrainerloc 0 get add 2 div def
        /newy lastpnt 1 get newtrainerloc 1 get add 2 div def
	/nextpoint [newx newy] def
	/dogpnts [dogpnts aload pop nextpoint] def
	%newpath
	%lastpnt 0 get lastpnt 1 get moveto
	%newx newy lineto
	%closepath
	stroke
	nextpoint drawdot
} def
setup
drawtriangle
dogpnts 0 get drawdot
nummoves { drawdogmove } repeat

More lattice stuff

Friday, February 18th, 2005

I’ve continued reading about lattice theory. It’s exactly what I need to stimulate an interest in my algebra class.

One interesting fact I came across was that a lattice is distributive iff it doesn’t contain a diamond or pentagon as a sublattice. That’s interesting not only because it is a totally unexpected condition for sufficiency, but also in graph theory, there’s a similar condition on the planarity of graphs. I wonder if there’s any significant connection between lattices and graph theory, via directed graphs maybe?

Another interesting fact: \lcm( a, \gcd(b, c)) = \gcd(\lcm(a, b),\lcm(a,c)) since (\N, \gcd, \lcm) is a distributive lattice (unfortunately, this equality has to be proven to show that it is in fact a distributive lattice), and since this is true, so is the formula \gcd( a, \lcm(b, c)) = \lcm(\gcd(a, b),\gcd(a,c)) (this one is automatic, since the first one shows that it is a distributive lattice).