Intel's Ronler Acres Plant

Silicon Forest
If the type is too small, Ctrl+ is your friend

Showing posts sorted by date for query fractions. Sort by relevance Show all posts
Showing posts sorted by date for query fractions. Sort by relevance Show all posts

Friday, June 12, 2026

Interstellar Travel


How Long Might a Generation Starship Last in Interstellar Space?
Silent Abyss

I'm only posting this video as a curiosity. It showed up on YouTube the day after I mentioned Nemesis by Isaac Asimov in a post. I only listened to few minutes. Who's got three hours to spend listening to someone drone on endlessly about generation ships? I dunno, maybe I could listen to him if I was busy doing something else, but usually, if I am working on something I will listen to music, which requires no thinking, as opposed to listen to someone talking. I do listen to audio books when I go for a walk. So far I've just been listening to free audio books on YouTube Music. Some are wretched, but some are okay. You have to be careful because if you search for Audio Books (or is it Books on Tape?), half of the items it returns will be music by a band with that name.

Nemesis did get me restarted thinking about interstellar travel. Right now the only way we know how to go anywhere in space is to throw things in the opposite direction. That can get us to the Moon, and can get robots to Mars, but rockets are not going to get us to the stars. Tsiolkovsky's rocket equation puts a limit on how fast you can go, but it is based on your rocket's exhaust velocity. If you can get that velocity up some large fraction of the speed of light, you could reach the stars, but getting that high velocity would be a bit of a trick. We can do it with particle accelerators, but they are only working with particles. We would need to do it with a continuous stream of matter.

Of course, none of this matters if we don't have a destination. Astronomers have detected numerous exoplanets, that is planets orbiting another star, but we have scant information about the planets themselves. One of these days astronomers are going to find one that looks like it might be worth going to visit. Probably want to send a probe before we send a manned mission. Also give us a chance to test our particle beam rocket engine.

Even with a super particle beam rocket engine, it will probably take years to get to the star. And it will  be even longer before we hear anything back from our probe. And will we even be able to hear it? Our current deep space network has limited bandwidth, and we are only dealing with small fractions of interstellar distances. Lasers might work, but I suspect it would have to be one heck of laser. Sending actual physical mail might work better, but you would need the probe to return home to deliver the package.

Problem: if you use half of your mass as reaction mass to get you to your cruising velocity, then you will need half of your remaining mass to slow down to visit your destination. Now you've collected your data and you want to return it to Earth, you will need half of your remaining mass to accelerate to cruising speed, and then half of you remaining mass to decelerate.

100   tons x 50% = 50   tons
 50   tons x 50% = 25   tons
 25   tons x 50% = 12.5 tons
 12.5 tons x 50% = 6.25 tons

Start with 100 tons and you will only have 6 tons for your spacecraft. But using only 50% of your mass is probably highly optimistic. You are more likely to need 90%, which means you will only have 10% of your starting mass that you began that stage with. So your fuel consumption will look like this:

100   tons x 10% = 10    tons
 10   tons x 10% =  1    tons
  1   tons x 10% =  0.1  tons
  0.1 tons x 10% =  0.01 tons

Start with a 100 ton rocket and you return package will only weigh 20 pounds. Somehow I don't think you are going to be able to make a nuclear powered particle accelerator rocket engine and pack it in a 20 pound package with all the necessary sensors and recording equipment. So a ton in this case is liable to mean a zillion pounds.

On the other hand, some whiz kid might conjure up a warp drive, an astronomer will discover a whole raft of possibly habitable planets, and all this speculation can be ignored.

Monday, April 28, 2025

Count Like An Egyptian


The Bizarre Fractions of Ancient Egypt
Wrath of Math
From Wikipedia:
The Rhind Mathematical Papyrus (RMP; also designated as papyrus British Museum 10057, pBM 10058, and Brooklyn Museum 37.1784Ea-b) is one of the best known examples of ancient Egyptian mathematics.

It is one of two well-known mathematical papyri, along with the Moscow Mathematical Papyrus. The Rhind Papyrus is the larger, but younger, of the two.

In the papyrus' opening paragraphs Ahmes presents the papyrus as giving "Accurate reckoning for inquiring into things, and the knowledge of all things, mysteries ... all secrets". He continues:
This book was copied in regnal year 33, month 4 of Akhet, under the majesty of the King of Upper and Lower Egypt, Awserre, given life, from an ancient copy made in the time of the King of Upper and Lower Egypt Nimaatre. The scribe Ahmose writes this copy.
Several books and articles about the Rhind Mathematical Papyrus have been published, and a handful of these stand out. The Rhind Papyrus was published in 1923 by the English Egyptologist T. Eric Peet and contains a discussion of the text that followed Francis Llewellyn Griffith's Book I, II and III outline. Chace published a compendium in 1927–29 which included photographs of the text. A more recent overview of the Rhind Papyrus was published in 1987 by Robins and Shute.

Farther down the Wikipedia page is this image:

Ancient Egyption Units of Measurement in the Rhind Mathematical Papyrus

The image on Wikipedia contains some text, but the lines are very long which makes it difficult to read. Printing the image large enough to make the text legible requires two sheets of paper. I used Windows Paint. I had completely forgotten about this program, but it is around, at least on my Windows computer.

Anyway, I thought the text in this image ought to be converted to text, so I used OCR Online to extract the text and then edited it to correct the errors. The only words OCR had trouble with were the  highlighted words in color. Other than that it was perfect. Then I went ahead and chopped it up to make it more readable, at least in my mind. Here it is:
The present table is a concordance of ancient Egyptian units of measurement which are used throughout the Rhind Mathematical Papyrus, an ancient Egyptian document which is a record of elementary mathematics. The papyrus consists of four sections:
  1. a title page with historical information,
  2. a table of fractional calculations for 2/3 - 2/101, or the "2/n table" (where n is always odd),
  3. a much smaller table of fractional calculations for the nine fractions 1/10 - 9/10, or the "1-9/10" table, and finally
  4. a series of 91 "problems" or numbers, which are numbered from 1-87 (a modern convention imposed on the document to differentiate the problems) and include four additional items designated by moderns as 7B, 59B, 61B, and 82B.
Many of the latter problems make use of certain ancient Egyptian units of measurement, whether of length, volume, time, or otherwise, and this is what the present table summarizes. It happens that none of the 2/n table, the 1-9/10 table, or even most of the first several problems 7, 7B, 8-34 make any mention of units, and they are therefore not included in this table.
Almost all usage of units of measure is confined to the later problems in the papyrus (with some early exceptions, also listed), being the title page, problems 1-6, and problems 35-87, which include three additional items designated as 59B, 61B, and 82B.
For the title page and numbers 86-87, the context of the usage of units is not mathematical, but historical.

The units are grouped by unit type, and color-coded. From top to bottom, the unit types are:
  • length,
  • area,
  • volume (deben),
  • monetary (sha'ty),
  • trigonometric (seked),
  • food/manufacturing (pefsu), and finally
  • "foodstuff" (loaves, des-measure).
The seked is not strictly speaking a trigonometric item, but its context is so close to our modern understanding of trigonometry that we identify it with that word.
The pefsu is also a kind of derived unit of measure relating to food preparation and manufacturing.
Finally, the "loaf' is not really a standard unit of measure within the papyrus as such, but it is mentioned so frequently in related contexts that it merits its own entry. In any one problem, it can be interpreted as a measure of solid food.
Likewise, the "des-measure", mentioned in only a few problems, can be interpreted as a volume unit of liquid measure (especially in the context of food and drink) which is not immediately related to the other volume units.

Entries in black indicate that a given unit of measure is explicitly named or entailed in the problem, in the original document.
Entries in gray indicate that although the unit's word is not expressly stated in that problem, the context of the document makes clear that the unit is implicitly being used in the course of the problem's calculation, statement, etc.
Note that neighboring groups of problems often tend to entail similar units, although in some cases the units are merely strongly implied by context, as opposed to being explicitly stated in the original document.

In the Rhind Papyrus, units of a given type have precise, exact, simple relationships to one another, which conversion factors we can and therefore do easily express in modern terms, using only integers.
Although there is historical evidence that certain units of measure can be "concretely" compared with modern units, these exact specifications are not essential to reading the Rhind Papyrus as a mathematical document.
Indeed, one can read the papyrus has having an internally consistent system of units of measure, which is all that is presented in this table and explanation.
The reader is cautioned that ancient Egypt had a very long history, and that the present information about units pertains directly to the Rhind Papyrus only.
At other periods of ancient Egyptian history, certain units were taken to have different conversion factors relative to other units.

Among units of length, 1 khet = 100 cubits = 700 palms = 2800 fingers.
Among units of area, one square khet is called one setat, and 1 setat = 100 cubit strips, where one cubit strip is a rectangular strip of area being 1 cubit by 100 cubits (or any other sector of equal area).

Among units of volume, the following holds:
2 cubic cubits = 3 khar = 60 heqats = 600 hinu = 19200 ro.

Furthermore as one might expect, the somewhat redundant "hundreds/multiples" versions of the heqat and the ro can be equated with those same "base units" in the following wise:
1 hundred quadruple heqat = 2 hundred double heqats = 4 hundred heqats = 100 quadruple heqats = 200 double heqats = 400 heqats = 128000 ro = 64000 double ro = 32000 quadruple ro.

Combining these two chains of equalities, rearranging their terms, and expressing all of the units' conversion factors in the simplest terms of integers yields the following comparison among all of the standardized units of volume measurement in the Rhind Papyrus:
3 hundred quadruple heqats = 6 hundred double heqats = 12 hundred heqats = 300 quadruple heqats = 600 double heqats = 1200 heqats = 40 cubic cubits = 60 khar = 12000 hinu = 384000 ro = 192000 double ro = 96000 quadruple ro.

Among time units, since the Egyptian month is always exactly 30 days, then 6 years = 73 months = 2190 days. The remaining units, being of different types and not having simple or relevant conversion factors into other units of like type (at least as far as the papyrus itself is concerned) are therefore not expanded upon here.

More posts about fractions.

Another post about ancient mathematics: the Babylonian Plimpton 322 clay tablet. It dates from 1800 BC, so roughly the same era the Rhind Papyrus.


Wednesday, February 12, 2025

New Experiences And A Cold Morning (Two Posts In One)

Stolen entire from Adaptive Curmudgeon.

New Experiences And A Cold Morning (Two Posts In One)

Have you enjoyed the bright new age? Despite 2024’s fake polls, assassination attempts, and endless complaints, a new situation rushed into existence right on schedule. It’s like it was created by the utter, complete, and total collapse of the Bidenverse? Maybe we needed to hit rock bottom? Reagan won huge because Carter sucked. Biden is similar. If they hadn’t mercilessly lawfared him, would Trump 2 have leveled up to the Ultimate Boss he’s become?

Watching rational governance return to America is like watching a horse released from a tiny paddock into a large field. Muscles are used. Strength happens. A head is held high as the horse does what it was born to do. Look at that thing run!

Older folks might have memories. I’ve only heard stories of a government that was proud and strong. For most generations, the only experience is plodding mediocrity. As with all forms of evil, it gradually descended into blithering madness and abject corruption before going down in flames.

And now Trump does one thing after another. His actions make me (and a lot of other folks) smile. It’s refreshing when a President acts like he has an actual job. We’d gotten used to figureheads who treated “the big chair” like a side gig; the posing of a marionette for cutting ribbons and giving speeches. Meanwhile, private grift and secret maneuvers were the real action.

It’s fulfilling to see things happen. Right there in front of your eyes, you’re seeing responsibility exercised, duties fulfilled; someone is even trying to balance the books! We’re seeing (possibly for the first time) actual, no-bullshit, all the warts exposed, transparency.

America (and perhaps most of Europe) has spent a very long time locked in a web of conflicting interests. The slightest change in anything anywhere generated an equal and opposite force from an eternal maladapted bureaucracy. That is ending.

I knew this day would come. Multi-generation attritional wars of ineptitude must end. They have to. When something can’t possibly continue, it won’t.

I did not guess it would happen this way. I vacillated between anticipating a Mad Max Armageddon or the mass death of Boomers leading to the financial depression they baked into the cake. In defense of Boomers, they did it not necessarily out of malignancy but of inertia. They just weren’t going to let the world adapt to… the world.

Yet to my surprise, real measurable change is happening more or less peacefully. (If you ignore a few assassination attempts and whatever we should call 2020.) Don’t fret over the uncertainties, rejoice that we no longer have concertina wire around the White House or political prisoners.

This is the second time I’ve seen it. The first was the fall of the Berlin wall.

I spent an entire (young) life concerned that oppressed people suffered behind that wall. If you’d asked anybody, anyone at all, they’d have said it was there forever. It was never going away. It was never going to get better. Nobody anywhere had the slightest bit of optimism. As Gen X, I spent my life being told there was no hope. The wall, a geopolitical scar left from the second great war and supported by inevitable infallible socialism, was there for eternity.

Until it wasn’t. On November 9, 1989 the house of cards collapsed. Could there be a greater revelation?

I’d been lied to. In 1988, everyone said communism was inevitable and sure to overcome America. By Christmas 1989, newly freed people were already starting to rebuild a better life.

Anyone who saw the Wall fall should know “experts” make mistakes. They were absolutely, massively, completely, utterly wrong. (Maybe the Berlin Wall was supposed to teach us to keep our head when “experts” wanted everyone to go apeshit over Covid? The President himself pronounced me doomed: “…we are looking at a winter of severe illness and death — if you’re unvaccinated — for themselves, their families, and the hospitals they’ll soon overwhelm…” Wrong call motherfucker! I’m as happy as a pig in shit and your decrepit ass was kicked out of your own campaign!)

Love him or hate him, Trump Version 2.0 is the fall of another Berlin Wall.

A man can say what he’ll do and then do it. Who knew?!? Did you know a president can do the things he said he’d do during the campaign? We know there’s no law against it, but doesn’t it seem like a rule of nature? Once a politician  has your vote he’ll “grow in office”, doing the bare minimum until he’s a fucking slug. That’s my observation. Until now.

Which brings me to the next pleasant revelation; I forgot there could be a Republican president that isn’t immediately fucked by the Republican party. It’s not required by law, but it most certainly is practice and tradition. Reagan could tell ya’ all about it. Trump #1 did about as much as he could possibly while his own party jammed a shiv in his back every chance they could. I assumed it inevitable that a President of R gets hosed by his own party. The party is so reliably bad I wonder why the party of R actually exists. This time it’s different. After a few bleating sheep-like motions they sniffed the wind and fled while the Orange Juggernaut steamrolled everything. Neat!

I could go on for hours but I don’t need to. You’re watching the same show. The best I can say is “enjoy this moment“.

Motion in direction can be beautiful. I’ve often sought out riverbanks for the same feeling I’m getting out of “events” today. I’ll find a nice rock or tree stump and watch the mighty inexorable flow of a river. Steady and strong, eternally in motion yet also calming and true. How many tons of water flow by? How far does it go? How majestic is it to see each little molecule of H20 become a forever flow to the ocean.

Rivers feel strong. The Army Corps of Engineers might hurl money at the Mississippi but it always gets to Gulf. Apparently it gets to the Gulf of America now. Ha ha ha! Rivers can be killed. Ask the Colorado River Compact about it. But it’s hard to screw up that bad.

Now is a time to pleasantly flow like a river. I was tired of percolating in a swamp.

I drove to town. I used to go there every day. That changed. Not the town, me. I go there only occasionally.

After COVID, seeing what people allowed themselves to become, I just stopped needing the presence of people so much anymore. I’m not angry (I’m not even disappointed), I’m just removed. I was never of the city, now I’ve structured a life where I don’t often go there… and I don’t miss it.

Folks think I must be suffering. What am I missing? Symphonies? Do you honestly go to the city for symphonies and glorious museums? Of course not. You go there to buy shit at Walmart. I need shit less and less.

I was never gregarious and now I’m even less so. I kind of like the new me. Nobody escaped Covid. It (or rather the social upheaval generated of it) either it made you more of what you already were or nudged you to be something different. I was always less interested in people and more in trees; Covid reminded me why.

I’m not a hermit. I need hardware stores and car parts just like everyone else. I need to do certain business transactions. I have weaknesses. (I keep an eye out in case the McRib comes back.)

So it is that I found myself in town. It was -20 Fahrenheit and snowing.

The “city” was hunkered down, riding out a climate that will literally kill you. The best part of brutal climates is that it reduces bullshit. When it’s that cold, nobody’s bitching about recycling or wants you to sign a petition. Nobody’s out on the streets being a pain in the ass. Electric cars evaporate. The only pedestrians are dressed like they’re running a trap line. They move from Point A to Point B with quick, forced efficiency. It gets so cold, only  serious, rational, adults can handle it.

-20 is hard core.

My diesel truck (fueled on the higher cost diesel #1) was running flawlessly. I churned through unplowed urban parking lots in useful non-ironic 4×4 mode. I did my errands. Then I left.

As I left I noticed what I never see at -20 Fahrenheit. Lunatics and bums and drugged out losers. They wander the streets in August, but are gone at -20. I’m not sure where they go. Like mosquitoes, they simply reappear when it’s warm. Unlike insects, their absence under certain circumstances tells me they’re an optional part of the environment.

I was thinking about USAID; a bureaucracy seemingly built entirely to launder tax dollars into kickbacks and unpleasant experiences. Old videos of old cities don’t show bums. At least not like we accept in a modern city.

I theorize nutjobs and addicts and flakes are ubiquitous because they were deinstitutionalized. One could argue with the wisdom of “dump them on the streets”. Maybe the institutions sucked. I dunno’. I read One Flew Over The Cookoos Nest just like you did. But is delusional wandering in traffic better?

I only know that a world of non-crazy people ended before I was born. It ended so completely I have trouble imagining it. Only during a blizzard do I see a remnant of the time when a regular citizen could walk city streets without dealing with derelicts. Grainy videos of Buicks maneuvering busy streets filled with working men wearing ties and hats are as distant as Mars.

Was that on purpose? How much of was caused by USAID? How much money does it take to generate derelicts to beg at the stoplight in August yet vanish in January? I harbor the suspicion they’re more created than inevitable. Just one of a thousand ways our tax dollars are spent to destabilize society and annoy us.

I’m starting to wonder what WON’T be around after USAID (and much more) is cut? Have you considered this?

What won’t happen without all that corrupt funding?

Will I be able to turn on my truck radio without NPR bitching at me about gun control? Will I be able to stop at a light without some willfully unemployed jackass begging for a buck? Will I make a service call without pressing 9 for English? Will I “Netflix and chill” without a black lesbian in the lead role? Will there be TV without a thousand ads for drugs? Will teachers instruct students in fractions instead of “oppression”? Will subsidized electric cars be less common? Will I drive on the highway without billboards barking about various government programs? Will the power grid stay on better? Will McDonalds fries once again taste yummy?

Imagine all the good things we might get from the absence of corrupt and expensive Federally funded bullshit!

Everything from plastic straws to non-propaganda media might return. Dare we hope for a quieter, saner life?

I can’t wait to find out.


Friday, March 19, 2021

All π

π

Looking over my program for computing the value of pi, I realized that the method I had labeled as 'classic' was actually a copy of the BBP method, so I set about correcting this mistake. Turns out the classic method (the infinite sum of alternating positive and negative fractions of ever decreasing magnitude) is poorly suited for implementation on a modern computer. Where all the other methods can calculate pi to the limit of the machine's precision in 25 steps or so, the classic method takes something like two trillion steps to get anywhere close. After a bit of futzing about, I find it gets pretty close after about two million steps. Up until then the difference between the computed value of pi and our reference value keeps getting smaller, but at that point it inexplicably gets larger. It starts getting smaller again, but nobody wants to wait for hours for a demo to run, so we call it quits.

Then I got to wondering just how do we know just what the digits of π are? A physical measurement is only going to get us a handful of digits. How do we know what the rest of the digits are? Well, you need to have a little faith. You come up idea of how it can be calculated, and then you implement that idea in a computer program, turn the machine on and let the program run. If it's a well behaved program it will run forever or until it runs into it's limitations (like my demo program) or it runs out of space to store the result. Asking for a zillion digits of π is like asking how far your car can drive. It's a machine and it will keep running until it breaks down. It's kind of pointless actually.

Still, it's a good exercise for the computationally inclined, kind of like target practice in archery.


Friday, June 8, 2018

Bugs

I've been working on my Farey addition program and I found a couple of bugs. The first one a simple mistake that took me four days to find, mostly because my mind was a bit fuzzy. The problem was that I was using abs (absolute value function for integers) instead of fabs, which is the same function, but for floating point numbers. One little letter and everything is wrong.

Got that corrected and now I'm running the program and when the denominator gets to 4142 it goes off the rails. What the heck could be causing that? It's been working fine for the first 4141 denominators, why should it choke on 4142? It blows up when it is checking the Farey addition. Doing this only involves integer operations, and they are all relatively small integers, we aren't going to overflow the accumulator. What could possibly be go wrong? This one had me stymied for a couple of days, I couldn't even think of what to look at. There is nothing wrong except it doesn't work.

This morning my brain served up a clue. When I generate the fractions, I compute their decimal value and use that to sort my list of fractions. The problem is that I also depend on this value being unique. If two fractions have the same decimal value, I presume they are duplicates and eliminate one. The problem might be (I haven't verified it yet) is that two fractions could have the same decimal value, but be different. For instance, Google delivers these values:
2048 / 4007 = 0.51110556526
2071 / 4052 = 0.51110562685
2117 / 4142 = 0.51110574601
The first 6 digits of these three fractions are all the same. After that they diverge. In my debug output, they all show the same value, but then I am only printing the first six digits. Standard floating point values hold much more than six digits, so maybe there is something else going on here. Anyway, I've got a place to start looking which is more than I had a couple of days ago.
 

Friday, June 1, 2018

Tangent Circles

Fun with Circles
I came across this bit of geometry on Quora the other day. I haven't quite sorted out just why it works, but if it does, it's pretty cool. I was so impressed with it that I printed a copy and took it lunch to show the gang.


Funny Fractions and Ford Circles - Numberphile

Dennis responds with this video, which also has a bunch of tangent circles along with some goofball math. I saw this and thought that it wouldn't be too much trouble to write a program to verify what's going on here, so I did. Turns out there were a couple of tricky bits that needed sorting, but I think I have it. The first tricky bit was figuring out how much memory I would need. I wrote about this a couple of days ago.

int gcf(int m, int n)    // greatest common factor
{
    if ((m==0) || (n==0))
    {
        if ((m==0) && (n==0)) return 1;
        if (m==0) return n;
        return m;
    }

    while(m!=n)
    {
        if(m > n)
            m -= n;
        else
            n -= m;
    }
    return m;
}

The next was figuring out how to find the greatest common factor (GCF) of two integers. I've run into this problem before, but where oh where has that bit of code gone? I dunno, but Google finds an example, but it doesn't work. I have to spend several minutes monkeying with it to get it to behave.

That was enough to verify that the Farey addition of fractions works. That is, you generate all of the fractions between zero and one using all denominators from 1 to whatever. Now take any three adjacent fractions on the number line. Add the numerators of the first and last and you will get the numerator of the middle one. Do the same for the denominator and you get the denominator of the middle fraction. You might have to reduce the fraction to make it identical, but the value will be the same regardless.

Verifying that you could use these fractions to generate tangent circles took a little more doing. One way to do it would be to check this out for every new denominator, since at that point the fractions on either side would be the ones you would be forming tangents with. I didn't want to do that, mostly because I was already generating all of the fractions prior to checking the Farey addition, so I need some way to keep track of a fractions "parents" even after multiple fractions had been interposed between them. What I finally settled on was, after generating all fractions for the next denominator, I recorded the values of the parent fractions. Then later I would use these values to locate the original fraction and verify that the generated circles would indeed be tangent.


Tangent Circles and Pythagoras

Verifying that the circles are actually tangent to each other is done by comparing the sum of their radii with the distance between their centers. If these two values are equal they are tangent. If the distance is larger, they are not touching. If the distance is smaller, they overlap.

The distance between centers can be calculated using the Pythagorean Theorem. All you need is the horizontal distance, which is simply the difference between the values of the two fractions, and the vertical difference, which is the difference in their radii. See the above illustration. The orange and purple lines form the sides of the right triangle and the black line forms the hypotenuse.

I fired up my program around 12 hours ago. I gave it some big number to work with, like a 100,000 or something. It has generated over 20 million fractions and it is still running. It seems to be marching on regardless of whether the desktop goes to sleep, or if I am using the computer. I am debating whether I should cancel it or let it keep running. If I remembered what the number was that I gave it, I could estimate how long it is going to run, but I just typed in a one and bunch of zeros. I suppose I should let it run just to make sure it doesn't crash before it finishes.

I've uploaded the source to github if you are interested. I intend to clean up the output so it gives a better picture of what it's doing. When I have done that I will update github.

Wednesday, May 30, 2018

Calculating

I'm working on a little program to play with some numbers and I need an array of the appropriate size. It's easy to do, you decide on some array size and then you ask the O.S. for a chunk of memory that big. If you are a well behaved program, and the O.S. likes the cut of your jib, he might let you have it.

You don't want to ask for anymore than you need because if you ask for a great deal, that might interfere with whatever else you are trying to do, like trying to watch YouTube videos. Also, large amounts of memory can involve lots of processor time, and you might not want to run the program for that long, so you run on it a smaller set of data.

In the C programming language there are a couple of ways to do this. The traditional way is call malloc, the O.S.'s memory allocation procedure with number of bytes you want. It will return a pointer which you will base your data structure on.

    fraction_s* a = malloc(q * sizeof(fraction_s));

Another way is to declare your array in the main procedure (which is where the program starts), and use another variable as the size of the array. You need to assign a value to the size variable before you try and make use of it in the declaration of the array. Get all that? Sounds kind of convoluted. Maybe it's just my explanation is convoluted. Let's see if a bit of code helps.

int main(int argc, char** argv)
{

    int q = 1000;    // default value
    if (argc>1)
        q = atoi(argv[1]);    // pick up value from command line

    fraction_s    a[q];       // declare an array of data blocks

    memset(a, 0, sizeof(a));  // zero out the array

Last thing is to fill the array with zeros. Saves having to do it explicitly whenever we are loading data, we can just skip all those locations for which we don't have data. That way, come run time, we can be sure we won't misinterpret them for data. We might want to set a flag in each block that does have valid data.

Took a while to get here, but we have finally got to the crux of the matter. I'm working on a program to check out Farey Addition of fractions. I need an array to hold of all the possible fractions that can be generated using any pair of integers, up to some limit. For instance if my limit was 1,000, I would need an array to hold a million numbers. If I confine my self to proper fractions (the numerator is smaller than the denominator), then I only need half as much. Roughly.

You don't want to get a size calculation like this wrong, because while it might be a nuisance when the program is only going to run for a few seconds, it would be the shitz if your program got a memory fault after it had been running for a week and it lost all your work, all because you got the memory request size calculation wrong.

You screw up once or twice and you start taking pains to get it right. Getting it right also insures that your program doesn't get kicked off for asking for too much memory, when a properly sized request would allow you to run. It also tells you how much memory you need for the kinds of problems you are working with.

There's probably a name for the series that tells you how many fractions you are going to generate. Fibonacci or Bernoulli, or maybe, I dunno, Flatulence? I think I'm getting burned out on the math section of Quora. Seems like half the questions over there are talking about some obscure thing named after an even more obscure, old, dead, white guy (usually). Numberphile does that some too, but usually it's just kind of a decoration, like ribbons and bows, on their presentation. On Quora, these names are in these questions and understanding what the term means is crucial to understanding the question. Sometimes it's really simple, like this fraction thing I am working around to explaining, which is great, it means I can understand the question. But sometimes it's such an esoteric term that only the half dozen people who are writing theses on it have any idea what it means. I'm not going into those ratholes, I have plenty of my own, thank you.

Back to our array. For a denominator of 1 you can have two values in the numerator: 0 or 1. We're only going to count the zero. One over one is one, which really isn't a fraction. We aren't going to count the one, so for one, we have one value. For a denominator of 2 you can have two real values: 0 or 1. Plus 1 for zero gives you three. Like so:

Denominator /
Number of Proper Fractions    Total
            1              1
            2              3
            3              6
            4             10
            5             15
            6             21
            7             28
            8             36
            9             45
           10             55

It kind of looks (n+1) * n/2. It looks an exact calculation to me. No issue with rounding due to division by 2 (of n and (n+1) ), one is going to be even and the other will be odd, so the product will always be even and divisible by two.

We could eliminate the zeros, and maybe I will, all zeros are alike, am I right? But right now it's handy becuase I've been using zero based arrays for so long it's like second nature. Taking out the zeros, oh boy, I dunno if that's ever been done before Mr. Halliday (figment of my imagination, my inner Jimmy Stewart talking to big fat boss man with the straw hat, bifocals and a cigar).

Saturday, December 9, 2017

Donut bag windfall story

Iaman sends me a story:

Bitcoin Donuts
Riding the crosstown, a stumblebum boards my bus, disheveled, wreaking of booze. The unfortunate is carrying a neat clean little bag of Little Debbie Mini Powdered Donuts, I may have noticed because they are a favorite of mine.  After a long twisting ride, the man gets up to disembark at the next stop. I notice he has left the Little Debbie bag on his seat. I hail him "Sir you left your donuts!"  He waves me off with a slurred profanity.  On his wrist I spy what appears to be a besmirched Cartier Rotonde de Cartier Astrotourbillon wristwatch, clearly out of place.
The bus jolts to a start, the abandoned Little Debbie bag falls to the floor, papers appear out of the top of the donut bag. Bored and curious I examine the paper......Bitcoin Private keys! On the pages there must be a hundred, this mornings news said Bitcoin was topping $15,000! So these coins represent $1,500,000!
Upon arriving home I google businesses that take bitcoin as payment,  the only one that interests me is OKCupid a web dating site,  the most they charge is $19.95.   What to do with the remaining $1,499,980.05? What to do?
It's a story, that is, fiction. Besides, private keys likely give you access to wallets (if you have the wallet id), but having access to wallets doesn't necessarily mean there is anything in there. Fractions of a bitcoin are very popular. Most people don't have 15 grand to wager on a risky gamble. 100 accounts with .005 bitcoins each would only be worth $7,500, not 1.5 million. But it's all imaginary anyway, dreaming about imaginary riches.

Rotonde de Cartier Astrotourbillon wristwatch $140,000
Just in case you were wondering.

Thursday, May 12, 2016

Salt and Blood Pressure

A model of Na-K-2Cl cotransport.
Salt and sodium are commonly blamed for high blood pressure. Do not confuse the two terms. Common table salt is sodium chloride, a simple chemical compound. Sodium is a highly reactive element and is not found free in nature. "Salt" is not synonymous with the term “sodium.”
Salt vs. Sodium
A list of conversions for salt and sodium appears below:
  • 1 mmol sodium = 23 mg sodium
  • 1 g sodium = 43.5 mmol sodium
  • 1 g salt (sodium chloride) = 390 mg sodium
  • 1 tsp salt = 6 g salt ≈ 2,400 mg sodium = 104 mmol sodium = 104 mEq sodium
To convert mmol to mg of sodium, chloride, or sodium chloride, multiply mmol by 23, 35.5, or 58.5 (the molecular weights of sodium, chloride, and sodium chloride), respectively. - CDC
mmol stands for millimol, or one one-thousandth of a mole. A mole of a chemical compound has as many grams as the atomic weight of the compound. Sodium has an atomic weight of 22.98976928, call it 23. Chlorine makes up the chloride part of sodium chloride and has an atomic weight of 35.45, call it 35. I don't have a scale that will measure fractions of a gram, and if we're talking about the amount of food you eat, it's not significant. Anyway, one mole of table salt is 58 grams, which is 2 ounces, which is why all the numbers in the list above use the milli- prefix.

The mEq unit label in the last line of the above chart stands for milliequivalence. An Equivalence is one mole of a substance times the valance of the ion in question. Sodium ions have a valance of one, so one mole of sodium is the same as one equivalence. Calcium ions have a valance of two, so one mole of calcium is two equivalences. Wikipedia has an article. The Ohio State University School of Veterinary Medicine also has a page on the topic.

Friday, January 22, 2016

Used Book Market

Got a book in the mail yesterday from Murfbooks. I ordered it on Amazon about a week ago. The price was a penny, shipping was $3.99. The packing slip that came with the book identified the seller with a 13 digit number. The order number had 17 digits. Then there was this line:

aisle 13 Bay 6   Shelf 1    Item 909

This must be a really big operation. Just from looking over the listings on Amazon there must be a couple of dozen of these places in operation in the USA, maybe as many as one in each state. They obviously aren't making any money on the sales price, so they must be making it in the shipping. Looking for more information, I came across this discussion on Reddit. I've excerpted the relevant bits:
11 Oct 2014
I managed an online book company for the past 4 years. It's the shipping. Amazon sets the shipping charge for all books and media at 3.99 (USD). Most of those books are going to cost me around .80 (possibly less) to ship anywhere in the US, .08 for materials, labor is pretty small, on the order of fractions of a cent for any one book. We list around 1200 books a day, and ship around 2000-2500 a week. Pretty much, it's volume (which also gets you the shipping discounts for being a bulk mailer), and cheap shipping. - Alfowick
Where do you get the books and how much do they typically cost? - jraby3
Everywhere. We take donations, we work with recycling companies, bookstores that shutdown, old stock from thrift stores, libraries. Cost is going to vary widely with the quality and "status" of the books. Big cost difference in buying stuff that has been sitting in a thrift store, versus nice remainders or overstocks from a clearinghouse, but say around .18 per pound. We buy in bulk so we do this for about 40,000 lbs at a time, once a week. Around 70 percent of that (in a really good load) is worthless and will be recycled, donated, or sold in our brick and mortar store. We don't throw books away. We have been moving away from buying books outright and do a lot of consignment work now.- Alfowick
P.S. The book is With Charity Toward None: A Fond Look at Misanthropy Hardcover by Florence King. Don't know anything about it, but Tam recommended Florence, so I thought I'd give her a shot.

P.P.S. I bought the book for a penny, plus shipping, but now the lowest price is $3.88. I guess dying is one way to boost your popularity.

Thursday, May 2, 2013

Big Idea: Translate Currency & Measurements


Reading any kind of article about science or money inevitably involves numbers of one sort, and where we have numbers we need to know just what we are enumerating, i.e. what unit of measure are we using? Since there are two popular measurement systems (English and Metric) and innumerable monetary systems, if you choose to use just one system in your writing, some reader somewhere is going to feel left out. Many writers try to compensate by including a converted number with alternate units in parentheses. i.e. 6 miles (10 clicks). This is alright if there are only one or two numbers involved, but when there are more, it can obscure the writing, making it hard to follow.
    Since we all have these fancy-schmancy computers now, it would be nice if the computer could automatically translate these numbers into your preferred system. Something for the next version of HTML, maybe. Of course, to make this really painless, we would need a sophisticated parser that could identify the numbers and units being used. Should be a piece of cake for the people who brought us self driving cars.

The drawing above is supposed to show that the Metric system is superior to the English system, and if the world was filled with rectangular islands it might be. But it's not. The world we live in is more like the squiggly shaped yellow island. The English measurement system has been constructed to measure the world as it is. For science and engineering, the metric system has certain advantages. Given a choice, I would prefer to work on cars built using the metric system. Fractions of an inch are just a pain. They would be okay if they stopped at sixteenths, but no, so people insist on using 32nds, and even 64ths, and then below that they revert to thousandths of an inch.
    For things in everyday life, like weather, land, travel and houses I prefer the English system.

Friday, May 4, 2012

Crazy Women

Feast of Souls by C.S. Friedman. Here we have young whore apprenticed to a sorcerer. I really liked C.S.Friendman's science fiction books, and I also liked Black Sun Rising, which took a step towards fantasy, but kept one foot in reality. This book leaves reality pretty much behind and enters completely into fantasy. There are some rough edges to the plot, kind of like she was figuring out the implications of the powers available in this imaginary world as she was writing it. There's a bit much of the stilted fair lady / brave knight style of speech. But all in all it's a pretty good story.
Counterprobe by Carole Nelson Douglas. This one reads like a script to a made-for-TV UFO abduction drama. Lot's of tears, anguish and confusion, along with evil government agents and mysterious aliens, who still hadn't made an appearance by the time I got a third of the way through the book, where upon I gave up on it. Too much drama, not enough plot. The woman in this story isn't as psycho as the others, she's just an alien grown clone and as such has no memories of growing up.
Forbidden Knowledge, The Gap Into Vision by Stephen Donaldson. Here we have a beautiful (it's implied, but I don't think the book ever states it explicitly) young, talented female space cop. Prior to this book she was kidnapped by a really rotten space pirate who implanted a remote control in her brain. With this remote control he was able to subject her to all kinds of degrading acts. Presumably sexual, but we never learn just exactly what happened. We are just told, over and over again, how awful and degrading it all was. But this remote control has all kinds of capabilities, and once she gets control of it she starts finding out that there are some things she likes. She likes them so much she becomes addicted to it, and hides it's existence from her superiors and everyone else. As soon as she is rescued from the bad guy, which is where the book starts, she is spirited off by another space pirate, and an endless stream of adventures and predicaments ensue. Great space opera. In this universe they have space ships with engines that consume fuel and can propel their ships to sizable fractions of the speed of light. They also have the "Gap" drive, which allows them to make jumps across interstellar distances. The author's grasp of sub-light physics is not quite perfect, but since you are only operating in a realm that is only a fraction of a light year across, it really doesn't make any difference. And well, super-light physics, well, that's whatever you want to make it, isn't it?


Monday, October 17, 2011

Way O Way O Way O

Spent the weekend converting the garage from the automobile-engine-overhaul business back to normal suburban garage-full-of-junk and cars. Almost all done, everything put away, floor swept, just need to deal with the cat's litter box. Grab the trash can to carry it outside and behind my back there is this explosive crash. Oh, poop, what was that? There were three four foot long fluorescent tubes leaning against the wall behind the trash can. Now there are only two. The third has managed to spread itself over the entire floor.

I put those three bulbs there some time ago. They have been waiting for me to come up with some nice, clean method of getting rid of them. (I wonder what happened to the fourth.)  They are too long to fit in the garbage can, and if I just stick them in there I am sure they will get broken before they make it to the garbage truck and will no doubt spread glass shards hither and yon.

Well, we've got one big mess now, might as well finish off the other two and be done with it. Get a paper grocery sack, stick one end of one of the unbroken bulbs and wack it with a baseball bat. Surprising tough these bulbs, but the bat does the trick. Slide another foot or so of unbroken bulb into the bag and repeat until it is all smashed to smithereens. Repeat for other bulb. Sweep up the mess. Sweep some more. Sweep it all again. Doesn't seem to be any end to these little glass shards.

Eight foot fluorescent bulbs are considered hazardous waste, at least in my jurisdiction: they contain too much mercury. Four foot bulbs are not hazardous waste. They are under the limit. We are talking tiny fractions of a gram here. From Wikipedia: The amount of mercury in a fluorescent lamp varies from 3 to 46 mg, depending on lamp size and age. There was a noticable amount of white powder on the floor from the broken bulb. This is the fluorescent part. The stuff from modern lamps, i.e. any lamps made in the last 60 years, is not poisonous.

Saturday, October 24, 2009

Eternity II, Part 3

I couldn't leave it alone until I sorted it out. Here's the formula for calculating the possible number of unique square tiles where each edge can be a different color and N is the number of colors. I have verified it up to 10 colors. Spreadsheet here.

N
+ (N * (N-1))
+ (N * (N-1) / 2)
+ (N * (N-1) / 2)
+ (N * (N-1) * (N-2))
+ (N * (N-1) * (N-2) / 2)
+ (N * (N-1) * (N-2) * (N-3) / 4)

While I was fooling around with this I ran into a weird problem. When I tried to reduce the formula through factoring, the computer code would not produce the right number for all the different values of N. It would get most of them right, but not all. I am going to try and stop fooling with this now and go on to something else. We shall see how that works. Here is the formula that does not work:

N * (1 + ((N-1) * (2 + ((N-2) * (1.5 + (N-3)/4)))))

Update: problem was caused by intermediate results being fractions. Changing N to a floating point number fixed the problem.

Wednesday, September 30, 2009

Quote of the Day

Heard on Law & Order the other night:
Good liars make good actors.
Or was it:
Good actors make good liars.
Same diff. You watch enough Law & Order and you begin to recognize some patterns, like Detective Green getting a cell phone call in the middle of an interview and telling Lenny they've got to go for some reason, and they hurry off stage. Or the knock on the door when they have a suspect in interrogation. But the characters who aren't regulars are played by some good actors. They do a good job of confusing the issue. Who's lying? Who's guilty? But after a while you begin to notice subtle clues, like that person's response was slightly off, or the camera lingers on someone a fraction of a second too long, and a half hour later you find out you were right! I knew that so and so was no good!

Of course, the guys who are making this show all know this ahead of time, so it's interesting that they can make the clues subtle enough that they don't stand out, but people are still able pick up on them. That they are able to do this week after week and year after year makes me suspect there is more engineering going on than art.

I saw one episode last week that I think was really old because the timing was way different. The lapse between scene changes and the delays between people speaking were slower, or just different. We are talking fractions of a second here. It was interesting to watch.

Tuesday, January 13, 2009

Air Travel Notes

Miscellaneous observations from our recent flight to Iowa. More evidence that air travel is the very peak of technology and the very pit of civilization.

Portland

I have an aluminum watch, aluminum case and bracelet. Used to be I could wear it through a metal detector and it would not set it off. This time it did. Of course it could have been in combination with my belt buckle that triggered the alarm, but taking the watch off is easier. Belt buckle alone did not set off the alarm.

Annoying unattended luggage announcements. We are in the secure section of the airport. All the bags were supposed to have been checked. Why are we being subjected to these stupid announcements over the PA (Public Address) system?

At the gate there is black woman with two crying children. The crying sounds like they are acting, not hurt, or scared. Perhaps each one was trying to cry louder than the other. The mother did not look too happy. I offered her a smile, which she returned. I've been there. Father shows up and she tells them they've been fighting.

Flight attendant giving the "buckle your seat belt" instructions had a very thick accent and/or a speech impediment. It's bad enough we have to listen to these stupid safety instructions every time we get on a plane. Now they are making them incomprehensible as well.

Flight was not full. Out of 21 seats I could see from where I was sitting (3 and a half rows), 8 were empty.

Pilot told us flight would be 2:33. It took 3 hours.


Minneapolis - St. Paul (MSP)

Clear and cold at MSP. Land and sit on runway, they've changed our gate. We get to the gate and it takes a long time before people start getting off. I don't know what the hold up was. For some reason having to wait after we have landed is the most annoying. We have over an hour here before the hopper (twin engine turbo prop) takes us to Fort Dodge (Iowa). This is good as the boarding gate for the hopper is a long way off, relatively speaking.


T3 Mobile Defender from Lamperd Less Lethal
As we are walking through the terminal we see a police tricycle. Looks kind of like a Segway, but it's a trike. It appears to be driven standing up.

There is an automated train that takes us part of the way, and after we get off the train there are a series of moving sidewalks. The train worked very well. Much better than the one I rode in Dallas maybe ten years ago.

On the way we went by the world's largest parking garage. Well, it looked that way to me. Ten stories and a half a mile long, maybe?


The Humphrey Terminal SRF Consulting
We finally get to Gate A-9. There are maybe a dozen seats there and most of them are filled. Well, now we know where it is, so we go look for something to eat. There is a small food court three slidewalks back. There are three or four food vendors and some tables. Most of the tables are full, but I managed to secure a double with four chairs. There are crumbs on the table from the previous visitor. I look around for cleaners or cleaning supplies, but find nothing, not even napkins. True, I did not look very far. But I did find some napkins in my pocket and used them to sweep the debris off the table and into my hand, which I dutifully carry over to the trash can. Three people get sandwiches from Quiznos. Anne shares her sandwich with me. Kathryn has some left over, buy it is less than half and I have already had enough. I don't like to eat too much when I am flying, it gives me grief.

There is a young couple there with small children. The wife is speaking harshly to the kids. The father is wearing a ball cap with BERETTA written across the front. I'm surprised they let him through security.

Burger King does not have milkshakes here. Bummer.

On the whole trip there were only three annoying cell phone talkers, and they quickly shut up. No, I didn't growl, or even glare at them. MSP has a "cell phone area", for people to talk loudly on their cellphones, I imagine. Good idea, if it works.

I'm looking for a restroom but all I see are "Companion Care" rooms. I open the door on one, but I decide against it for some reason. But now my hand is sticky. When I finally find a restroom I go to wash my hand and it is cover with black stuff. I have to wash my hands twice to get it all off. I got this from just touching the door handle on the "Companion Care" room.

The paper towel dispenser was missing it's knob. It was one of those with the lever you pull down to unspool a short length of paper. On the end of the lever there is supposed to be a plastic knob which is easy to grip. This one was missing, leaving me with having to push on the narrow edge of the sheet metal lever. Grrr!

The attendant at Gate A-9 has a big black mole on her face. I wonder why people put up with these things. Maybe the cure is worse than the disease. I suppose they are used to it. Maybe it doesn't bother other people as much as it bothers me. I wonder if it would bother me if I knew her.

They have an abbreviated Jet-Way that leads to the door. The last time I was here we had to walk out across the tarmac to the plane. The hood at the end of the Jetway does not completely seal against the fuselage. It leaves a gap a foot or two tall. Along the side of the Jetway there is container with shelves to store your "checked" baggage. While we are standing in line to board the plane the door to the container slams shut with a big bang. The "container" is an elevator that takes the baggage down to the ground and the baggage handlers.


Hopper (short range turboprop aircraft)

The plane is a Saab-34. The doorway into the airplane is not very tall and Anne bumps her head. Loading seems to go very slowly, especially since there are only a dozen or so passengers. There are two seats on the right hand side of the aisle and one on the left.

The engine nacelles seem enormous considering the relatively small size of the props. The props have four blades and look to be about 12 feet in diameter. The inner half of the leading edge of the props appears to have some kind of rubber coating, anti-icing system, I assume. The nacelle looks to be about five feet tall, 12 to 15 feet long, and two or three feet wide. The air intake under the prop looks to be about 6 inches by 12. The exhaust looks to be about 12 inches in diameter. The nacelle also holds the main landing gear.

When the engines start up I can see where the blades are spinning. The outer tips are marked by yellow. The spinning circle shifts up and down by fractions of an inch. Once we are at cruising altitude I can no longer see the outer parts of the blades. I can still see a smear where the inner parts of the blades are.

I watch six airliners land while the hopper is taxiing prior to takeoff. The come in one after another, alternating on parallel runways. We have to cross one of these runways and we do so at a good clip.

On the way to Fort Dodge (Iowa) I see numerous power generation windmills. I couldn't count them all. 50? 100?

Iowa is flat. The whole Midwest is flat. Flat as a pancake clear to the horizon. As seen from an airplane anyway. From a bicycle it's a different story.

Saw what looked like some kind of ice fishing camp on a frozen lake. Tried to get a better look and the whole place erupted in a cloud of smoke, or snow. Look again and all the "smoke" is gone. Shift my head and it's back. Oh, it's craze or scratches on my window. There isn't any smoke. It really fooled me for a second. Amazing.


Fort Dodge

Driving through Fort Dodge on a four lane concrete road and in half a mile I only see maybe ten cars.


On our way out of Fort Dodge, I see a couple of railroad gondolas equipped with big yellow snow plow blades. Makes for a quick way to get a snow plow. Just hook up an engine behind the gondola and push.

Just down the road we drive on a bridge over a good size river. There are automobile tracks going up and down the ice.

Update December 2016 replaced missing pictures. Minneapolis parking picture is not the original.