f



HP35s - solving functions in user programs

Hi all,

the HP-35s offers the well-known HP Solve function which can be used
with equations (solving for one of several variables) as well as with
user-programmed routines. In this case Solve returns a zero of this
programmed function.

In the days of the good old HP-34C (first model offering HP Solve and
Integrate) Solve could be used for any program, even complex ones with
loops and iterations. Also Solve and Integrate could be combined, which
is no longer possible today. While this limitation is well documented, I
wonder why the HP-35s cannot solve certain user routines just as the 34C
did - the calculator seems to get stuck in an endless loop, sometimes
ending in a final "NO ROOT FND".

Example:

x * (1/3 + 1/2 + 1/1) - 2  =  0
Solution is x = 12/11 = 1.0909...

Direct method:

R001 LBL R
R002 3
R003 1/x
R004 2
R005 1/x
R006 +
R007 1
R008 1/x
R009 +
R010 RCL X
R011 *
R012 2
R013 -
R014 RTN

FN= R          ; solve the function at label R
0  STO X  2    ; provide two initial guesses
SOLVE X

=> SOLVING
   X= 1.0909   ; Solve returns correct result


Okay, that was easy.
Now try the same function with a loop inside:


R001 LBL R
R002 3
R003 STO A
R004 0
R005 RCL A
R006 1/x
R007 +
R008 DSE A      ; A := A-1, still > 0 ?
R009 GTO R005
R010 RCL X
R011 *
R012 2
R013 -
R014 RTN

FN= R          ; solve the function at label R
0  STO X  2    ; provide two initial guesses
SOLVE X

=> SOLVING ...

The 35s gets stuck in an infinite loop. After a few minutes of staring
at the display, pressing C cancels the process.

Question: what happens here? There seems to be an issue either with
backward jumps and/or changes of variables inside the user routine.
What *exactly* is the problem here? Is this behavior documented
somewhere? The manual didn't provide any hints.

Dieter

0
Dieter
7/31/2008 5:48:36 PM
comp.sys.hp48 9763 articles. 3 followers. fbarbaise (60) is leader. Post Follow

8 Replies
649 Views

Similar Articles

[PageSpeed] 28

On Jul 31, 1:48=A0pm, Dieter <didis.mehl...@web.de> wrote:
> Hi all,
> Now try the same function with a loop inside:
>
> R001 LBL R
> R002 3
> R003 STO A
> R004 0
> R005 RCL A
> R006 1/x
> R007 +
> R008 DSE A =A0 =A0 =A0; A :=3D A-1, still > 0 ?
> R009 GTO R005
> R010 RCL X
> R011 *
> R012 2
> R013 -
> R014 RTN
>
> FN=3D R =A0 =A0 =A0 =A0 =A0; solve the function at label R
> 0 =A0STO X =A02 =A0 =A0; provide two initial guesses
> SOLVE X
>
> =3D> SOLVING ...
>
> The 35s gets stuck in an infinite loop.

I don't have an HP35s, but my 32SII uses much the same programming,
and your program worked okay for me, returning 1.0909.  One difference
is that the 32 doesn't allow jumping to line numbers, only LBLs, so I
had to insert LBL B ahead of R005 and replace R009 with GTO B.

Maybe it's something unique to the 35s.

Bill
0
Bill
8/8/2008 2:15:38 PM
On 31 jul, 19:48, Dieter <didis.mehl...@web.de> wrote:
> Hi all,
>
> the HP-35s offers the well-known HP Solve function which can be used
> with equations (solving for one of several variables) as well as with
> user-programmed routines. In this case Solve returns a zero of this
> programmed function.
>
> In the days of the good old HP-34C (first model offering HP Solve and
> Integrate) Solve could be used for any program, even complex ones with
> loops and iterations. Also Solve and Integrate could be combined, which
> is no longer possible today. While this limitation is well documented, I
> wonder why the HP-35s cannot solve certain user routines just as the 34C
> did - the calculator seems to get stuck in an endless loop, sometimes
> ending in a final "NO ROOT FND".
>
> Example:
>
> x * (1/3 + 1/2 + 1/1) - 2 =A0=3D =A00
> Solution is x =3D 12/11 =3D 1.0909...
>
> Direct method:
>
> R001 LBL R
> R002 3
> R003 1/x
> R004 2
> R005 1/x
> R006 +
> R007 1
> R008 1/x
> R009 +
> R010 RCL X
> R011 *
> R012 2
> R013 -
> R014 RTN
>
> FN=3D R =A0 =A0 =A0 =A0 =A0; solve the function at label R
> 0 =A0STO X =A02 =A0 =A0; provide two initial guesses
> SOLVE X
>
> =3D> SOLVING
> =A0 =A0X=3D 1.0909 =A0 ; Solve returns correct result
>
> Okay, that was easy.
> Now try the same function with a loop inside:
>
> R001 LBL R
> R002 3
> R003 STO A
> R004 0
> R005 RCL A
> R006 1/x
> R007 +
> R008 DSE A =A0 =A0 =A0; A :=3D A-1, still > 0 ?
> R009 GTO R005
> R010 RCL X
> R011 *
> R012 2
> R013 -
> R014 RTN
>
> FN=3D R =A0 =A0 =A0 =A0 =A0; solve the function at label R
> 0 =A0STO X =A02 =A0 =A0; provide two initial guesses
> SOLVE X
>
> =3D> SOLVING ...
>
> The 35s gets stuck in an infinite loop. After a few minutes of staring
> at the display, pressing C cancels the process.
>
> Question: what happens here? There seems to be an issue either with
> backward jumps and/or changes of variables inside the user routine.
> What *exactly* is the problem here? Is this behavior documented
> somewhere? The manual didn't provide any hints.
>
> Dieter

Hello Dieter,

Have a look at
http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/articles.cgi?read=3D896
for a program that works.

Note that I have had my share of infinite loops while programming the
HP35s... (no fun)

Caspar
0
caslugt
8/8/2008 9:01:00 PM
On Jul 31, 10:48=A0am, Dieter <didis.mehl...@web.de> wrote:
> Hi all,
>
> the HP-35s offers the well-known HP Solve function which can be used
> with equations (solving for one of several variables) as well as with
> user-programmed routines. In this case Solve returns a zero of this
> programmed function.
>
> In the days of the good old HP-34C (first model offering HP Solve and
> Integrate) Solve could be used for any program, even complex ones with
> loops and iterations. Also Solve and Integrate could be combined, which
> is no longer possible today. While this limitation is well documented, I
> wonder why the HP-35s cannot solve certain user routines just as the 34C
> did - the calculator seems to get stuck in an endless loop, sometimes
> ending in a final "NO ROOT FND".
>
> Example:
>
> x * (1/3 + 1/2 + 1/1) - 2 =A0=3D =A00
> Solution is x =3D 12/11 =3D 1.0909...
>
> Direct method:
>
> R001 LBL R
> R002 3
> R003 1/x
> R004 2
> R005 1/x
> R006 +
> R007 1
> R008 1/x
> R009 +
> R010 RCL X
> R011 *
> R012 2
> R013 -
> R014 RTN
>
> FN=3D R =A0 =A0 =A0 =A0 =A0; solve the function at label R
> 0 =A0STO X =A02 =A0 =A0; provide two initial guesses
> SOLVE X
>
> =3D> SOLVING
> =A0 =A0X=3D 1.0909 =A0 ; Solve returns correct result
>
> Okay, that was easy.
> Now try the same function with a loop inside:
>
> R001 LBL R
> R002 3
> R003 STO A
> R004 0
> R005 RCL A
> R006 1/x
> R007 +
> R008 DSE A =A0 =A0 =A0; A :=3D A-1, still > 0 ?
> R009 GTO R005
> R010 RCL X
> R011 *
> R012 2
> R013 -
> R014 RTN
>
> FN=3D R =A0 =A0 =A0 =A0 =A0; solve the function at label R
> 0 =A0STO X =A02 =A0 =A0; provide two initial guesses
> SOLVE X
>
> =3D> SOLVING ...
>
> The 35s gets stuck in an infinite loop. After a few minutes of staring
> at the display, pressing C cancels the process.
>
> Question: what happens here? There seems to be an issue either with
> backward jumps and/or changes of variables inside the user routine.
> What *exactly* is the problem here? Is this behavior documented
> somewhere? The manual didn't provide any hints.
>
> Dieter

Have you tried stepping through the program?
0
cappy2112
8/9/2008 3:35:48 PM
cappy2112 wrote:

> [ I wrote ]
> ...
> > R001 LBL R
> > R002 3
> > R003 STO A
> > R004 0
> > R005 RCL A
> > R006 1/x
> > R007 +
> > R008 DSE A � � �; A := A-1, still > 0 ?
> > R009 GTO R005
> > R010 RCL X
> > R011 *
> > R012 2
> > R013 -
> > R014 RTN
> >
> > FN= R � � � � �; solve the function at label R
> > 0 �STO X �2 � �; provide two initial guesses
> > SOLVE X
> >
> > => SOLVING ...
> >
> > The 35s gets stuck in an infinite loop. After a few minutes of staring
> > at the display, pressing C cancels the process.

....

> Have you tried stepping through the program?

Yes, shure.
The *program* is perfectly okay and returns the expected values:

1 STO X
XEQ T => -0,1667

2 STO X
XEQ T =>  1,1667

12/11 STO X
XEQ T =>  0,0000

So, everything's fine so far.
As long as you don't start Solve. <8)

If Solve is interrupted and you try to SST trough the very same program,
weird things happen: the individual program steps appear as usual and it
looks as if they were exectued, but the stack does not change at all: it
shows the two initial guesses (RegT=1,  RegZ=2) and 2 in RegY and RegX.
Even the variable A in the example doesn't change its value altough it
should be decremented until it becomes zero (DSE A, line R008). I think
that's exactly the reason why the 35s gets stuck - the DSE-loop doesn't
terminate.

There seems to be  a problem with that variable A inside the loop. Some
more testing showed that the program actually stores *no value at all*
in A! I tried Pi STO A.  After starting Solve and waiting for a few
seconds (i.e. the routine should have overwritten A with the value 3 in
R002 at least once as the routine was executed for the first time)
a VIEW A still shows the old pre-solve value: A = 3,1416.

Completely confused -

Dieter

0
Dieter
8/11/2008 3:03:02 PM
Bill Markwick wrote

> I don't have an HP35s, but my 32SII uses much the same programming,
> and your program worked okay for me, returning 1.0909.

That's nice - but the 32S/SII and 35S are different in several ways. 8-)

> One difference
> is that the 32 doesn't allow jumping to line numbers, only LBLs, so I
> had to insert LBL B ahead of R005 and replace R009 with GTO B.

Tried that as well: replaced line-addressing by label-addressing.
Same result. See my other posts in this thread.

> Maybe it's something unique to the 35s.

Yes... "unique" - I think that's the word. <8)

Dieter

0
Dieter
8/11/2008 3:03:03 PM
caslugt@gmail.com wrote:

> Have a look at
> http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/articles.cgi?read=896
> for a program that works.

Yes, thank you. Reminds me of the good old days when I wrote similar
programs for my HP-41. <8)

Is there a special reason why you didn't use DSE or ISG where the
advantage would be obvious?

> Note that I have had my share of infinite loops while programming the
> HP35s... (no fun)

Must be another thread on hpmuseum.org - or were these problems not
discussed there? At the moment I only remember some guy who had problems
with programs that could not be interrrupted at all.

Dieter

0
Dieter
8/11/2008 3:03:04 PM
On 11 aug, 17:03, Dieter <didis.mehl...@web.de> wrote:
> Is there a special reason why you didn't use DSE or ISG where the
> advantage would be obvious?

Not really, I am not that familiar with the HP-35S yet, I will look
into it. Thanks.

> > Note that I have had my share of infinite loops while programming the
> > HP35s... (no fun)
>
> Must be another thread on hpmuseum.org - or were these problems not
> discussed there? At the moment I only remember some guy who had problems
> with programs that could not be interrrupted at all.

I had the same problem, the ON key or the R/S key did not work...
paperclip reset and all my hard work typing all these lines was lost
(a couple of times)... :-(

Caspar
0
caslugt
8/11/2008 7:35:26 PM
"Dieter" <didis.mehlbox@web.de> wrote in message 
news:urk0a4pmqv2fgg822pndt5uqt4e8p0eg2s@4ax.com...
> Completely confused -

The 35s has known bugs that are similar to this -- expressions that reference 
memory variables instead get values coming from the stack, for instance. 
(This is bug #15 at 
http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/articles.cgi?read=735 , and 
there was a forum discussion where some guy figured out exactly what gets 
substituted where during evaluation.)

HP has been informed of these problems and had shown zero public interest in 
fixing any of them. :-(

---Joel


0
Joel
8/18/2008 4:39:49 PM
Reply:

Similar Artilces:

Commercial Users of Functional Programming: program is published, registration is open
[posted on behalf of the organizers] Friends, The program for the 2007 Commercial Users of Functional Programming workshop is now published. http://cufp.galois.com/ The workshop is co-located with ICFP, and will be held in Freiburg, Germany, on 4 October 2007. We had a terrific response to our call for talks, and there are twelve (!) speakers describing commercial applications, variously written in Caml Erlang F# Haskell ML Scheme The talks are informal, and there are no proceedings. We'll just have fun learning about functional ...

Commercial Users of Functional Programming: program is published, registration is open #2
[posted on behalf of the organizers] Friends, The program for the 2007 Commercial Users of Functional Programming workshop is now published. http://cufp.galois.com/ The workshop is co-located with ICFP, and will be held in Freiburg, Germany, on 4 October 2007. We had a terrific response to our call for talks, and there are twelve (!) speakers describing commercial applications, variously written in Caml Erlang F# Haskell ML Scheme The talks are informal, and there are no proceedings. We'll just have fun learning about functional ...

Functions and functional programming.
Consider this. double foo( double (*callback_a)(), double (*callback_b)()) { double a, b; a = (*callback_a)(); b = (*callback_b)(); return a + b; } double bar( double (*callback_a)(), double (*callback_b)()) { double a, b; b = callback_b(); a = callback_a(); return a + b; } There's no way in C to guarantee that foo shall return the same value as bar, which is awful. How's the best way to enforce this property? Malcolm McLean <malcolm.mclean5@btinternet.com> writes: >There's no way in C to guarantee that foo shall re...

Can Your Programming Language Do This? Joel on functional programming and briefly on anonymous functions!
Can Your Programming Language Do This? Joel on functional programming and briefly on anonymous functions! http://www.joelonsoftware.com/items/2006/08/01.html -- Regards, Casey Casey Hawthorne wrote: > Can Your Programming Language Do This? And the answer is "yes, of course" !-) > Joel on functional programming and briefly on anonymous functions! > > http://www.joelonsoftware.com/items/2006/08/01.html > > -- > Regards, > Casey -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for ...

Commerical Users of Functional Programming Workshop 2005
[ Apologies for multiple postings; please forward to potentially interested parties ] CUFP 2005 THE SECOND COMMERCIAL USERS OF FUNCTIONAL PROGRAMMING WORKSHOP Talinn, Estonia September 24th 2005 Co-located with ICFP Functional languages have been under academic development for over 25 years, and are still proving to be very fertile ground for programming language research. Consequently, most of the development focus of these languages is driven by academic and theoretical questions. Mo...

Commercial Users of Functional Programming Workshop 2005
Apologies for multiple postings; please forward to potentially interested parties ] CUFP 2005 THE SECOND COMMERCIAL USERS OF FUNCTIONAL PROGRAMMING WORKSHOP Talinn, Estonia September 24th 2005 Co-located with ICFP Functional languages have been under academic development for over 25 years, and are still proving to be very fertile ground for programming language research. Consequently, most of the development focus of these languages is driven by academic and theoretical question...

Commercial Users of Functional Programming
Commercial Users of Functional Programming Workshop (CUFP) 2009 Functional Programming As a Means, Not an End Call for Presentations Sponsored by SIGPLAN Co-located with ICFP 2009 Edinburgh, Scotland, 4 September 2009 _________________________________________________________ Presentation proposals due 15 May 2009 http://cufp.galois.com/2009/call.html _________________________________________________________ Functional languages have been under academ...

CFP: Commercial Users of Functional Programming 2011
Commercial Users of Functional Programming Workshop (CUFP) 2011 Call for Presentations: http://cufp.org/2011-call-presentations Sponsored by SIGPLAN Co-located with ICFP 2011 Tokyo, Japan Sep 22-24 Proposal Submission Deadline 15 June 2011 Functional programming languages have been a hot topic of academic research for over 35 years, and they have seen an ever larger practical impact in settings ranging from tech startups to financial firms to biomedical research labs. At the same time, a vigorous community of programmers employing functional languages has come into existence. CUFP is desi...

CFP: Commercial Users of Functional Programming 2011
Commercial Users of Functional Programming Workshop (CUFP) 2011 Call for Presentations: http://cufp.org/2011-call-presentations Sponsored by SIGPLAN Co-located with ICFP 2011 Tokyo, Japan Sep 22-24 Proposal Submission Deadline 15 June 2011 Functional programming languages have been a hot topic of academic research for over 35 years, and they have seen an ever larger practical impact in settings ranging from tech startups to financial firms to biomedical research labs. At the same time, a vigorous community of programmers employing functional languages has come into existence. CUFP is desi...

Using the HMS functions in a user RPL program.
I would like to use the HMS functions available under the time menu in the HP49G+ in several programs I am writing in UserRPL. How would I reference those functions in my UserRPL program? What syntax would I use? It would be great if I could see one or two lines of code in an example of how to do this. Thanks, The Sunburned Surveyor sunburned.surveyor@gmail.com wrote: > I would like to use the HMS functions available under the time menu in > the HP49G+ in several programs I am writing in UserRPL. > > How would I reference those functions in my UserRPL program? What > synt...

Commercial Users of Functional Programming
Commercial Users of Functional Programming Workshop (CUFP) 2009 Functional Programming As a Means, Not an End Call for Presentations Sponsored by SIGPLAN Co-located with ICFP 2009 Edinburgh, Scotland, 4 September 2009 _________________________________________________________ Presentation proposals due 15 May 2009 http://cufp.galois.com/2009/call.html _________________________________________________________ Functional languages have ...

Commercial Users of Functional Programming
Commercial Users of Functional Programming Workshop (CUFP) 2009 Functional Programming As a Means, Not an End Call for Presentations Sponsored by SIGPLAN Co-located with ICFP 2009 Edinburgh, Scotland, 4 September 2009 _________________________________________________________ Presentation proposals due 15 May 2009 http://cufp.galois.com/2009/call.html _________________________________________________________ Functional languages have ...

CFP: Commercial Users of Functional Programming 2011
Commercial Users of Functional Programming Workshop (CUFP) 2011 Call for Presentations: http://cufp.org/2011-call-presentations Sponsored by SIGPLAN Co-located with ICFP 2011 Tokyo, Japan Sep 22-24 Proposal Submission Deadline 15 June 2011 Functional programming languages have been a hot topic of academic research for over 35 years, and they have seen an ever larger practical impact in settings ranging from tech startups to financial firms to biomedical research labs. At the same time, a vigorous community of programmers employing functional languages has come into existence. CUFP is desi...

Commercial Users of Functional Programming
Commercial Users of Functional Programming Workshop (CUFP) 2009 Functional Programming As a Means, Not an End Call for Presentations Sponsored by SIGPLAN Co-located with ICFP 2009 Edinburgh, Scotland, 4 September 2009 _________________________________________________________ Presentation proposals due 15 May 2009 http://cufp.galois.com/2009/call.html _________________________________________________________ Functional languages have been under academ...

CFP: Commercial Users of Functional Programming 2011
Commercial Users of Functional Programming Workshop (CUFP) 2011 Call for Presentations: http://cufp.org/2011-call-presentations Sponsored by SIGPLAN Co-located with ICFP 2011 Tokyo, Japan Sep 22-24 Proposal Submission Deadline 15 June 2011 Functional programming languages have been a hot topic of academic research for over 35 years, and they have seen an ever larger practical impact in settings ranging from tech startups to financial firms to biomedical research labs. At the same time, a vigorous community of programmers employing functional languages has come into existenc...

Web resources about - HP35s - solving functions in user programs - comp.sys.hp48

Talk:Trigonometric functions - Wikipedia, the free encyclopedia
This article is within the scope of WikiProject Mathematics , a collaborative effort to improve the coverage of Mathematics on Wikipedia. If ...

Standing desks may boost students’ cognitive function as well as health
(credit: Texas A&M University ) Standing desks—most often installed in efforts to improve physical activity and health—may help get your noggin ...

A Non-Sokratic Dialogue on Social Welfare Functions: Hoisted from the Archives from 2003
**[A Non-Sokratic Dialogue on Social Welfare Functions: Hoisted from the Archives from 2003](http://www.j-bradford-delong.net/movable_type/2 ...

Drop Point Knives: Function, Fit, Timeless
Drop Point Knives: Function, Fit, Timeless

Here's how squads and iron sights will function in Rising Storm 2: Vietnam
... roles and create a squad, and the creator can name, lock, or invite others to their little group. The more an outfit fills up, the more functions ...

Learning F# – The Thunderdome Principle for Functions
... One object enters, one object leaves! What I like about F# is that the language designers took a similar approach when they implemented functions. ...

Slim and Soft Cover-Ups: Protecting Your Laptop with Function and Style
I’m a klutz. My phone has the scars and cracks to prove it. Likewise, my laptop bears scratches and dents in the lid, from me banging it into ...

Using AWS Lambda functions to create print ready files
... going to tell you about our processing architecture as well as at a recent performance improvement with the integration of AWS Lambda functions. ...

Power Through Your Work With a “Forcing Function”
... to flow faster and more easily when I know I only have a couple of hours to turn it in. Entrepreneur Dan Martell calls this a “forcing function” ...

Macphun Creative Kit 2016 review: Critical photo editing functions delivered in one diverse app
With Creative Kit, Macphun wants to pick up where Apple’s now-defunct Aperture left off. As a plug-in to Photos , Macphun’s apps significantly ...

Resources last updated: 2/7/2016 12:08:24 PM