Programming Challenge: a classic trigonometry problem
|
01-04-2014, 04:19 PM
Post: #9
|
|||
|
|||
RE: Programming Challenge: a classic trigonometry problem
(01-04-2014 01:23 PM)Bunuel66 Wrote: Sorry to join a bit later...Better late than never! Quote:1) BC=15(B+C)Compare this to: (B=u, C=v) (01-01-2014 08:44 AM)Thomas Klemm Wrote: \[ From here we can take different roads. One is using Newton's algorithm. I won't go into details here but leave a solution written in Python: Code:
As expected the convergence is quadratic: u = 35.0000000000000 v = 25.0000000000000 u = 36.6702279202279 v = 25.3383190883191 u = 36.6659267952683 v = 25.3848840365818 u = 36.6659934976999 v = 25.3849380375812 u = 36.6659934977741 v = 25.3849380377187 x = 15.9876490085686 Yet another approach is to use a fixed-point equation. From the 2nd equation we extract \(u=f(v)\) and from the 1st \(v=g(u)\) . This leaves us with: \(u=f(g(u))\). For the 1st equation we can use the WP-34S with the || operator to find: \(-\frac{1}{v}=-\frac{1}{c}+\frac{1}{u} \) Thus assuming \(-c\) = -15 is stored in register 00 we can use: 001 RCL 00 002 || From the 2nd equation we conclude \(u^2 = v^2 + 700\) where we can use →POL to solve for \(u\). The constant \(\sqrt{700}\) has to be stored in register 01 beforehand: 003 RCL 01 004 →POL These four steps are the core that is needed to solve for \(u\). We iterate these steps until the value doesn't change: 36.6659934978 And now we can calculate \(x=\sqrt{a^2-u^2}\): 15.9876490086 For this last step trigonometric functions can be used if everything is scaled so that \(a=1\). Initialization:
Program: 001 RCL X 002 RCL 00 003 || 004 RCL 01 005 →POL 006 x≠? Z 007 BACK 006 008 ACOS 009 SIN 010 RCL× 02 011 END You can use any value as initial guess though a good starting point will be 0.9. Cheers Thomas PS: Anybody noticed that this construction can be used as a calculator for parallel resistors? |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)