Can’t sleep: My mind is wandering about in my skull, a kitty among the bins. I can’t make up my mind how to represent an atomic algebraic expression term.

Clearly, an expression term, and an elementary binary operator are two different kinds of objects. What do I make, then, of an expression term such as sin(x)? It’s a function operator taking a single argument. I’d like to be able to manipulate a pair of rational expressions like


How about 2x? It’s an elementary product expression consisting of a constant and a variable. I’m beginning to think each subexpression ought to be represented as an object, now – so that I could replace the factor 2 with an expression, for example. This pretty much puts paid to representing an algebraic polynomial term as a struct:

struct Monomial {
    integer coeff;
    Variable x;
    Exponent t;

Each member coeff, x,  and t would then be an Expr:

struct Monomial {
    Expr coeff;
    Expr x;
    Expr t;

Then I should represent elementary operations as functors as well, perhaps. Hmm. This eliminates the need for a Monomial type:

Expr x('x'), X;
X = 2 * x ^ 3;
cout << X.strict().toString() << endl; // 2*(x^3)
cout << X.toHumanString() << endl; // 2x3
cout << X.toMathML() << endl; // Something like 2x(super)3

I need to look into operator associativity rules and find out whether any combination of member and nonmember functions will cause type coercion of the RHS into an Expr type.


My goal is to be able to create simple code to generate elementary algebra expressions programmatically, like so:

Expr a('a', '1/(x+2)');
Expr b('b', '2/(x+7)');
Expr c;
c = a * b;
cout << c.toMathML() << endl;
cout << c.execute().toMathML() << endl; // 1/(x^2 + 9x + 14)

Then a simple, short chunk of code could do and generate an online algebra workbook of arbitrary complexity:

string generate_rational_fraction_sum( int terms, int glbpower, int lubpower ) {
  Expr rfs;
  Expr numerator;
  Expr denominator;
  Expr monomial('x');
  for ( int i = 0 ; i < terms ; i++ ) {
    integer r = rand(glbpower, lubpower);
    integer q = rand(1,10);
    for ( int j = 0 ; j < r ; j++ ) {
      // Generate an order-j polynomial expression for the denominator
      integer k = rand(1,10);
      denominator += k * monomial ^ j;
    numerator = rand(1,10);
    rfs += numerator / denominator;
  return rfs.execute().toMathML();

Recovering Lost Sectors

Trigonometric identities – gone.  Techniques for polynomial factoring – gone. Ditto for logarithmic and exponential functions. Drat!

I guess recovering the calculus is basically going to take a wholesale rebootstrap of my entire maths education. Granted, a lot of it is going to be recovery rather than reintroduction. The skills have atrophied, and the surety of technique gone, but the memory of how to construct a proof, for example – the concept of inductive logic – isn’t completely lost to me.

This feels like having fallen off a mountain, nevertheless.

“Anybody have pitons?” I got pitons. The idea I have is to do both relearn algebra and trigonometry and write the software tools to help me do the math exercises. Instead of just the old pen and paper, I’d like to make use of a LaTeX engine and parser to enable me to solve these problems like I’d do on paper, but onscreen instead. I think of it basically as a way to generate problem sets and grade them on the fly to get feedback quicker (and to offset the tedium of interacting with the computer using an interface – a keyboard and maybe the mouse – that doesn’t allow easy math symbol input).

Much as I’d like to reprise Vance in its’ entirety, I’ll need to use a University course outline to guide the structure of my application. There were bits of Vance that led into complex analysis, real analysis, and linear algebra that I’d like to include as part of my course flow. I’m imagining an interactive Vance that does for algebra and trigonometry what Push Pop Press did for Al Gore’s book on the environment, and digital media should be able to be molded to the purpose: Javascript and HTML5 have evolved quite a bit since 1996, and might just enable a Web interactive application to do just  that.

Can’t wait to start on elementary physics, a la Angry Birds.

Setting up

I’ve ripped apart my copy of Wylie and Barrett’s Advanced Engineering Mathematics in nice signature-length sections, and have turned it’s first four chapters into nice iPad albums. Ditto for Harry Lass’s Vector and Tensor Analysis.

Over the next four weeks I’ll find either that I’d just wasted eight hours (and one perfectly good copy of W&B) of my previous weekend, or that I can still recover my old maths chops and get on with writing my own MRI scan image synthesis library.