## How to spend an idle afternoon

Yesterday, I told another fellow computer geek an ’80s DOS joke about being prompted to “Enter any 11-digit prime number and press ENTER to continue.” She then suggested that a number with 11 1’s might be prime.  Having encountered this before in programs I’ve written, I warned her that you can’t assume all sequences of 1’s are prime, having previously tried this on numbers like 11; 111  1,111; 11,111; 111,111 and so on. 1 itself is neither prime nor composite, so it doesn’t count.

But of course, was 11,111,111,111 prime? There was no direct way of knowing that, and even an attempt to write a C program ran me into trouble, since said number is one digit beyond double precision, and I can’t get the “%” operator to work with floating point anyway. Long int will cause an overflow; casting long double as any kind of int will result in undefined behaviour. And admittedly, I didn’t want to spend hours at this. The only thing that came out of this is that I needed to brush up on my C coding.

The prime detectors I saw on the web also choked on 11 digit numbers. There were exceptions, however. The prime number calculator at math.com could do it. 21,649 was a factor of 11,111,111,111.

(Late edit) I tried using Maple to find primes consisting of ones, and the lowest number I can find besides 11 was the number: 1,111,111,111,111,111,111, or 1 quintillion and change (maybe 1 million billion if you are old-school).

Views: 168

## What is old is new: RPN on the HP 35s Scientific Calculator part 3

For those of you lucky enough to purchase the calculator back in 2007, you more than likely had the full 200-page print edition of the user manual. HP discontinued the print edition, possibly later that same year. It has been replaced by a smaller 40-page mini manual whose only real useful purpose has been to help me review the main points of RPN. If you are a beginner, then you need to access the full manual which is now stored on CD. My CD, which I bought less than a week ago, appears to have been last updated in 2009. The same CD also has the same manual in 15 other languages.

You would have had the ability to review the book at your leisure, rather than on a laptop screen the way I have to view it. It is a bit of a deterrent and is tiring on my eyes, but I guess it beats having no book. I have discovered that you can purchase copies on E-Bay if you feel desparate enough for a print copy. You will probably shuck out your dollars for a print copy if you want to program, or if you want to have a more through mastery of its system of menus.

However, if you program, it must be stated quickly that much of the programming language is printed on the keyboard above the keys, and are active in program mode. It is definitely a caclulator that had its keyboard laid out with the programmer in mind, and with their needs as the higher priority. A look at the keypad shows a lot of programming commands rather than statistics, summations, or clearing the stack, all of which require menus. The “STO” function requires the blue shift key to be pressed first; and the functions for x2, log, ln all require a shift key to be pressed first. For whatever reason that perplexes me, there seemed to be a need to cram a good fraction of the interface of the calculator with various conversions: metric to imperial, fraction to floating point, degrees to radians, signed to absolute value. It takes up 10 of the 43 keys. Since none but grade-school calculators have these conversions, I am not sure of the motive. It is likely that it helps in the programming to save coding effort.

It seems to be all about the programming. Programming takes up 5 chapters or 100 pages of the 382-page booklet. Plenty to learn for the HP 35s programming enthusiast.

Views: 79

## Getting f(x) notation to work in Maple

Maple is a robust math environment which can graph, solve equations, and solve for the unknown with the aid of its computer algebra solver (CAS), which is capable of computing exact roots of cubic functions, for example.

I wanted to demonstrate for myself that Maple could do various function transformations, such as: `f(x), f(x + 1), f(x) + 1, 2*f(x)`, and the like. I discovered after much reading and browsing the web that I could coax f(x) to do whatever is needed using an inline call:

```f := proc (x :: float) option inline; x4 + 5x3 + 5x2 - 5*x - 6 end proc: ```

The function takes a floating point number `x` as a parameter. This means that `f(-10.0)` would yield

`5544.0000`

as output. I noticed that Maple practices fairly strong typing, so if you declare floating point using `float`, you can only pass floats to the function. That is, `f(-10)` would have gotten an error, at least in my copy of Maple 12. Once you execute this proc declaration, you can do a plot function like:

`plot ({f(x), f(x + 1), f(x + 2)}, x = -5..5, numpoints=1000);`

and superimpose three curves on the same set of axes to make a comparison. You can even do:

`plot ({f(x), 0.5 * f(2*(x + 1)) - 5}, x = -10..10``, numpoints=1000``);`

to illustrate combinations of transformations of a function. Even a transformation of a sine wave can look like this:

``` h := proc (x::float) option inline; sin(x) end proc; plot(1.5h(2(x+Pi/4)), x = -2Pi .. 2Pi, numpoints = 5000, tickmarks = [spacing((1/4)*Pi), default]);```

and you are rewarded with:

There is an even better function called animate which is great for transformations of functions. I will discuss that in a later post.

Views: 97