(50g) Earthquake Magnitudes: How Much Stronger?
07-06-2019, 01:21 PM
Post: #1
 Joe Horn Senior Member Posts: 1,591 Joined: Dec 2013
(50g) Earthquake Magnitudes: How Much Stronger?
In honor of the two large earthquakes here in Southern California in the past two consecutive days, here's a little User RPL program called 'QUAKE' which answers the question, "How much bigger in one earthquake than another earthquake?"

"Earthquake magnitude" has many different meanings. This program uses the definition used by the USGS, since that's what the US news services quote.

INPUT: Two earthquake magnitudes (order doesn't matter).
OUTPUT: How much "BIGGER" the larger quake is, and how much "STRONGER" (energy expended) the larger quake is. Both outputs are tagged.

Example: Yesterday's quake was M7.1 and the quake the day before that was M6.4. How much worse was yesterday's quake?

7.1 ENTER 6.4 QUAKE -->
STRONGER: 11.2
BIGGER: 5

So yesterday's quake was 5 times bigger and 11.2 times stronger than the quake the day before that.

'QUAKE'
<< I->R - ABS ALOG LASTARG 2. / ALOG OVER * 1. RND
"STRONGER" ->TAG SWAP 1. RND "BIGGER" ->TAG >>

BYTES: 76.5 #EECDh

The math is simple. If the two magnitudes are A and B:
BIGGER = 10^ABS(A-B)
STRONGER = 10^(ABS(A-B)/2)*BIGGER
Simplifying the program is left as a micro-challenge.

<0|ɸ|0>
-Joe-
07-06-2019, 04:20 PM
Post: #2
 Valentin Albillo Senior Member Posts: 486 Joined: Feb 2015
RE: (50g) Earthquake Magnitudes: How Much Stronger?

Hi, Joe:

Sorry for the quakes, we had a respectable one last week or so in Costa Rica, no damage.

(07-06-2019 01:21 PM)Joe Horn Wrote:  Example: Yesterday's quake was M7.1 and the quake the day before that was M6.4. How much worse was yesterday's quake?

7.1 ENTER 6.4 QUAKE -->
STRONGER: 11.2
BIGGER: 5
[...]

'QUAKE'
<< I->R - ABS ALOG LASTARG 2. / ALOG OVER * 1. RND
"STRONGER" ->TAG SWAP 1. RND "BIGGER" ->TAG >>

BYTES: 76.5 #EECDh

HP-71B:

INPUT A,B @ T=ABS(A-B) @ "Bigger:";10^T;", Stronger:";10^(1.5*T)

Trivial but shorter and way less cryptic, as usual. If you want results rounded to just 1 decimal place, place a FIX 1 anywhere before the output.

Have a nice weekend.

V.

Find All My HP-related Materials here:  Valentin Albillo's HP Collection

07-06-2019, 05:06 PM
Post: #3
 grsbanks Senior Member Posts: 992 Joined: Jan 2017
RE: (50g) Earthquake Magnitudes: How Much Stronger?
(07-06-2019 01:21 PM)Joe Horn Wrote:  'QUAKE'
<< I->R - ABS ALOG LASTARG 2. / ALOG OVER * 1. RND
"STRONGER" ->TAG SWAP 1. RND "BIGGER" ->TAG >>

BYTES: 76.5 #EECDh

Interesting. I make that 86 bytes but with the same checksum as you.

There's this option too (leaving the rounding to the user's display settings):

Code:
<<   - ->NUM ABS ALOG DUP 1.5 ^   "STRONGER" ->TAG SWAP "BIGGER" ->TAG >>

76.5 bytes, #3C12h
07-06-2019, 05:07 PM
Post: #4
 Didier Lachieze Senior Member Posts: 1,157 Joined: Dec 2013
RE: (50g) Earthquake Magnitudes: How Much Stronger?
And for RPN fans here is a 42S version

Code:
00 { 47-Byte Prgm } 01▸LBL "QUAKE" 02 - 03 ABS 04 10↑X 05 1.5 06 RCL× ST L 07 10↑X 08 "Bigger: " 09 ARCL ST Y 10 ├"[LF]Stronger: " 11 ARCL ST X 12 AVIEW 13 END

Attached File(s)
07-06-2019, 09:52 PM
Post: #5
 Joe Horn Senior Member Posts: 1,591 Joined: Dec 2013
RE: (50g) Earthquake Magnitudes: How Much Stronger?
(07-06-2019 05:06 PM)grsbanks Wrote:
(07-06-2019 01:21 PM)Joe Horn Wrote:  'QUAKE'
<< I->R - ABS ALOG LASTARG 2. / ALOG OVER * 1. RND
"STRONGER" ->TAG SWAP 1. RND "BIGGER" ->TAG >>

BYTES: 76.5 #EECDh

Interesting. I make that 86 bytes but with the same checksum as you.

Yes, it's 86 bytes if you execute BYTES on the name, but 76.5 bytes if you execute BYTES on the program itself, which I prefer to do, to allow for renaming.

<0|ɸ|0>
-Joe-
07-06-2019, 09:55 PM
Post: #6
 Joe Horn Senior Member Posts: 1,591 Joined: Dec 2013
RE: (50g) Earthquake Magnitudes: How Much Stronger?
(07-06-2019 04:20 PM)Valentin Albillo Wrote:
HP-71B:

INPUT A,B @ T=ABS(A-B) @ "Bigger:";10^T;", Stronger:";10^(1.5*T)

Trivial but shorter and way less cryptic, as usual.

Thanks for sharing that! The human-readable clarity of HP-71 BASIC always warms my heart.

<0|ɸ|0>
-Joe-
07-07-2019, 02:04 AM
Post: #7
 ijabbott Senior Member Posts: 804 Joined: Jul 2015
RE: (50g) Earthquake Magnitudes: How Much Stronger?
(07-06-2019 05:07 PM)Didier Lachieze Wrote:  And for RPN fans here is a 42S version

Code:
00 { 47-Byte Prgm } 01▸LBL "QUAKE" 02 - 03 ABS 04 10↑X 05 1.5 06 RCL× ST L 07 10↑X 08 "Bigger: " 09 ARCL ST Y 10 ├"[LF]Stronger: " 11 ARCL ST X 12 AVIEW 13 END

Oh, does this mean I can play 'Quake' on my DM42?

— Ian Abbott
07-07-2019, 07:57 AM
Post: #8
 grsbanks Senior Member Posts: 992 Joined: Jan 2017
RE: (50g) Earthquake Magnitudes: How Much Stronger?
(07-06-2019 09:52 PM)Joe Horn Wrote:  Yes, it's 86 bytes if you execute BYTES on the name, but 76.5 bytes if you execute BYTES on the program itself, which I prefer to do, to allow for renaming.

Interesting. I'll have to read up on this and find out why.

Feeding my version of the program to BYTES makes it 67 bytes in length.
07-17-2019, 02:19 PM
Post: #9
 StephenG1CMZ Senior Member Posts: 826 Joined: May 2015
RE: (50g) Earthquake Magnitudes: How Much Stronger?
On the HP Prime, I have implemented some additional earthquake functions that may be of interest.