I am a relatively new HP calculator user. I own the 50g and just got
my 35s in the mail.
I have been RTFM about the solver and playing with it. Here is my
question:
I enter the quadratic equation to be solved using the 'EQN' button.
I then hit 'SOLVE' and then enter the variable to solve for (T in
this case)
But it only gives me one of the answers...
The FM says something about test points, but I dont want to do test
points (at the moment). I just want to get the two answers from the
quadratic formula
I know the HP 50g can do this.
What is the best way to get the two solutions from the quadratic
formula?
Thank you!
P.S. I just found this forum, I had been using the museum forum for
the HP 50g. I hope its OK for 35s questions here, I have seen a few
already
Assuming that the 35s works like the 32sII or 33s you can store a start
value in the variable you want to solve for.
Roman
PS: Another -maybe more elegant- solution would be to key in a program
to solve quadratic equations, of course.
Gene: Read the learning modules for the 35s dealing with the formula
solver and polynomials.
They can be found on the 35s page at www.hp.com/calculators.
> I enter the quadratic equation to be solved using the 'EQN' button.
> I then hit 'SOLVE' and then enter the variable to solve for (T in
> this case)
> But it only gives me one of the answers...
Yes, of course. It's a numeric approximation, i.e. you give it two
starting points (a very rough guess of the interval where the solution
can be expected) and the solver looks for a solution on this interval.
That's how any algorithm of this kind works.
> The FM says something about test points, but I dont want to do test
> points (at the moment).
Then the solver definitely is the wrong way to go.
No input => no output.
> I just want to get the two answers from the
> quadratic formula
Use two different starting points and you get what you want.
Example:
x^2 - 2x - 3 = 0
Use a negative interval (e.g. 0 and -5) to get the solution x1 = -1
Use a positive interval (e.g. 0 and +5) to get the solution x2 = 3.
> I know the HP 50g can do this.
*You* can do this as well. <8)
> What is the best way to get the two solutions from the quadratic
> formula?
As usual: write a program that gives the direct solution for this case.
You know, this formula for solving x^2 + px + q, where the two solutions
x1 and x2 are x1,2 = (-p/2) + or - sqrt((p/2)^2 - q). Programming this
formula can be done in two minutes - simple and direct.
Dieter
It took considerably longer (more like 10 minutes!) to do program for the 33s,
since it didn't have complex number support. The two lines was useful,
though: I wrote a quadratic solver that would display either "REAL ROOTS" and
leave them in Y and X, or "COMPLEX ROOTS" and leave the real part in Y and the
imaginary part in X (since of course the other solution is the complex
conjugate, no need to "calculate" it).
---Joel
> It took considerably longer (more like 10 minutes!) to do program for the 33s,
> since it didn't have complex number support.
I just did it on a HP-41. No complex support either, but that's no major
problem here. Okay, it took 3 minutes, including the complex solution.
<8)
Just check if the term under the square root (let's call it d) is
negative. If it is, the solution is simply -p/2 +/- sqrt(-d)*i.
Otherwise there are two real solutions (or one, if d = 0).
> The two lines was useful, though:
> I wrote a quadratic solver that would display either "REAL ROOTS" and
> leave them in Y and X, or "COMPLEX ROOTS" and leave the real part in Y and the
> imaginary part in X (since of course the other solution is the complex
> conjugate, no need to "calculate" it).
I see you got the idea. 8-)
Dieter
Just remember, in the two real roots case, to enhance the accuracy,
compute the first real root with the discriminant having the same sign
as -b and the second root from the first and c/a.
In RPN mode, you can use the following program:
Q001 LBL Q
Q002 ENTER
Q003 R^
Q004 /
Q005 LASTx
Q006 R^
Q007 x<>y
Q008 2
Q009 *
Q010 /
Q011 +/-
Q012 ENTER
Q013 ENTER
Q014 x^2
Q015 R^
Q016 -
Q017 0.5i0
Q018 y^x
Q019 -
Q020 x<>y
Q021 LASTx
Q022 +
Q023 RTN
If complex roots are not needed lines replace lines Q017 and Q018 with
Q017 |/x
Usage:
a ENTER b ENTER c XEQ Q ENTER --> x1
x2
Ex.:
1 ENTER 5 +/- ENTER 6 XEQ Q ENTER --> 2i0
3i0
Regards,
Gerson.
Hi Gerson,
I used to use similar program just slightly different output - for
practical reasons (in surveying) - no complex roots ;)
At program end in X register is the number of real solutions - 0, 1 or
2 and above - the root(s) themselves (if any)
Q001 LBL Q
Q002 ENTER
Q003 R^
Q004 /
Q005 LASTx
Q006 R^
Q007 x<>y
Q008 2
Q009 *
Q010 /
Q011 +/-
Q012 ENTER
Q013 ENTER
Q014 x^2
Q015 R^
Q016 - ;;; all the same up to here
Q017 X>0?
Q018 GTO Q026
Q019 X=0?
Q020 GTO Q023
Q021 CLSTK ;;; no real root
Q022 RTN
Q023 CLx
Q024 1 ;;; discriminant = 0, 1 root
Q025 RTN
Q026 SQRT
Q027 +
Q028 X<>Y
Q029 LASTx
Q030 -
Q031 2 ;;; 2 roots
Q032 RTN
Cheers,
reth
Hi Reth,
Thanks for posting your interesting program. I also found the
convergence of the first 16 steps especially interesting.
The program I presented is neither the shortest nor the most accurate
one, as you can see here:
http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/archv017.cgi?read=114345
The line-addressing feature in the HP-35s allows for shorter programs,
although program size is not a problem anymore :-)
Cheers,
Gerson.
Hi Gerson,
I dont't remember where I got the first 16 lines, it was long ago -
the HP-41 times :). Here I only wanted to point out the "flagged"
output witch comes handy where further branching of the calling
program depends on the number of roots found. For example - the 2
missing bearings problem for traverse closure or solving vertical
curve.
Best regards,
reth
It appears that many of you are well versed in programming. I however
am not, I have never programmed and am not a C.S. major.
I did manage to program this into my 50g, and that was quite easy. I
simply put in the two equations for the two solutions and I get two
answers on the stack.
But programming this 35s appears to be much harder... I have tried to
follow the program to understand it (not just input it and use it).
My first question is - What is R^ that I see on line 3? What purpose
does that do in the program?
R^ is roll up the stack, right-shifted key 2.2 whose primary function
is Rv - roll down the stack
T: 4
Z: 3
Y: 2
X: 1
after R^ becomes
T: 3
Z: 2
Y: 1
X: 3
cheers
oops, make that
T: 3
Z: 2
Y: 1
X: 4
;)
>
> It appears that many of you are well versed in programming. I however
> am not, I have never programmed and am not a C.S. major.
You don't need to be a C.S. major to program the 35s or even the 50g.
Reading chapter 13 in the 35s manual might help a bit. In order to
underdand RPN programs you should read the chapter 2. If your prefer
ALG mode, then you might want to write an ALG version of the program.
You can use either the traditional quadratic formula or this one:
http://www.enterhp.com/images/quadratic_eq-512.jpg
> But programming this 35s appears to be much harder... I have tried to
> follow the program to understand it (not just input it and use it).
> My first question is - What is R^ that I see on line 3? What purpose
> does that do in the program?
R^ is the Roll Up key (page 2-4), (blue shift and Rv). Rv stands for
the Roll Down key (page 2-3).
The manual seems to be clear enough. Anyway, you can find more
examples here:
http://www.hpmuseum.org/rpn.htm#learn
Regards,
Gerson.
I thought the R^ was an exponent or something like that. But it makes
sense that it is a roll button.
Thanks everybody
> I did manage to program this into my 50g
All HP48G/49G/50G:
'X^2-5*X+6' 'X' -1 CF QUAD
[ 1 -5 6 ] PROOT
.
It doesn't have to be. You can just store the coefficients into variables and
compute an equation, as you did on the 50g. In fact, beginning with the 33s
where effectively you're never going to run out of memory, I started writing a
lot of my programs that way. They're definitely easier for someone else to
understand, and they don't have to keep track of what's happening on the stack
either mentally or on a sheet of paper.
The "keyboard programming"-type solutions you see here are appealing from a
certain nostalgic point of view (this was all you had back on the
15c/32s/etc.) -- they tend to minimize program space requirements and execute
more quickly than the "direct" equation-based approach. Hence those of us who
have been using HP calculators for awhile enjoy playing around with them. :-)