derived functions: with applications to ballistics and daylength

6
480 to and Whitney Harris Have you noticed that scientific calcula- tors have built-in functions that are missing on computers? It’s surprising, but not as troublesome as it seems at first. The functions that are not built-in are not truly missing either for they can be expressed algebraically in terms of the built-in functions and so are called derived functions. Where do you find the algebraic expression for a function you want? If it is a widely known and practical function (as are those built into the calculator) then you may find it in the reference manual for your computer. For instance, two that we will derive and apply later are inverse sine: ARCSIN(X) = ATN(X/SQR( - X*X + 1)) (1) and inverse cosine: ARCCOS(X) = 1.5708 - ATN(X/SQR( - X*X + 1)). (2) These formulas, valid for values of X greater than - 1 and less than + 1, rely on the built-in functions inverse tangent ATN and the square root function SQR. Since, throughout this article, we will discuss formulas for use in computer programs, we will use computer style all-on-one-line notation in the text as well. There is an advantage of sorts to making a function only available as a derived function rather than built-in. Each built-in function or command adds to the list of reserved words that we are not allowed to use in variable names or in new function names. Having too many reserved words makes choosing variable names difficult. In fact, when we use ARCSIN(X) as a derived function we can’t use that name for it because it has the reserved word SIN in it. When we write code, we will use ASN(X) instead. For the same reason, the built-in function in- verse tangent is denoted ATN(X) rather than ARCTAN(X) which contains the reserved word TAN. Formula Derivation Because computer manuals typically present formulas (1) and (2) without proof School Science and Mathematics Volume 85 (6) October 1985

Upload: whitney-harris

Post on 30-Sep-2016

220 views

Category:

Documents


4 download

TRANSCRIPT

480

toand

Whitney Harris

Have you noticed that scientific calcula-tors have built-in functions that aremissing on computers? It’s surprising,but not as troublesome as it seems atfirst. The functions that are not built-inare not truly missing either for they canbe expressed algebraically in terms ofthe built-in functions and so are calledderived functions.

Where do you find the algebraic expression for a function you want? If it is awidely known and practical function (as are those built into the calculator) thenyou may find it in the reference manual for your computer. For instance, twothat we will derive and apply later are inverse sine:

ARCSIN(X) = ATN(X/SQR( - X*X + 1)) (1)and inverse cosine:

ARCCOS(X) = 1.5708 - ATN(X/SQR( - X*X + 1)). (2)These formulas, valid for values of X greater than - 1 and less than + 1, rely onthe built-in functions inverse tangent ATN and the square root function SQR.

Since, throughout this article, we will discuss formulas for use in computerprograms, we will use computer style all-on-one-line notation in the text as well.

There is an advantage of sorts to making a function only available as a derivedfunction rather than built-in. Each built-in function or command adds to the listof reserved words that we are not allowed to use in variable names or in newfunction names. Having too many reserved words makes choosing variablenames difficult. In fact, when we use ARCSIN(X) as a derived function we can’tuse that name for it because it has the reserved word SIN in it. When we writecode, we will use ASN(X) instead. For the same reason, the built-in function in-verse tangent is denoted ATN(X) rather than ARCTAN(X) which contains thereserved word TAN.

Formula Derivation

Because computer manuals typically present formulas (1) and (2) without proof

School Science and MathematicsVolume 85 (6) October 1985

Derived Functions 481

of any kind, we supply a brief derivation here.To express ARCSIN in terms of ARCTAN start with the Pythagorean Identity

SIN(A)A2 + COS(A)A2 = 1.Solve for COS(A), and substitute into TAN(A) = SIN(A)/COS(A) to get

TAN(A) = SIN(A)/SQR(1 - SIN(A)A2).Letting SIN(A) = X or equivalently A = ARCSIN(X), by substitution

TAN(A) = X/SQR(1 - XA2).Solving for A followed by substitution yields

ARCSIN(X) = ARCTAN(X/SQR(1 - XA2)),which is equivalent to formula (1) upon replacement of XA2 by the computa-tionally faster form X*X.To obtain the formula for inverse cosine, start with the familiar identity

SIN(A) = X = COS((PI/2) - A).Recasting in terms of inverse functions and rearranging yields

ARCCOS(X) = (PI/2) - ARCSIN(X).Finally, substituting formula (1) into the right side yields:

ARCCOS(X) = (PI/2) - ARCTAN(X/SQR(1 - X*X)),which agrees with formula (2) by using 1.5708 for PI/2.Now let’s look at two programming applications: one to ballistics using in-

verse sine and one to hours of daylight using inverse cosine.

Ballistics

In the age of rockets, ballistics is still alive. An object in flight that is not beingpowered at the time behaves as a projectile�coasting under the influence ofgravity. In fact, an intercontinental ballistic missile expends its fuel quickly, thenfollows a ballistic trajectory to its target. Its path can be determined based on its"initial velocity," by which we mean its speed and direction at the instant itstarted to coast. Similarly, for an artillery piece the term "muzzle velocity" isused for the initial speed with which the shell issues from the gun. In sports alsothe trajectory of the projectile is determined by the velocity at release or take off,as in the shot-put or javelin throw and even in the broad jump in which the jump-er’s body is the projectile.

In the above sports examples maximum range is desired, but in the militarysituation the shell must land on or near a target. Baseball, golf, and footballhave both; sometimes you want maximum range and sometimes you want to hita target. Suppose you know (from radar, observation, map, etc.) the range R(distance to the target) and you also know V the muzzle velocity of the gun; whatyou need is the inclination angle A above the horizontal at which you should setthe gun barrel. Physics books give the modest kinematic background and deriva-tion of a range formula relating the above quantities:

R = (VA2)*SIN(2*A)/g, (3)

School Science and MathematicsVolume 85 (6) October 1985

482 Derived Functions

where g is the acceleration due to gravity (g = 9.8 meters/sec. A2).1 This for-mula, in which air resistance is neglected, holds for both gun and target on thesame level. Since the maximum value 1 of the sine function is attained when theangle 2*A = 90 degrees, the maximum range of the gun (VA2)/g occurs when A= 45 degrees. Since g is fixed, and V is a known property of the charge and gun,the maximum range becomes known. Denoting (VA2)/g by MAX in the originalrange formula gives the simpler formula

R = MAX * SIN(2*A). (4)Solving equation (4) for A yields

A = .5 * ARCSIN(R/MAX). (5)Using formula (5), a value of R determines the gun inclination angle A. Actually,due to the identity

SIN(180deg. - 2*A) = SIN(2*A),applicable to equation (4), there are two angles you can use to hit the target: thelow angle A and the high angle 90 deg. - A. The resulting trajectories are simi-lar to those of a line drive and a fly ball to the same spot on the baseball field.A comprehensive list of corresponding values of range R and angle A is called

a range table. Program One produces such a table based on the low muzzle veloc-ity of 52 mtr./sec. for the United States, 81mm, M-29 Mortar.2 For higher muz-zle velocities more sophisticated methods accounting for air resistance are pre-ferred.3

10 REM PROGRAM ONE�BALLISTIC RANGE TABLE15 REM **********************************20 LET PI = 3.141625 REM DEFINE INVERSE SINE FUNCTION30 DEF FN ASN(X) = ATN (X / SQR ( - X * X + 1))40 REM MUZZLE VELOCITY, METERS/SEC. AND50 REM GRAVITY ACCELERATION, METERS/SEC.A260 LETVEL = 52:G = 9.870 REM MAXIMUM RANGE80 LET MAX = (VEL * VEL) / G85 PRINT : PRINT90 REM TABLE HEADING100 PRINT "MUZZLE VELOCITY = ";VEL;" METERS/SEC."110 PRINT "MAXIMUM RANGE = ";MAX;" METERS"120 PRINT130 PRINT "RANGE MTRS. "; "LOW ANGLE DEG. "; "HIGH ANGLE"140 REM LOOP TO COMPUTE INCLINATION ANGLE OF GUN150 FOR RANGE = 0 TO (MAX - .01) STEP 20160 LET ARAD = .5 * FN ASN(RANGE / MAX)170 LETADEG = ARAD * 180 / PI175 LET ANGLE = INT (ADEG * 100 + .5) / 100180 LET HIGHANGLE = 90 - ANGLE190 PRINT RANGE; TAB( 13); ANGLE; TAB( 29); HIGHANGLE200 NEXT RANGE210 END

School Science and MathematicsVolume 85 (6) October 1985

Derived Functions 483

Table produced by Program One

Muzzle Velocity = 52 Meters/Sec.

Maximum Range = 275.918367 Meters

RANGE MTRS.020406080100120140160180200220240260

LOW ANGLE DEG.02.084.176.288.4310.6212.8915.2517.7220.3623.2326.4430.2235.22

HIGH ANGLE9087.9285.8383.7281.5779.3877.1174.7572.2869.6466.7763.5659.7854.78

Hours of Daylight

Have you seen the tourist bureau advertisements for summer vacations in Scan-danavia? They claim their longer hours of daylight allow more time for touringand recreation. Let’s see how significant this really is by comparing the length ofthe longest Scandanavian day with that of the British Isles or with that of NewEngland.

The formulaR = ARCCOS(( - .01513 + COS(A)*SIN(L))/(SIN(A)* COS(L))) (6)

gives the angular rotation R (in radians) of the Earth from noon to sunset for alocation at latitude L. The letter A stands for the angle between a ray along theaxis of the Earth in the direction of the North Pole and a ray starting at the cen-ter of the Sun and passing through the center of the Earth.At the summer solstice (about June 22) angle A is not difficult to find. Then,

the Earth’s axis is tilted 23.5 degrees toward the Sun, so angle A is 90 + 23.5 =

113.5 degrees. Since the Earth takes 24 hours to make a complete rotation (360deg. or 2*PI radians), we multiply the rotation angle R (corresponding to halfthe daylength) by 24 hours/(2*PI radians) then multiply by two to get the fullnumber of hours of daylight.Program Two produces a table of longest daylengths for the Northern Hemis-

phere. For comparison we included locations in the Southern Hemisphere where

School Science and MathematicsVolume 85 (6) October 1985

484Derived Functions

". . . the tourist bureau advertisements for summer vaca-tions in Scandanavia . . . claim longer hours of daylightallow more time for touring and recreation/9

on the same date the shortest day occurs. From the table you can see that com-pared to the latitude of New York (40.75 degrees), London (51.5 deg.) has 1.6more hours of daylight, and Oslo (60 deg.) has 3.8 hours more than New York.In contrast, Miami (25.75 deg.) has 1.4 hours less daylight than New York.

10REM PROGRAM TWO�HOURS OF DAYLIGHT JUNE 2215REM **********************************20LET PI = 3.1415926530DEF FN ACN(X) - 1.5708 - ATN (X / SQR ( - X * X + 1))35PRINT : PRINT40REM TABLE HEADINGS50PRINT "LAT. DEG."; TAB( ^"CITY/LOCATION"; TAB( 25);"HOURS

OF LIGHT"55PRINT60REM READ LATITUDE AND CITY/LOCATION70READ LDEG, CITY$80REM CONVERT ANGLES A AND L TO RADIANS90LET A - 113.5* PI/180100LET L = LDEG * PI / 180110LET RTNNUMBER = ( - .01513 + COS (A) * SIN (L)) / ( SIN (A) * COS (L))120REM TEST FOR CONTINUAL DAYLIGHT130IF RTNNUMBER > = - 1 THEN 150140LET HOURS = 24: GOTO 180150LET RANGLE = FN ACN (RTNNUMBER)160REM CONVERT ROTATION ANGLE OF EARTH TO HOURS170LET HRS = RANGLE * 24 / PI175LET HOURS = INT (HRS * 100 + .5) / 100180PRINT LDEG; TAB( 10);CITY$; TAB( 29);HOURS190IF LDEG = 69 THEN 240200GOTO 70202DATA -52,"FALKLAND IS.",-46,"DUNEDIN, N.Z."204DATA -34,"SYDNEY",-22,"RIO",-12,"LIMA"210DATA 0,"QUITO, ECUADOR",9,"PANAMA",19,"BOMBAY"220DATA 26,"MIAMP’,41,"NEW YORK",52,"LONDON"230DATA 60.0SLO,69,MURMANSK240END

School Science and MathematicsVolume 85 (6) October 1985

Derived Functions 485

Table produced by Program Two

LAT.DEG. CITY/LOCATION

HOURSOFLIGHT

-52FALKLAND IS.-46DUNEDIN,N.Z.- 34SYDNEY-22RIO-12LIMA0QUITO, ECUADOR9PANAMA19BOMBAY26MIAMI41NEWYORK52LONDON60OSLO69MURMANSK

7.748.639.8810.7911.4212.1312.6513.2813.7815.1416.7618.9124

The programs, written in BASIC on an Apple II computer, should require lit-tle or no change to run on other computers.

References

1. Sears, F. W., M. W. Zemansky, and H. D. Young. University Physics, Fifth Ed.,Reading, Mass.: Addison-Wesley, 1977,93-97.

2. Foss, Christopher. Artillery of the World, New York: Scribner, 1976, 140.3. Thomas, W. E. and D. A. Grouws. Projectile Motion. School Science and Mathemat-

ics, April, 1984,320-366.4. The Astronomical Almanac for the Year, U.S. Naval Observatory, Washington D.C.

Whitney Harris

Queensborough Community CollegeBayside, New York 11364

Solar Undercut

The potential energy savings that solar heating and cooling of buildings couldprovide is also undercut by the inherent inefficiency of our common housingforms. Without solar and with a more severe climate, Sweden requires approxi-mately 50 percent less energy use per capita than the United States. There aremany ways that we could greatly reduce the energy demands of new housing. Un-less community-scale issues are addressed comprehensively, solar could becomea kind of chemotherapy for irrational development.

School Science and MathematicsVolume 85 (6) October 1985