15c SOLVE question on usage - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: General Forum (/forum-4.html) +--- Thread: 15c SOLVE question on usage (/thread-1212.html) |
15c SOLVE question on usage - lemontea - 05-01-2014 02:24 AM Hello everyone! I have a 15c (the LE reissued one; woot!). I have a newbie question on SOLVE (yes, I have not used this function in all these decades). User guides talk about solving for roots, but that's not what I want to do. Can I enter an equation, say Ohm's Law, and have it solve for the 3rd unknown, if I have 2 of the 3 variables? As you know, Ohm's Law is E = I * R where E = voltage, I = current in amps, R = resistance in ohms So, can I write an equation in programming, such as (I* R) - E = 0 (or however one should program it in) and use SOLVE to find the unknown? If so how? Thanks! RE: 15c SOLVE question on usage - Tugdual - 05-01-2014 02:40 AM You could use a trick using the I (index) register to define which of the 3 variables E,R,I is unknown (the 2 others should be known). But that looks a bit over engineered in my opinion. RE: 15c SOLVE question on usage - lemontea - 05-01-2014 02:50 AM (05-01-2014 02:40 AM)Tugdual Wrote: You could use a trick using the I (index) register to define which of the 3 variables E,R,I is unknown (the 2 others should be known). But that looks a bit over engineered in my opinion. I thought about that but it would just be a regular program and won't use the SOLVE function. If the SOLVE function can't do it easily, then I guess I will have to just resort to regular programming, but it seems like a hassle just for short equations. I thought if SOLVE can help with that then it is OK to program short equations (a few lines). To have program branching, etc. is a bit of a hassle (especially since the calculator does not use a full fledged programming language); I can standardize X Y Z registers as the variables (e.g., X is always voltage) and test to see which is a 0 value, and compute for that. But this is not really what I was hoping for, unless SOLVE doesn't work this way. RE: 15c SOLVE question on usage - Thomas Klemm - 05-01-2014 02:53 AM (05-01-2014 02:24 AM)lemontea Wrote: So, can I write an equation in programming, such as cf. TECHNIQUE: 'SOLVE' AND 'INTEG' WITH "MISO" USER FUNCTIONS ON THE 34C/15C/41C Code: LBL A Example: <I> STO 0 <E> STO 2 1 STO I SOLVE A HTH Thomas RE: 15c SOLVE question on usage - lemontea - 05-01-2014 03:06 AM Thanks! That helps a lot. BUT I don't understand this bit: (examples as per that web page; deleted non-15c information here) Quote:EXAMPLE: Why did the example have to enter the last 2 values before executing SOLVE? (the 0.5 and the 5; and then later the 0.5 and 6). Quote:0.5 RE: 15c SOLVE question on usage - Thomas Klemm - 05-01-2014 03:14 AM (05-01-2014 03:06 AM)lemontea Wrote: Why did the example have to enter the last 2 values before executing SOLVE? (the 0.5 and the 5; and then later the 0.5 and 6).These are initial values for SOLVE. RE: 15c SOLVE question on usage - Thomas Klemm - 05-01-2014 03:59 AM (05-01-2014 02:40 AM)Tugdual Wrote: But that looks a bit over engineered in my opinion. cf. EE calculations, some not obvious RE: 15c SOLVE question on usage - Jeff_Kearns - 05-01-2014 07:18 PM (05-01-2014 03:14 AM)Thomas Klemm Wrote:(05-01-2014 03:06 AM)lemontea Wrote: Why did the example have to enter the last 2 values before executing SOLVE? (the 0.5 and the 5; and then later the 0.5 and 6).These are initial values for SOLVE. These particular examples do not require initial guesses. The program will still work without them. Initial guesses are usually only required when seeking more than one root, such as in a quadratic equation. As far as I am concerned, Karl Schneider's MISO technique, which essentially makes the 15C and 34C (as well as the 41C/Advantage) solver work just like that of the Pioneers, is one of the most useful tricks I have come across. I used it in adapting a TVM program for the 15C (Accurate TVM for HP-15C). It is only 40 lines long (in it's current form), uses a single label, and is an order of magnitude easier to use compared to the 108 line program in the Advanced Functions Handbook which uses 10 labels. I credit this program, in part to the Indirect addressing 'trick' discussed in this thread. Jeff K RE: 15c SOLVE question on usage - Visu - 05-02-2014 07:41 AM SOLVE might not be that efficient for such simple equations. Because it uses Newton's alogrithm, and to make it is effecient you may want to enter two approximations of the result, you're better off creating 3 small routines in A, B C where LBL A E = I*R, LBL B R = E/I, ... you get the picture. Now if you're talking of more complex esuqtions, including powers, trigs or logs, then SOLVE is really a good tool. Enoy your 15C ! RE: 15c SOLVE question on usage - lemontea - 05-02-2014 09:11 AM Ok thanks; good to know. RE: 15c SOLVE question on usage - Thomas Klemm - 05-02-2014 11:31 AM (05-02-2014 07:41 AM)Visu Wrote: SOLVE might not be that efficient for such simple equations.With the following entries the function is executed only 3 times: 0.0012 STO 0 3.8 STO 2 1 STO I 3,000 ENTER 4,000 SOLVE A 3,166.6667 Quote:Because it uses Newton's alogrithmYou can find a description of the algorithm in the paper Personal Calculator Has Key to Solve Any Equation f(x) = 0 by William M. Kahan. Cheers Thomas RE: 15c SOLVE question on usage - Visu - 05-02-2014 12:08 PM (05-02-2014 11:31 AM)Thomas Klemm Wrote:(05-02-2014 07:41 AM)Visu Wrote: SOLVE might not be that efficient for such simple equations.With the following entries the function is executed only 3 times: Agreed. My point was using of SOLVE for linear equations is like using a machine gun to kill a mosquito. Cheers Thibaut RE: 15c SOLVE question on usage - Jeff_Kearns - 05-02-2014 01:15 PM (05-02-2014 12:08 PM)Visu Wrote: My point was using of SOLVE for linear equations is like using a machine gun to kill a mosquito. Agreed - but how much more elegant can one get than's Thomas' 6-line suggestion? Code: LBL A STO (i) RCL 0 RCL* 1 RCL- 2 RTN Example: (I* R) - E = 0 <I> STO 0 <E> STO 2 1 STO I SOLVE A It is arguably, three linear equation with 3 variables. Jeff K RE: 15c SOLVE question on usage - Dieter - 05-02-2014 09:44 PM (05-01-2014 02:24 AM)lemontea Wrote: Can I enter an equation, say Ohm's Law, and have it solve for the 3rd unknown, if I have 2 of the 3 variables? Yes, I know, this is a 15C thread, but this example shows very nicely how elegantly this kind of problem is handled by newer calculators with equation solvers. For instance the 35s. Simply enter E = I x R as you write it down on paper and then solve for E, I or R. Since every variable appears only one, you do not even have to provide an initial guess - the 35s "knows" that I = E : R and R = E : I and returns the third value immediately after you have been prompted for the two others. Of course this also works with the other example: f(x, y, z) = 2x – ln y + 1/z: Code: 2*X - LN(Y) + 1/Z = 0 The results are returned immediately as the 35s knows that x = (ln y – 1/z)/2 resp. y = e2x + 1/z resp. z = 1/(ln y – 2x). Great, huh ?-) Dieter RE: 15c SOLVE question on usage - lemontea - 05-02-2014 09:48 PM Yup; that's when it's time to take out the other units and put the Voyager series temporarily to the side of the desk (away from drinks though!). RE: 15c SOLVE question on usage - Jeff_Kearns - 05-03-2014 01:18 AM (05-02-2014 09:44 PM)Dieter Wrote: Since every variable appears only once, you do not even have to provide an initial guess - the 35s "knows" that I = E : R and R = E : I and returns the third value immediately after you have been prompted for the two others. Using SOLVE on the 6-line HP-15C MISO code does not require initial guesses either. Just sayin'... (again). Jeff K RE: 15c SOLVE question on usage - Csaba Tizedes - 05-25-2014 09:32 PM (05-01-2014 03:06 AM)lemontea Wrote: That helps a lot. And another examples here (only in Hungarian, sry): HP15C Notes: Down to the Rabbit Hole This short paper describes how works and how to use SOLVE (i) on HP15C - with examples. Enjoy! --Csaba RE: 15c SOLVE question on usage - Gamo - 09-06-2017 05:59 AM Example of simple equation solver using SOLVE solve for X to the power of { 1 to 12 } 12X - 1000 = 0 Program: I'm using Label 0 for this example and Store 1 for exponents LBL 0 RCL 1 Y^x 12 x 1000 - RTN P/R Run the equation: 1 STO 1 f SOLVE then 0 ----> X=83.3333 2 STO 1 f SOLVE then 0 ----> X=9.1287 3 STO 1 f SOLVE then 0 ----> X=4.3679 . . . 12 STO 1 f SOLVE then 0 ----> X=1.4457 This is just the simple equation with simple program to use SOLVE feature. The STO and RCL is very useful feature to adapt to more complicate equation program. Gamo RE: 15c SOLVE question on usage - Dieter - 09-06-2017 11:17 AM (09-06-2017 05:59 AM)Gamo Wrote: solve for X to the power of { 1 to 12 } No, that's not the equation for your following example. You are solving 12 xn – 1000 = 0 where n = 1...12. (09-06-2017 05:59 AM)Gamo Wrote: Run the equation: Do not forget to provide two guesses for x. Since x must be > 1 you could try 1 [ENTER] 100 [SOLVE] 0. If you do not enter anything here the solver starts with the two values that happen to be in X and Y. That's certainly not a good idea! Dieter |