Post Reply 
(50g) Earthquake Magnitudes: How Much Stronger?
07-06-2019, 01:21 PM
Post: #1
(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. Wink

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
07-06-2019, 04:20 PM
Post: #2
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.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
07-06-2019, 05:06 PM
Post: #3
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
Find all posts by this user
Quote this message in a reply
07-06-2019, 05:07 PM
Post: #4
RE: (50g) Earthquake Magnitudes: How Much Stronger?
And for RPN fans here is a 42S version Smile

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)
.zip  quake.zip (Size: 180 bytes / Downloads: 1)
Find all posts by this user
Quote this message in a reply
07-06-2019, 09:52 PM
Post: #5
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-
Visit this user's website Find all posts by this user
Quote this message in a reply
07-06-2019, 09:55 PM
Post: #6
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. Smile

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
07-07-2019, 02:04 AM
Post: #7
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 Smile

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? Smile

— Ian Abbott
Find all posts by this user
Quote this message in a reply
07-07-2019, 07:57 AM
Post: #8
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.
Find all posts by this user
Quote this message in a reply
07-17-2019, 02:19 PM
Post: #9
RE: (50g) Earthquake Magnitudes: How Much Stronger?
On the HP Prime, I have implemented some additional earthquake functions that may be of interest.
https://www.hpmuseum.org/forum/thread-13244.html
Thanks for the inspiration.

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)