Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

HP 35s Quadratic Formula

1,060 views
Skip to first unread message

KitusFa...@gmail.com

unread,
Jul 27, 2007, 2:55:46 AM7/27/07
to
Hello,

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

Roman Hartmann

unread,
Jul 27, 2007, 6:53:51 AM7/27/07
to

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

unread,
Jul 27, 2007, 9:29:47 AM7/27/07
to
On Jul 27, 1:55 am, "KitusFanati...@gmail.com"

<KitusFanati...@gmail.com> wrote:
> Hello,
>
> 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:
> What is the best way to get the two solutions from the quadratic
> formula?


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.


Dieter

unread,
Jul 27, 2007, 2:32:16 PM7/27/07
to
KitusFa...@gmail.com wrote:

> 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

Joel Kolstad

unread,
Jul 27, 2007, 3:16:11 PM7/27/07
to
"Dieter" <didis....@web.de> wrote in message
news:ukdka39k91noor42p...@4ax.com...

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

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


Dieter

unread,
Jul 27, 2007, 3:36:57 PM7/27/07
to
Joel Kolstad wrote:

> 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

mjc

unread,
Jul 27, 2007, 7:09:27 PM7/27/07
to

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.

GWB

unread,
Jul 27, 2007, 10:41:28 PM7/27/07
to
On Jul 27, 3:55 am, "KitusFanati...@gmail.com"

<KitusFanati...@gmail.com> wrote:
>
> What is the best way to get the two solutions from the quadratic
> formula?
>

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.


reth

unread,
Jul 28, 2007, 4:46:47 AM7/28/07
to

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

GWB

unread,
Jul 28, 2007, 12:50:26 PM7/28/07
to
> reth- Hide quoted text -
>
> - Show quoted text -

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.

reth

unread,
Jul 28, 2007, 4:37:52 PM7/28/07
to
> http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/archv017.cgi?read=11...

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

KitusFa...@gmail.com

unread,
Jul 28, 2007, 6:54:01 PM7/28/07
to
Thank you for all the responses!

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?

reth

unread,
Jul 28, 2007, 10:20:18 PM7/28/07
to
On Jul 29, 8:54 am, "KitusFanati...@gmail.com"

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

reth

unread,
Jul 28, 2007, 10:21:44 PM7/28/07
to

oops, make that


T: 3
Z: 2
Y: 1

X: 4

;)

GWB

unread,
Jul 28, 2007, 10:52:26 PM7/28/07
to
Hi,

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

KitusFa...@gmail.com

unread,
Jul 28, 2007, 11:33:00 PM7/28/07
to
Alright I got it!

I thought the R^ was an exponent or something like that. But it makes
sense that it is a roll button.

Thanks everybody

John H Meyers

unread,
Jul 29, 2007, 5:35:38 AM7/29/07
to
On Sat, 28 Jul 2007 17:54:01 -0500:

> 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

.

Joel Kolstad

unread,
Jul 30, 2007, 12:37:53 PM7/30/07
to
<KitusFa...@gmail.com> wrote in message
news:1185663241....@i13g2000prf.googlegroups.com...

> But programming this 35s appears to be much harder...

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


jer...@straubsurveying.com

unread,
Mar 3, 2018, 5:39:37 PM3/3/18
to
what are the key strokes to get: greater than 0? as in Q017 X>0?

Joe Horn

unread,
Mar 4, 2018, 3:08:20 AM3/4/18
to
> what are the key strokes to get: greater than 0? as in Q017 X>0?

If you're talking about the HP 35s, it's blue-shift MODE 4.
See the blue "X?0" printed on the front of the MODE key? That means that all the x-to-zero comparison commands are accessed by pressing blue-shift MODE.

-Joe-
0 new messages