Re: 35s Programming (need help) Message #40 Posted by Valentin Albillo on 5 Feb 2008, 8:04 a.m., in response to message #1 by Chuck
Hi, Chuck:
Chuck posted:
"So, is there an elegant way to "solve" an integral equation on the 35s?"
If by "elegant" you mean some way to make the builtin Solve functionality work with the builtin Integrate functionality then sorry, that's impossible in the current firmware.
What to do ? Well, you'll have to replace one or the other with a usercreated program, as simple and efficient as possible. As integration programs tend to be much more complicated and slower than rootfinding programs, we'd do well to make use of the builtin Integrate and provide instead our own Solver.
To that effect, I suggest you use something like the solver I created and proposed decades ago for its inclusion in the PPC ROM, which you can find in the following thread: Valentin Albillo's Rootfinder
If you visit that thread (which you should do, for the documentation if nothing else) you'll notice that I wrote the program for the HP41C which was the rage at the time. For you to be able to use it in your HP35s, I'm providing the following converted (and slightly optimized) version instead
A001 LBL A
A002 CF 0 A016 X=0?
A003 STO A A017 E^X
A004 50 A018 /
A005 STO B A019 Go
A006 Go A020 *
A007 RCL+ A A021 STO A
A008 XEQ F001 A022 RND
A009 STO C A023 X=0?
A010 RCL A A024 GTO A028
A011 XEQ F001 A025 DSE B
A012 X=0? A026 GTO A006
A013 GTO A028 A027 SF 0
A014 STO C A028 RCL A
A015 RCL C A029 RTN
where the Go at lines A006 and A019 is obtained from the CONSTants menu, defined as the "Conductance quantum", which evaluates to 7.748E5 approximately.
Once you've entered this simple, general, and quite fast rootfinding procedure o'mine, you just need to define the equation to solve, which in your case is essentially Integral(0,X) = 6, which gets programmed in the HP35s as:
F001 LBL F I001 LBL I
F002 FN= I I002 4
F003 0 I003 RCLx T
F004 X<>Y I004 RCLx T
F005 INTEG T I005 1
F006 6 I006 +
F007  I007 SQRT
F008 RTN I008 RTN
where LBL F is the equation being solved, which uses the builtin Integrate, and LBL I is the function being integrated, which is defined above as an RPN program segment. You can also define it as an ALGebraic equation, like this:
I001 LBL I
I003 EQN SQRT(1+4*SQ(T))
I004 RTN
which is shorter and possibly clearer, but the RPN version above is significantly faster to evaluate.
Once you've entered the rootfinder program (LBL A), the equation to solve (LBL F), and the function to integrate (LBL I), you can then proceed to specify the precision wanted (FIX 3) and supply a suitable initial guess (3) to get:
FIX 3, 3, XEQ A > 2.305
in either 17 seconds for the RPN version of the function or 23 seconds for the ALGebraic version, whichever you chose.
Hope this is more or less what you wanted. See the thread linked above for documentation on my root finder such as what happens if the computed derivative is zero or if the equation being solved has no real roots or convergence is extremely slow.
For solving equations with complex roots or complex parameters using your HP35s, have a look at my "Boldly Going  Going Back to the Roots" Datafile article published in Datafile September/October 2007 issue (V26N6P28).
Best regards from V.
