HP Forums
Programs for 15C and 35S - Printable Version

+- HP Forums (https://archived.hpcalc.org/museumforum)
+-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html)
+--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html)
+--- Thread: Programs for 15C and 35S (/thread-243838.html)



Programs for 15C and 35S - Eddie W. Shore - 05-19-2013

HP 15C: Julian Date

HP 35S Horizontal Curve: Radius, Chord Length, Arc Length given Tangent Length and Radius

HP 35S Vertical Curve: Point of Peak and Elevation at Peak Point and Length

HP 35S: Distance to Horizon

HP 35S Air Density and Density Altitude

HP 35S: Approximate Length of Sunlight


Re: Programs for 15C and 35S - LMMT - 05-20-2013

Thank you, very useful!


Re: Programs for 15C and 35S - Walter B - 05-20-2013

+1.

BTW, is anybody collecting such programs in a program library of some kind? The collective knowledge of RPN programmers shouldn't vanish in time IMHO. I know the RPL folks have their place at hpcalc.org. Is there anything alike for RPN? If true, where?

d:-)


Re: Programs for 15C and 35S - Thomas Klemm - 05-20-2013




HP-35S Vertical Curve: Elevation at Peak and at End Point - Thomas Klemm - 05-20-2013

Quote:
Examples 
Uphill curve:
I = 1,000 ft
G = 7% = .07
H = -4% = -.04
L = 1,368 ft

Point at peak elevation is 870.545 ft into the curve at 1,030.469 ft.
The elevation at the end of the curve is 1,020.520 ft.



Given your solution I get:

G = (1,030.469 - 1,000) / 870.545 = 0.035
H = (1,020.520 - 1,030.469) / (1,368 - 870.545) = -0.02

So it seems a factor 2 is missing somewhere.


As I'm not an engineer I wonder why the length L is divided into two parts similar to G:H (or rather |G|:|H|) to determine the peak. Why would somebody want to do that? What's the real world application of it?

Kind regards

Thomas


Re: Programs for 15C and 35S - Dieter - 05-20-2013

Eddie, I tried the Julian date program and noticed that it will work only for dates since the introduction of the Gregorian calendar on October 15, 1582 (JD 2299161). Every date before produces a JD result that is off by some days, simply because the rules for leap years introduced with the Gregorian calendar did not apply earlier.

Example:

 date          Julian Day   15C program     error
--------------------------------------------------
Oct 15, 1582 JD 2299161 JD 2299161 0 ; first day of Gregorian calendar
Oct 04, 1582 JD 2299160 JD 2299150 -10 ; last day of Julian calendar
Jan 01, 1500 JD 2268933 JD 2268924 -9
Jan 01, 1000 JD 2086308 JD 2086303 -5
Jan 01, 300 JD 1830633 JD 1830633 0
Jan 01, 1 JD 1721424 JD 1721426 +2
In other words, the 15C program assumes a proleptic (perpetual) Gregorian calendar, so that even dates before Oct 15, 1582 are assumed Gregorian. This means that even dates in medieval times are assumed to be given in a calendar system introduced many centuries later. This is at least not very common, so that either the program should be modified or a respective note should be added.

Dieter


Re: Programs for 15C and 35S - Torsten - 05-20-2013

I have some programs on my HP-15C simulator page and some of Eddie's programs are part of the simulator distributions.

I am looking forward to receiving more HP-15C programs to be published and included with the simulator. Preferably already as .15c program file with the documentation included.


Re: Programs for 15C and 35S - Thomas Klemm - 05-20-2013

The listings that your simulator creates are very nice! Congratulations! Just had a glimpse at Little Gauss. Here's a third variant:

LBL C
1
+
2
Cy,x
RTN

In the article
Effective Computer-aided Calculator Programming - Part 1 - Voyager you can find a compiler that could probably be adjusted to produce the format you need for your simulator as well. Just thought you might be interested.

Kind regards

Thomas

Edited: 20 May 2013, 6:34 p.m.


Re: Programs for 15C and 35S - Gerson W. Barbosa - 05-21-2013

Quote:
Here's a third variant:
LBL C
1
+
2
Cy,x
RTN

More computational effort, I think, but a record for conciseness! Increasing the constants by one will give the sum of the first n triangular numbers. Increasing them by one again will give the sum of the latter, and so on it appears.

Cheers,

Gerson.


Re: Programs for 15C and 35S - Thomas Klemm - 05-21-2013

If you define as the
forward difference operator defined as an = an+1 - an and the summation operator as an = Sum[ai, {i, 0, n-1}], you can verify the following:

  • = 1 (identity)
  • Cn,k = Cn,k-1
  • Cn,k = Cn,k+1
Thus these two operators are shifting the index k of the binomial coefficient up and down.

This is similar to how differentiation and integration operate upon the functions fk(x) = xk/k!. Hence the similarity of Newton's Forward Difference Formula with the Taylor series expansion.

Cheers

Thomas


Re: HP-35S Vertical Curve: Elevation at Peak and at End Point - Eddie W. Shore - 05-23-2013

Quote:

Given your solution I get:

G = (1,030.469 - 1,000) / 870.545 = 0.035
H = (1,020.520 - 1,030.469) / (1,368 - 870.545) = -0.02

So it seems a factor 2 is missing somewhere.


As I'm not an engineer I wonder why the length L is divided into two parts similar to G:H (or rather |G|:|H|) to determine the peak. Why would somebody want to do that? What's the real world application of it?

Kind regards

Thomas


I am looking into this. I got the formulas from the Fundamental of Engineering Handbook reference book, if it helps.

You determination for G and H are straight forward.

Update: It seems to be a factor of 2 at peak point. Vertical curves, to my understanding, are symmetrical in a sense of tangent lines: one created from the beginning of the curve and on at the end of the curve. If a line is drawn at the intersection of the tangent line perpendicular to the base, that line bisects the length of the base.

The grade is determined from where the tangent lines meet. In a perfectly symmetrical vertical curves the tangent lines meet at the curve's peak elevation. For this case:

G = (y0 - I)/(L/2) and H = (I - y0)/(L/2) where y0 is the peak elevation.

Some more information is provided here:

http://www.wsdot.wa.gov/publications/manuals/fulltext/M22-23/Vertical.pdf

http://www.iowadot.gov/design/dmanual/02b-01.pdf

I am not an engineer either, I just have an interest in the subject. Hope this helps, Eddie

Edited: 23 May 2013, 10:09 p.m.


Re: Programs for 15C and 35S - Eddie W. Shore - 05-23-2013

Quote:
Eddie, I tried the Julian date program and noticed that it will work only for dates since the introduction of the Gregorian calendar on October 15, 1582 (JD 2299161). Every date before produces a JD result that is off by some days, simply because the rules for leap years introduced with the Gregorian calendar did not apply earlier.

Example:

 date          Julian Day   15C program     error
--------------------------------------------------
Oct 15, 1582 JD 2299161 JD 2299161 0 ; first day of Gregorian calendar
Oct 04, 1582 JD 2299160 JD 2299150 -10 ; last day of Julian calendar
Jan 01, 1500 JD 2268933 JD 2268924 -9
Jan 01, 1000 JD 2086308 JD 2086303 -5
Jan 01, 300 JD 1830633 JD 1830633 0
Jan 01, 1 JD 1721424 JD 1721426 +2
In other words, the 15C program assumes a proleptic (perpetual) Gregorian calendar, so that even dates before Oct 15, 1582 are assumed Gregorian. This means that even dates in medieval times are assumed to be given in a calendar system introduced many centuries later. This is at least not very common, so that either the program should be modified or a respective note should be added.

Dieter


Dieter, I will do the note. Thanks for pointing this out. Always appreciated.

Eddie

Edited: 23 May 2013, 10:09 p.m.


Re: HP-35S Vertical Curve: Elevation at Peak and at End Point - Thomas Klemm - 05-25-2013

I completely mixed up the peak point of the curve and the Vertical Point of Intersection. But I didn't realize that we're dealing with a curve (a parabola to be more specific) because it's missing in your sketch. I assumed the two intersecting lines, that's the curve.

Thanks for providing the links to the papers. It clarified a lot.

Cheers

Thomas


Re: HP-35S Vertical Curve: Elevation at Peak and at End Point - Eddie W. Shore - 05-29-2013

Quote:
I completely mixed up the peak point of the curve and the Vertical Point of Intersection. But I didn't realize that we're dealing with a curve (a parabola to be more specific) because it's missing in your sketch. I assumed the two intersecting lines, that's the curve.

Thanks for providing the links to the papers. It clarified a lot.

Cheers

Thomas


Thomas,

Thanks for posting the question - you helped me become clearer on the subject. Much appreciated.


Re: HP-35S Vertical Curve: Elevation at Peak and at End Point - Thomas Klemm - 05-29-2013

Just compare these two images:

VERTICAL CURVE EQUATIONS


HP35S Vertical Curve: Elevation at Peak and at End Point


LEGEND


    g1 = Approach gradient in %
A = Algebraic difference in gradients
L = Length of vertical curve stations

B.V.C. = Beginning of Vertical Curve
V.P.I. = Vertical Point of Intersection
E.V.C. = End of Vertical Curve
X = Distance from the B.V.C. to the low or high point in stations.

EQUATIONS


X = g1{L/A}

Your sketch suggest that (x0, y(x0)) is the Vertical Point of Intersection where instead it is the peak of the curve. I recommend to change the sketch.

Kind regards

Thomas


Re: Programs for 15C and 35S - Gerson W. Barbosa - 06-03-2013

On the HP-42S Little Gauss can be made the same size in bytes without using COMB. One step longer, however:

00 { 13-Byte Prgm }
01 LBL "LG"
02 1
03 +
04 2
05 COMB
06 END

00 { 13-Byte Prgm }
01 LBL "LG"
02 X^2
03 RCL+ ST L
05 2
06 /
07 END

Since we're at it, here is Gauss Little (Inverse Little Gauss :-)

00 { 21-Byte Prgm }
01 LBL "GL"
02 8
03 *
04 1
05 +
06 SQRT
07 0.5
08 *
09 RCL- ST L
10 END

Cheers,

Gerson.




Re: Programs for 15C and 35S - Thomas Klemm - 06-04-2013

Very nice! Do you still remember that thread: Short Quadratic Solver (HP-42S)

This solution is based on it:

00 { 17-Byte Prgm }
01 LBL "GL"
02 STO+ ST X
03 SQRT
04 ENTER
05 STO+ ST X
06 1/X
07 ASINH
08 E^X
09 /
10 END

Best regards

Thomas


The port to HP-15C is straight forward:
001 - 42,21,11  LBL A      
002 - 36 ENTER
003 - 40 +
004 - 11 SQRT
005 - 36 ENTER
006 - 36 ENTER
007 - 40 +
008 - 15 1/x
009 - 43,22,23 ASINH
010 - 12 e^x
011 - 10 /
012 - 43 32 RTN


Edited: 4 June 2013, 4:27 a.m.


Re: Programs for 15C and 35S - Thomas Klemm - 06-04-2013

For those interested in the math behind it:

Quadratic equation:

Solution:

Logarithmic representation of inverse hyperbolic function:

This implies:

Try to bring the solution of the quadratic equation to this form:

Substitution:

Move the negative sign through sinh-1:

Use e-x=1/ex:




Re: Programs for 15C and 35S - Gerson W. Barbosa - 06-04-2013

Quote:
00 { 17-Byte Prgm }

Great saving, more than I expected!

Just an interesting result:

2 SQRT 23 + XEQ GL XEQ GL

Cheers,

Gerson.

[sub]Edited to fix a typo per Thomas's observation below[/pre]

Edited: 4 June 2013, 12:03 p.m. after one or more responses were posted


Re: Programs for 15C and 35S - Thomas Klemm - 06-04-2013

How on earth did you stumble upon this? That's amazing! But it took me a while to figure out that XL is probably a typo.

Best regards

Thomas


Re: Programs for 15C and 35S - Thomas Klemm - 06-04-2013

Okay, I guess I figured it out:

#!/usr/bin/python
from math import pi
x = pi
for i in range(10):
x = x*(x + 1)/2
print "%.12f" % x

6.505598527340
24.414205363131
310.233814438138
48277.626717637635
1165388759.557138442993
679065481033757312.000000000000
230564963765804121415221078080356352.000000000000
2.65801012582e+70
3.53250891447e+140
6.23930961541e+280

I'm still impressed.

Cheers

Thomas


Re: Programs for 15C and 35S - Gerson W. Barbosa - 06-04-2013

Quote:
How on earth did you stumble upon this?

PI XEQ LG XEQ LG 2 SQRT -     -->    22.9999918008
Cheers,

Gerson.


Re: Programs for 15C and 35S - Gerson W. Barbosa - 06-04-2013

Quote:
679065481033757312.000000000000

How accurate should that be? On the WP34S I get
     679065481033757541.1897711439112775

Another interesting near-integer, not related to the above:

pi^34 = 8.00010471505e16
or
pi^34*10-16 - pi/3*10-4 = 7.99999999529

Yet another one involving sqrt(2) and pi:

1/2*pi^34 = 141422281.793

Whether these are a coincidence or not, I don't know.

Best regards,

Gerson

Edited: 4 June 2013, 12:49 p.m.


Re: Programs for 15C and 35S - Thomas Klemm - 06-04-2013

e to the pi Minus pi

Also, I hear the 4th root of (9^2 + 19^2/22) is pi.


Re: Programs for 15C and 35S - Gerson W. Barbosa - 06-04-2013

Quote:
e to the pi Minus pi

http://jsmarkovitch.files.wordpress.com/2009/11/coincidence-data-compression-and-mach_s-concept-of-economy-of-thought-j-s-markovitch.pdf

Quote:
Also, I hear the 4th root of (9^2 + 19^2/22) is pi

This is a bit closer, but still too far away:


Edited: 4 June 2013, 9:41 p.m.


Re: Programs for 15C and 35S - Thomas Klemm - 06-05-2013

That's an interesting paper. Both cases are handled. Thanks a lot for posting the link.

Kind regards

Thomas