(12C) SIN COS TAN
|
12-23-2023, 05:24 AM
(This post was last modified: 05-31-2024 12:51 AM by Gamo.)
Post: #1
|
|||
|
|||
(12C) SIN COS TAN
When you need to use the SIN COS TAN with your HP-12C
This program is not meant to be super accurate it is good enough at 4 decimal digits with the recommended angle between 0º - 45º Usage: Input angle [R/S] display answer for TAN For SIN [RCL] 1 For COS [RCL] 2 Program: RPN Quote: Gamo 12/23/2023 |
|||
12-23-2023, 10:01 AM
(This post was last modified: 12-23-2023 10:03 AM by Gamo.)
Post: #2
|
|||
|
|||
RE: (12C) SIN COS TAN
Example Problem.
John wants to measure the height of a tree. He walk exactly 100 feet from the base of the tree and look up. The angle from the ground to the top of the tree is 33º To the nearest foot, how tall is the tree? Formular for this problem is TAN(33º) = X / 100 100[ TAN(33º) ] = X Using this program: 33 [R/S] display 0.6494 100 [x] display answer 64.9402 ≈ 65 feet The tree is 65 feet tall. Gamo. |
|||
12-23-2023, 12:00 PM
Post: #3
|
|||
|
|||
RE: (12C) SIN COS TAN
I've used the Code Analyzer for HP Calculators with the following Python program:
Code: def sin_cos_tan(x): This is mostly a verbatim translation of your program. Make sure to import the sympy library block before running it. We can then use the series function to compare the trigonometric functions with their approximations: Code: from sympy import series, sin, cos, tan This results in the following output: \frac{x \left(-7 + \frac{10}{\frac{x^{2}}{20} + 1}\right)}{3} x - \frac{x^{3}}{6} + \frac{x^{5}}{120} - \frac{x^{7}}{2400} + \frac{x^{9}}{48000} + O\left(x^{11}\right) x - \frac{x^{3}}{6} + \frac{x^{5}}{120} - \frac{x^{7}}{5040} + \frac{x^{9}}{362880} + O\left(x^{11}\right) - \frac{x^{2} \left(-3 + \frac{5}{\frac{x^{2}}{30} + 1}\right)}{4} + 1 1 - \frac{x^{2}}{2} + \frac{x^{4}}{24} - \frac{x^{6}}{720} + \frac{x^{8}}{21600} - \frac{x^{10}}{648000} + O\left(x^{11}\right) 1 - \frac{x^{2}}{2} + \frac{x^{4}}{24} - \frac{x^{6}}{720} + \frac{x^{8}}{40320} - \frac{x^{10}}{3628800} + O\left(x^{11}\right) \frac{x \left(-7 + \frac{10}{\frac{x^{2}}{20} + 1}\right)}{3 \left(- \frac{x^{2} \left(-3 + \frac{5}{\frac{x^{2}}{30} + 1}\right)}{4} + 1\right)} x + \frac{x^{3}}{3} + \frac{2 x^{5}}{15} + \frac{43 x^{7}}{800} + \frac{3133 x^{9}}{144000} + O\left(x^{10}\right) x + \frac{x^{3}}{3} + \frac{2 x^{5}}{15} + \frac{17 x^{7}}{315} + \frac{62 x^{9}}{2835} + O\left(x^{11}\right) Sine Formula \[ s(x) = \frac{x \left(-7 + \frac{10}{\frac{x^{2}}{20} + 1}\right)}{3} \] Taylor Series \[ s(x) = x - \frac{x^{3}}{6} + \frac{x^{5}}{120} - \frac{x^{7}}{2400} + \frac{x^{9}}{48000} + O\left(x^{11}\right) \] \[ \sin(x) = x - \frac{x^{3}}{6} + \frac{x^{5}}{120} - \frac{x^{7}}{5040} + \frac{x^{9}}{362880} + O\left(x^{11}\right) \] Cosine Formula \[ c(x) = - \frac{x^{2} \left(-3 + \frac{5}{\frac{x^{2}}{30} + 1}\right)}{4} + 1 \] Taylor Series \[ c(x) = 1 - \frac{x^{2}}{2} + \frac{x^{4}}{24} - \frac{x^{6}}{720} + \frac{x^{8}}{21600} - \frac{x^{10}}{648000} + O\left(x^{11}\right) \] \[ \cos(x) = 1 - \frac{x^{2}}{2} + \frac{x^{4}}{24} - \frac{x^{6}}{720} + \frac{x^{8}}{40320} - \frac{x^{10}}{3628800} + O\left(x^{11}\right) \] Tangent Formula \[ t(x) = \frac{x \left(-7 + \frac{10}{\frac{x^{2}}{20} + 1}\right)}{3 \left(- \frac{x^{2} \left(-3 + \frac{5}{\frac{x^{2}}{30} + 1}\right)}{4} + 1\right)} \] Taylor Series \[ t(x) = x + \frac{x^{3}}{3} + \frac{2 x^{5}}{15} + \frac{43 x^{7}}{800} + \frac{3133 x^{9}}{144000} + O\left(x^{11}\right) \] \[ \tan(x) = x + \frac{x^{3}}{3} + \frac{2 x^{5}}{15} + \frac{17 x^{7}}{315} + \frac{62 x^{9}}{2835} + O\left(x^{11}\right) \] These are very good approximations. How did you come up with these? Somewhat related are Bhaskara's Sine and Cosine Approximations. |
|||
12-23-2023, 02:21 PM
Post: #4
|
|||
|
|||
RE: (12C) SIN COS TAN
From here we can go full circle and use the Python to RPN - source code converter with the following programs:
Code: def s(x): Code: def c(x): This generates the following programs for the HP-42S: Code: LBL "s" Code: LBL "c" We can combine them into a single program: Code: 00 { 59-Byte Prgm } I know that the degrees to radians transformation is missing, but this is left as an exercise. Example: 0.5 XEQ "SCT" 0.546301 RCL 01 0.479424 RCL 02 0.877583 |
|||
12-23-2023, 03:30 PM
(This post was last modified: 12-23-2023 06:36 PM by Albert Chan.)
Post: #5
|
|||
|
|||
RE: (12C) SIN COS TAN
sin(x) = x - x^3/3! + x^5/5! - x^7/7! + ... = x * (1 - x²/6 / (1 + x²/20)) + O(x^7)
\(\displaystyle s(x) = x \left( 1-\frac{20}{6}\left(\frac{\frac{x^2}{20}}{1+\frac{x^2}{20}} \right) \right) = \frac{x}{3} \left( 3-10\left(1 - \frac{1}{1+\frac{x^2}{20}} \right) \right) = \frac{x}{3} \left(-7 + \frac{10}{1+\frac{x^{2}}{20}}\right) \) cos(x) = 1 - x^2/2! + x^4/4! - x^6/6! + ... = 1 - x²/2 * (1 - x²/12 / (1 + x²/30)) + O(x^8) \(\displaystyle c(x) = 1 - \frac{x^2}{2} \left(1 - \frac{30}{12} \left(\frac{\frac{x^2}{30}}{1+\frac{x^2}{30}} \right)\right) = 1 - \frac{x^2}{4} \left(2 - 5 \left(1 - \frac{1}{1+\frac{x^2}{30}} \right)\right) = 1 - \frac{x^2}{4} \left(-3 + \frac{5}{1+\frac{x^2}{30}} \right) \) We may also reuse code: versin(x) = 1 - cos(x) = 2*sin(x/2)^2 \(\cos(x) ≈ 1 - 2\, s(\frac{x}{2})^2 \) |
|||
12-23-2023, 05:54 PM
Post: #6
|
|||
|
|||
RE: (12C) SIN COS TAN
I always appreciate your answers but I'm often reminded of this old meme:
|
|||
06-09-2024, 07:29 AM
Post: #7
|
|||
|
|||
RE: (12C) SIN COS TAN
Program Update from Post #1
This update make it easier to run the SIN COS TAN routine. Procedure: FIX 4 For first use store ¶ to register R1 and 180 to register R2 355 [ENTER] 113 [÷] [STO] 1 180 [STO] 2 ------------------------------------------------------------- To run [SIN] Make sure to run from beginning of program line by Pressing [f] [PRGM] SIN(x) [R/S] display answer Continue same problem no need to start from beginning again. ------------------------------------------------------------- To run [COS] [GTO] 25 COS(x) [R/S] display answer Continue same problem no need to use GTO 25 again ------------------------------------------------------------- To run [TAN] [GTO] 53 TAN(x) [R/S] display answer Continue same problem no need to use GTO 53 again ------------------------------------------------------------- Example: SIN(15) + SIN(25) [f] [PRGM] 15 [R/S] display 0.2588 25 [R/S] display 0.4226 [+] display answer 0.6814 COS(40) - TAN(10) [GTO] 25 40 [R/S] display 0.7660 [GTO] 53 10 [R/S] display 0.1763 [-] display answer 0.5897 ----------------------------------------------------------- Program: Quote:01 RCL 1 Gamo |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)