HP 42s solver question « Next Oldest | Next Newest »

 ▼ Mike Posting Freak Posts: 899 Threads: 193 Joined: Jan 2005 11-25-2002, 05:43 AM I have a simple program for the 42s that uses the solver to work out the value for the diameter of an object or area depending on what the user chooses (see below). What I would like to know, is there a way to also include the circumference while using the solver. For example if 7.3 was chosen for the "Dia" then if you pressed the key corresponding to "Area" it would work out 41.85 or if you pressed the key corresponding to "Circ" you would get 22.93. I'm not sure if this can be done but would be greatful if someone out there can help. Thanks Mike {41-Byte Prgm} LBL "Dia" MVAR "Dia" MVAR "Area" RCL "Dia" x2 PI X 4 / RCL- "Area" END ▼ Tom Sherman Member Posts: 95 Threads: 7 Joined: Jan 1970 11-25-2002, 10:02 AM Hi Mike, From your numerical examples, and from the appearance of PI in the solver expression, it appears that "object" refers specifically to spheres. Revisions are needed both in the calculation of area, and in the program listing, since area = PI x d^2, and the result for your calculation of area should be 167.42 rather than 41.85. There is a confusion here of diameter and radius -- you are not the first, I do it all the time! But for the interesting question of whether there is any way to incorporate diameter, area, and circumference in one solver program: I don't think so. I believe you would need two separate expressions for the solver to solve. And how about the volume as well? This is one of those cases where a BASIC program would serve much better. Greetings from the coast of Maine, Tom ▼ Tom Sherman Member Posts: 95 Threads: 7 Joined: Jan 1970 11-25-2002, 10:12 AM Mike, Forgive me. Your "object" is a circle, I guess, rather than a sphere. So your calculation is correct. Ignore all my rubbish except for the last paragraph. Tom ▼ Tom Sherman Member Posts: 95 Threads: 7 Joined: Jan 1970 11-25-2002, 01:06 PM If we wanted to write for the solver a single expression involving the three variables: diameter, area, and circumference (of a circle), we could do so. One example would be: ((PI*DIAM^2)/2)-AREA-((CIRC^2)/(4*PI))=0 which in effect says that twice the area minus the area minus the area equals nothing The problem is that because we have three variables in one expression, the solver will have to be given two of them in order to work. That would mean that if we started, for example, with the diameter, we would have to calculate the area separately to enable the solver to give us the circumference, or calculate the circumference separately in order to get the area. ▼ r. d. bärtschiger. Member Posts: 85 Threads: 8 Joined: Jan 1970 11-25-2002, 01:21 PM A question: Isn't the area of a circle; 'Pi * r^2' not 'Pi * d^2' ? and Cicumference 'Pi * d' ? rdb. ▼ Tom Sherman Member Posts: 95 Threads: 7 Joined: Jan 1970 11-25-2002, 02:08 PM Yes, my expression is confusing (unorthodox), but I think it is OK -- but goodness knows, I am capable of messing this up forever! The first term represents twice the area, expressed in terms of the diameter. The area is (PI*d^2)/4 (or PI*r^2), so twice the area is PI*d^2/2. The second term represents the area in terms of the area -- that one is difficult! The third term represents the area in terms of the circumference. Since the circumference is PI*d, the square of the circumference is (PI^2)*d^2, which needs to be divided by 4*PI to give the area -- which again is (PI*d^2)/4. So then if we take the first term and subtract the other two we get zero. Or is it the sound and the fury signifying nothing? Sorry about all this! Tom ▼ Mike Posting Freak Posts: 899 Threads: 193 Joined: Jan 2005 11-26-2002, 04:07 PM Thanks for your replies Tom, I will play around with your example. ▼ Tom Sherman Member Posts: 95 Threads: 7 Joined: Jan 1970 11-26-2002, 05:57 PM Mike, Don't play around with it too much! The expression is a curiosity, but totally impractical. Ordinarily, if we know any one of the three features of a circle -- diameter, area, circumference -- we can directly calculate the other two. That is, if we have one we can get two. But with my expression put in the solver, we need two to get one! Not much of a bargain. Much better would be a simple BASIC program. The following is written for an HP-71B: 10 DESTROY ALL @ FIX 2 @ DELAY 2 20 DISP "DIAM=1,AREA=2,CIRC=3" 30 DELAY 8 40 INPUT "START WITH 1,2,or 3?";N 50 IF N>1 THEN 100 60 INPUT "DIAMETER =";D 70 DISP "AREA =";PI*D*D/4 80 DISP "CIRCUMFERENCE =";PI*D 90 GOTO 200 100 IF N>2 THEN 160 110 INPUT "AREA =";A 120 D=SQR(4*A/PI) 130 DISP "DIAMETER =";D 140 DISP "CIRCUMFERENCE =";PI*D 150 GOTO 200 160 INPUT "CIRCUMFERENCE =";C 170 D=C/PI 180 DISP "DIAMETER =";D 190 DISP "AREA =";PI*D*D/4 200 END Tom ▼ Mike Posting Freak Posts: 899 Threads: 193 Joined: Jan 2005 11-27-2002, 03:50 PM Thanks Tom, I also have the hp71b so I will have a play with that as well and see if I can program that. I haven't used it before so for a bit of fun I will try to enter your program. Thanks Mike Werner Huysegoms Junior Member Posts: 44 Threads: 0 Joined: Jan 1970 11-28-2002, 03:18 AM Two ways to do it: 1. write the equation like ABS(Area - Dia^2*PI/4) + ABS(Circ - Dia*PI) = 0 It works with the solver, but you'll find an extremum of course 2. use the name of the variable you're solving for: (how do I get this to show as I typed it instead of all in a row?) LBL "Dia" MVAR "Dia" MVAR "Area" MVAR "Circ" ASTO ST X "Area" ASTO ST Y X=Y? GTO 00 CLA ARCL ST X RCL "Dia" PI * RCL "Circ" - RTN LBL 00 RCL "Dia" X^2 PI * 4 / RCL "Area" - RTN I think the Alpha-register must remain untouched, hence the CLA ARCL ST X Werner Huysegoms ▼ Randy Sloyer Senior Member Posts: 441 Threads: 24 Joined: Apr 2008 11-28-2002, 08:00 AM Werner: A very elegant solution. I worked on this for a few hours the other night and had given up on using solver for this. I never thought of having two solver programs within one. At least it got me paging through my new copy of the 42S programming guide (Thanks Iqbal!), so it was time well spent. I've made two insignificant changes (the RCL- )to the program and added the line numbers for ease of entry. This was formatted using a {pre /pre} block around the code listing. More options can be found here: http://www.hpmuseum.org/artfmt.htm ```00 {72 Byte-Prgm} 01 LBL "Dia" 02 MVAR "Dia" 03 MVAR "Area" 04 MVAR "Circ" 05 ASTO ST X 06 "Area" 07 ASTO ST Y 08 X=Y? 09 GTO 00 10 CLA 11 ARCL ST X 12 RCL "Dia" 13 PI 14 * 15 RCL- "Circ" 16 RTN 17 LBL 00 18 RCL "Dia" 19 X^2 20 PI 21 * 22 4 23 / 24 RCL- "Area" 25 RTN 26 END ``` ▼ Mike Posting Freak Posts: 899 Threads: 193 Joined: Jan 2005 11-28-2002, 04:23 PM Thanks you Randy and Werner, I tried your programs and they both seemed work correctly at first but only when you enter the "Dia" first, if you enter the others (area or circ)first it doesn't seem to calculate the correct result. I will try to understand how the program works and see why it is happening. Thanks for your efforts. Mike

 Possibly Related Threads... Thread Author Replies Views Last Post hp-prime solver and variable name fabrice48 22 1,707 12-10-2013, 03:25 AM Last Post: fabrice48 Solver issue with HP 17BII - different from 19BII Jeff Kearns 13 838 11-28-2013, 02:36 AM Last Post: Don Shepherd HP Prime Triangle solver BruceH 29 1,800 11-28-2013, 12:03 AM Last Post: Dale Reed HP prime: linear solver app Alberto Candel 1 316 11-21-2013, 01:57 AM Last Post: Michael Carey HP Prime: Linear Solver app bug BruceH 0 209 11-15-2013, 06:36 PM Last Post: BruceH HP Prime Solver Variables Issue Anibal Morones Ruelas 8 687 10-19-2013, 09:45 AM Last Post: Harold A Climer HP Prime triangle solver oddity BruceH 0 197 10-13-2013, 09:08 PM Last Post: BruceH Using units in Numeric Solver Harold A Climer 1 248 10-13-2013, 10:44 AM Last Post: Tim Wessman Meltiple Equation Solver PRIME Vs. HP 50G Harold A Climer 5 437 10-07-2013, 05:11 PM Last Post: CR Haeger Does Prime Have a Multiple Equation Solver? Norman Dziedzic 2 274 09-20-2013, 09:43 AM Last Post: Norman Dziedzic

Forum Jump: