Showing posts with label mathematics. Show all posts
Showing posts with label mathematics. Show all posts

Thursday, September 12, 2019

proth research - directories and more directories

After several years of working with Proth numbers, looking for interesting properties, a filesystem will get pretty packed!








How do I organise directories in a mass of say 500 or 1000 directories? Starting off with fixed so prothleadNNNNNN (Example: prothlead8388607)

If/when I find something interesting, and think its worth generalising, then I just replace the NNNNNN number with a short sequence of characters.
They have no meaning generally, just a way of making things stand out in a mass of directories.

What you can see from the final image 'prSAL' is how I labelled the prothlead8388607 directories after I generalised away from just the t=23 case. It helped to quickly think up something short - just a way of less typing at the time.

I could still be writing prothlead8388607 today but it just felt like too much and so i found a shorter thing that just occurred to me at the time. ( pretty arbitrary )

I could keep posting screenshots until I had 10 images on screen here to show the problem in hunting around in Proth numbers over a period of 7 years and keeping things organised in directories!


Saturday, September 2, 2017

High performance [mathematical] computing

When talking about supercomputers, there is a temptation to define things in terms of either of the following:
  1. massive simulations 
  2. they mean maths
Here is a phrase used in a recent discussion about high performance computing (hpc) that points to the first definition for my mind ...
The term number-crunching refers to large-scale numerical simulations
Now simulations of spacecraft flight or the effects of adding a dam to a major river really are typical uses of hpc

However, thinking about (2 ... they mean maths), you have many uses of hpc where the Mathematics itself is the outcome.

For people who are learners of hpc, I can see why the 'massive simulations' message is preferred as a way of presenting the utility of hpc

However as a Mathematician I naturally think also of many scenarios where the Mathematics is the outcome.

Not all of those outcomes will be moved onto a powerful workstation in the next decade.

There is also another major use of hpc which is not really [in my opinion] a good fit for the word simulation. Natural language processing at very high speed is one of the prerequisites of AI.

In such a context you are not simulating the process of adding meaning to raw words, you are actually doing it when you task a hpc with such processing.

Saturday, October 1, 2011

logarithm of large number - it is not about computation!

Computer programmers who have not studied Mathematics beyond elementary level, often trip over this one.

Perhaps you asked yourself one of these questions:
Why does Gnu Gmp library not have a logarithm function?

What is the natural log of a large number such as 6775471000000000?


Rules of logs - product and powers:

For calculating logarithms of gigantic numbers - the standard ANSI C library is probably all that you need.

That computational tool, needs to be supplemented, with two pieces of Mathematical knowledge as illustrated here:




Images courtesy of Wikipedia (Creative Commons Licensed)

The number I mentioned above 6775471000000000 is too large for entry into a school standard calculator. Ten digits or so is the most you can enter.

Rewrite the number as 6775471 times 'a thousand million' and go that way.

Using the product of logs rule (graphic above) and doing the two calculations we see that:

log(6775471) = 15.728819  to 6 decimal places

...and...

log(1,000,000,000) = 20.723266 to 6 decimal places

Add the two answers together gives 36.452085 to 6 decimal places

Alternatively for the second piece of the addition you could have used 9log(10) by utilising the second rule - power of logs.


But my number is huge and does not contain a long stream of zeros?

This is all about precision. Do you really need more than say 6 or 8 decimal places?

Avoid creating artificial conditions. Unless you are working with numerical methods and/or in Engineering, then you will probably answer NO to what I just asked.

So your number is 6775471 followed by another 75 digits (some zero some not)

If you only need 6 digits of precision in your answer, then it matters not what those 75 digits contain, simply pretend they are zero, and either adapt my method shown or...

...use the 2nd log rule from the image above.
( hint: You might want to use 75log(10) as part of your workings. )

Answer Guess: Around 187.nnnnnn sounds about right.


Prime number searching should not be limited to just Mathematicians

Agreed.

However looking up some rules of logarithms by reading this page or looking on Wikipedia is not hard.

So quit moaning that 'such and such a library' does not have a function for logarithms of huge integers, and take five minutes to do a little addition and subtraction.

Often Ansi C coders first go searching for log() of huge integer functions, when they are writing prime number search programs, which is why I mention it.


Notes and Further Reading:

Laws of Logarithms is part of the "Core 2 (C2)" Curriculum for post compulsory education in the UK (A level) .

If you studied Engineering at University, then you will have encountered Laws of Logarithms twice - once as part of 'A Level' Mathematics, and once as part of your Engineering course.

All the Logarithms in this article are 'Natural Log'. Your calculator might show that as 'ln' depending on the brand.

The Laws of Logarithms apply similarly to base 10 logs - but you would obtain different decimal answers, than those tabulated above.

The Index page for that C2 book shows pages 43 and 44 cover 'multiplication law' & 'power law' for Logarithms.

Friday, September 23, 2011

log theory reminder - pari / gp useful

When working with a scientific calculator that has log to base e and log to base 10 only, employ 'Change of Base' theory.

Change of Base - Wikipedia


Source: http://www.wikipedia.org/wiki/Logarithm#Change_of_base


Change of Base - questions rewritten:

If you know even a little about logs then you should be able to answer the following question:

What is log to base 10 of 1000?
The blindingly obvious answer is three.

Here are two additional ways of phrasing things to get an answer:
  • To what power do we raise 10 so as to obtain 1000
  • How many zeros in 1000

Assuming your calculator only does natural log (log to base e) use Change of base:

log to base 10 of 1000 is (log to base e (1000))/(log to base e (10)) = 3


Pari / GP - an example using x=1+1365*2^15

Pari / GP is a number theory program. It is designed for working Mathematicians / Number theorists, and is most useful to folks comfortable with Mathematical theory.

It is not designed, primarily, as a 'user friendly calculator replacement' for lay folks.

Now using x as given above - what is log to base 2 of x?

     Answer:






If you want that Answer as a continued fraction then Wolfram Alpha can do that.

Wednesday, September 21, 2011

Introduce a little Geometry into your life - morning

What is not to like about Geometry ... it surrounds us, so why not embrace it?

Patios & Pools to Steps & Walkways and beyond.

Have fun and introduce a bit of Geometry into your day!

Wednesday, April 20, 2011

making primes - fun with niece and nephew

You cannot make a prime by multiplying other numbers together

Whichever naive definition* you choose to give, some examples always help.

Once the students have an idea of what is and is not a prime, a fun exercise can be to pick a significant year (Man on the moon), and work some addition and subtraction.

Using just the individual digits of 1969, challenge the student to see, how many primes they can construct, using addition and subtraction.

This exercise is a reinforcing mechanism in that instead of focusing on multiplication, you are working a secondary construction method.

  • 2 = 9 - 6 - 1
  • 3 = 9 - 6
  • 5 = 6 - 1
  • 7 = 6 + 1
  • 11 = 9 + 9 - 1 - 6
  • 13 = 9 + 9 + 1 - 6
  • 17 = 9 + 9 - 1
  • 19 = 9 + 9 + 1

Doing this with a group of students, it is more likely that at least one will spot that a +1 in the construction, can be switched to -1 in the construction, and often obtain a new prime.

Obviously this is not a general rule, however it does introduce the student to the fact that sometimes when you have a prime, another can be found, just two away.

Now use another significant year, say 1989 (Fall of the Berlin Wall), and repeat the exercise.
( Not so easy with the 1989 example )

And use the year of birth for some of the students, see how many constructions can be made.

A useful follow up discussion can be to examine why 1969 is a better specimen than 1989, for this particular exercise.

How about 1979? Better? Worse?

*Note: I used the phrase naive definition at the beginning. With younger learners it is sometimes a useful exercise, to refine a definition, rather than give a rigorous definition at the outset.
If the student asks but what about 1, I can make 7 from 1*7, then you have an interaction, and have stimulated some thought.

Sunday, February 20, 2011

pari GP terminal colours - readable darkbg

After 3 years or more of using Pari/GP, the default highlighting (in terminal), bothered me enough, to read up how to change it.

default(colors,darkbg)

Here is a comparison of the effects of the highlighting change:


The lines prefixed %7 and %8 and in between, show the output is now in grey, and input highlighting is now greenish.

The original "1, 6, 3, 4, 5, 2, 3" profile known as lightbg is reactivated briefly, so it can be compared again.

Making the change permanent on Debian by:

emacs /etc/gprc

and changing which lines are commented out, results in the top of my /etc/gprc file looking like this:



So now when I start up Pari/GP my highlighting is set okay from the outset:




Notes and further reading:
On Ubuntu you will want to use the keyword sudo at the front of the command for editing /etc/gprc

If you want a lighter alternative to emacs on your system, then zile is a lightweight alternative that supports basic editing. Alternatively your system default editor is probably already chosen and use that.

The pari/GP command ...

default(colors,d)

... can be used interactively if you do not wish to make the change permanent.
darkbg abbreviated to just 'd' should work.