# HP Forums

Full Version: 15c SOLVE question on usage
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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!
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.
(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.
(05-01-2014 02:24 AM)lemontea Wrote: [ -> ]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?

cf. TECHNIQUE: 'SOLVE' AND 'INTEG' WITH "MISO" USER FUNCTIONS ON THE 34C/15C/41C

Code:
```LBL A STO (i) RCL 0 RCL* 1 RCL- 2 RTN```

Example:
<I> STO 0
<E> STO 2
1 STO I
SOLVE A

HTH
Thomas
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:

f(x, y, z) = 2*x - ln y + 1/z

x in R1; y in R2; z in R3

LBL A
STO (i)
RCL 1
2
*
RCL 2
LN
-
RCL 3
1/x
+
RTN

In RUN mode, solve for x such that f(x, y=15.1, z=5.3) = 0

15.1
STO 2
5.3
STO 3
1
STO I
0.5
ENTER
5
SOLVE A

Next, solve for y such that f(x=0.7, y, z=3.3) = 0

0.7
STO 1
3.3
STO 3
2
STO I
0.5
ENTER
6
SOLVE A

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
ENTER
5
SOLVE A
(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).

Quote:0.5
ENTER
5
SOLVE A
These are initial values for SOLVE.
(05-01-2014 02:40 AM)Tugdual Wrote: [ -> ]But that looks a bit over engineered in my opinion.

cf. EE calculations, some not obvious
(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
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.

Ok thanks; good to know.
(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 alogrithm
You 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
(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:

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 alogrithm
You 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

Agreed. My point was using of SOLVE for linear equations is like using a machine gun to kill a mosquito.

Cheers
Thibaut
(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
(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?
...
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?

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 SOLVE X Y? 15,1 R/S Z?  5,3 R/S X=  1,26300774927 SOLVE Y X?  0,7 R/S Z?  3,3 R/S Y=  5,49056026941```

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
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!).
(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
(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
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
(09-06-2017 05:59 AM)Gamo Wrote: [ -> ]solve for X to the power of { 1 to 12 }

12X - 1000 = 0

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:
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

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
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :