## Transcendental function programming

Written by Charles Douglas Wehner

Programming and chess have much in common.

Those who delve deep into mysteries of chess will have discovered that a single move can alter entire game. The ramifications go deep. Each subsequent move (or "ply" in jargon) is conditional upon what went before, and great chess-masters of this world pride themselves in being able to evaluate several ply of consequences.

The elegance of a game of chess is estimated from efficiency by which player heads towards his goal. No move must be wasted. There must be no hesitation. There must be no turning back to correct an error. In final stages - deeper ply - one sees reasoning behind earlier, seemingly trivial moves.

Then game is over. There is a glow of satisfaction, but nothing more. Perhaps, however, there are books written for guidance of others - that they also may know feeling of achievement. Yet in final analysis it is a GAME. Passions may be aroused, devotees may consider it to be a religion, a philosophy, highest accomplishment of human intellect - and still it is a game.

Machine code programming has all these facets - and delivers a PRODUCT as its goal. It is a game and an industry combined.

The programming of transcendental functions involves use of mathematics. There are various polynomials for creation of sine, cosine, tangent, logarithm and antilogarithm. Slavish obedience to set rules may well deliver a working product - but is it BEST?

Can you become a chess master by memorising a book?

Let us consider McLaurin-Taylor polynomial for natural antilogarithm. Do you take 1, then add argument X? Do you now multiply X by X and divide by 2 before adding it on? Do you multiply X by X by X, divide by 2, divide by 3, and also add on? Is this best?

Horner's rule says you can PRE-divide a large number such as 1 00000000 00000000 00000000 00000000 in binary (FFFFFFFF in Hex, 4294967296 in decimal) by 2, by 3 and so on, and build it into your code. Then machine does not have to waste time creating constants. The rule also says that you start at end of polynomial and work backwards. So if you multiply last coefficient by X, and add on penultimate before multiplying again, last will have X-squared in it whilst penultimate will have X. So it costs only one addition and one multiplication per term.

## PHP in the Command Line

Written by Robert Plank

There's a single line you can add to your web host's control panel that will automatically archive your content.

LISTEN CLOSELY AND YOU'LL HEAR THE OCEAN

Ever run commands in DOS? You've used a shell. A "shell" in computer world is a place where you enter commands and run files by name rather than clicking around different windows.

Most web hosts let you operate a shell remotely. This means that you can type commands in window on your computer, that are actually run on your web host, thousands of miles away.

I'd like you to log in to your shell now. If you can't do it by going in to DOS and typing "telnet your.domain.here", your web host probably uses "SSH" -- a secure shell. You'll have to ask your host how you can log in to shell, they might tell you to download a program called "PuTTY" and give instructions how to use it.

If you can't login to your shell, or aren't allowed, you'll just have to sit back and watch what I do.

Now that you're logged in, type: echo hi

On next line will be printed hi

Try this: date +%Y

This prints current year. That's 2004 for me.

So what if we combined two? Try: echo date +%Y

Well, that doesn't work, because computer thinks you're trying to echo TEXT "date +%Y" instead of actual COMMAND. What we have to do here is surround that text in what are called "back quotes". Unix will evaluate everything enclosed in back quotes (by evaluate, I mean it'll treat that text as if it were entered as a command.)

Your back quotes key should be located on upper-left corner of your keyboard, under Esc button.

PIPE DOWN, OVER THERE...

Type this in: echo `date +%Y`

Gives us "2004". You could even do something like this: echo `dir`

Which puts directory listing all on one line.

But now, we put our newfound knowledge to good use. Unix has another neat feature called piping, which means "take everything you would normally output to screen here, and shove it whatever file I tell you to." So say I had something like this:

echo "hey" > test.txt

Now type "dir" and you'll see a new file, test.txt, that wasn't there before. View it off web, or FTP it to your computer, do whatever you have to, to read file. It should contain word "hey".

Likewise, dir > test.txt would store directory listing into "test.txt".

HERE TODAY, GONE TOMORROW

But say we wanted that text file to be named according to current date. You already have pieces to figure all that out, if you think about it. Type: date --help to get a listing of all possible ways to represent date. The ones you want to represent year, month and day are %Y, %m, and %d (capitalization *is* important here).

This is what you want: echo `date +%Y%m%d.html`

Running this today, January 8th, 2004, results in: 20040108.html

I've just echoed this year, followed by this month and this day, with an ".html" at end. This will be our output file.

Now, to pipe it: echo "hey" > `date +%Y%m%d.html`

If this sort of thing were to run every day, it would save "hey" to a file called 20040108.html today, and tomorrow to a file called 20040109.html, then 20040110.html, and so on.

The easy part now, is figuring out what you want archived. I use wget, which takes an option to store output file, so we don't need to use piping. Here's an example of how to use wget to save page "http://www.google.com" to a file representing today's date: