My Best Teaching Is One-on-One

一対一が僕のベスト

Of course, I team teach and do special lessons, etc.

当然、先生方と共同レッスンも、特別レッスンの指導もします。

But my best work in the classroom is after the lesson is over --
going one-on-one,
helping individual students with their assignments.

しかし、僕の一番意味あると思っている仕事は、講義が終わってから、
一対一と
個人的にその課題の勉強を応援することです。

It's kind of like with computer programs, walking the client through hands-on.
The job isn't really done until the customer is using the program.

まあ、コンピュータプログラムにすると、得意先の方に出来上がった製品を体験させるようなことと思います。
役に立たない製品はまだ製品になっていないと同様です。

Friday, March 22, 2013

bc on MSWindows

Now that you have MinGW installed and running on your PC, it's time to install bc.

bc? basic calculator.

I've mentioned bc before. It's a great little basic calculator for *nix systems. Programmable. Quite literally all the precision you could ever want, if you want it.

If you remember using the old BASIC language interpreters as a substitute for a desktop calculator, and don't like having to open up a spreadsheet document just to check your math on something, bc may be what you're looking for.

bc is one of the packages available for cygwin distribution, so the following is not by any means the only way to get it onto your MSWindows PC. But you can use MinGW to install it, here is how.

bc is not an official package of MinGW, so this is a good way to practice compiling and installing free software by hand.

First, find the source code. As I type this, the wikipedia pages have a link to the source code (alpha, too) on the gnu servers. (The pages also have a link to the bc package from the separate GnuWin32 project on SourceForge, but then you wouldn't get the practice.) (Surprisingly, searching at google for "bc basic calculator source code" did not yield the gnu repositories on the first pages. It did bring us back to the wikipedia pages, so it got close.)

So, download the source code from the gnu servers. (Not the alpha version, I haven't yet figured out how to get that to compile and run on MinGW. Unless you're good at debugging these, in which case, please leave some suggestions in the comments.)

You get a tarball, which stock MSWindows does not know how to deal with. But that's okay, because MinGW should have the tar utility installed with it. (If you type "tar" at the msys shell command line and it says it doesn't understand, check the packages and install the appropriate package with "mingw-get install". But mingw-get isn't going to work without tar, so I guess that should never happen.)

Save or copy the tarball into your user's home directory:

c:/MinGW/msys/1.0/home/username

If you don't already have an msys shell running, go to the MinGW folder in the Start menu and get an msys shell running. (Not the uninstall icon, of course.) Enter the following commands at the prompt:

tar -zxvf bc-1.06.tar.gz
ls bc*

(tar didn't used to accept leading hyphen on the options, now it does.) The directory list should show that the tarball has been unpacked. Move into the bc-1.06 directory that tar just made and tell the configuration script to tell you what it can do:

cd bc-1.06
./configure --help
You probably want to add the readline option or the bsd version of it. (Don't need both.) If you plan, for some reason, on cloning your installation and distributing it to others, use the bsd version to keep yourself in conformance with the license. (I assume you are not going to cloning your installation tree, but I'll remind you just in case.) Here's how to configure it with the bsd version of line editing:

./configure --with-libedit

This will take a few minutes and tell you lots of things you may not really understand. Scan the output but don't worry about the stuff you don't understand unless it says "ERROR!" and stops. Warnings, you don't need to worry about just yet, either. Sort of.

When the prompt returns to you, unless there have been errors, you can make the executable:

make

Make handles the compiler commands for you. Are you let down? Don't be. Look back at the compiler output. ("make clean; make" again if you've lost the output.) You'll see some key warnings. The ones about memset and related functions are not that important, but you can edit lib/number.c (the file number.c in the directory lib) and add the line

#include <string.h>

at the end of the other include lines to get rid of that.

Make it again. (You may want to do a "make clean" just to be sure.) Test the results by typing the command

bc/bc

Once you get the copyright message so you know you are in the bc shell, type

scale = 100
17/11

You should see 1.5454 ... stretching out for 100 places. Now type

exit

to get back the the msys shell and type

bc/bc -l

to start bc with the math library. This is where things get good. Except you have to fix something first. In bc, type

4 * a(1)

That's 4 times the arctangent of 1. It should type the value of pi out to twenty places. (The last digit will be incorrect.)

3.14159265358979323844

But it probably won't.

Until somebody at gnu.org decides to update the package, it will probably complain about segmentation faults and the like. I looked on the web for "bc segmentation fault string.h save_adr" or something like that and found an archived mailing list thread and a patch from the linux-from-scratch project.

If you wanted to practice applying patches you could have applied it before you added the line to #include string.h. If you really want to practice, rename this directory, unpack the tarball again, and apply the patch there.

But it's easy enough to do by hand. Open bc/load.c (the file "load.c" in the directory "bc") in your text editor, and look around line 159. You'll find the line

program_counter save_adr;

On that line, save_adr needs to be declared static. Change it to

static program_counter save_adr;

and save it. Run make again, and repeat the tests. Just for fun, try this:

scale = 1000
4 * a(1)

That should give you pi to a thousand places (the last digit being incorrect again).

Way cool, huh? Now you need to make bc more generally accessible, so you don't have to type the whole path all the time.

make install

and bc is now available as just "bc". (dc is also fun to play with.) After you install it, the manual pages should be available, so you can type

man bc

to get more information about the cool things you can do with it. You can also look in the Examples directory for ideas.

I'll be using bc in some of my posts to the math-and-English blog, too.

No comments: