OTTI36X Algorithms  Printable Version + HP Forums (https://archived.hpcalc.org/museumforum) + Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum1.html) + Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum2.html) + Thread: OTTI36X Algorithms (/thread249211.html) 
OTTI36X Algorithms  Matt Agajanian  08302013 Helo all. What are the Solve and Integrate methods used for the TI36X?
Thanks
Re: OTTI36X Algorithms  Kiyoshi Akima  08312013 My TI36X Solar doesn't seem to have solve or integrate functionality. The TI36Xii's manual says Simpson's Rule for integration, and I don't see anything in the manual about a solver. I don't see anything in the TI36XPro's manual about the algorithms used by the solver or integrator.
Re: OTTI36X Algorithms  Matt Agajanian  08312013 Simpson's rule for integration, you say. That's pretty basic and, unless the user provides the number of subintervals to determine accuracy, I wonder if the 36 is using display format to internally determine the number of subintervals. Then, there's the issue of, in the course of calculating the integral that a sample point results in a math error. How does the 36X compensate for that one? As an obvious example, how would it handle the Bessel integral S(0, 2, 'sin(x)/x')?
Re: OTTI36X Algorithms  Kiyoshi Akima  08312013 I really don't know how the 36XPro integrates, though I'm pretty sure it's not Simpson's Rule. For the 36Xii, the integrator requires the user to input the number of intervals (up to 99). The 36XPro requires no such user input. If I had to guess, I'd say it uses a GaussKronrod like the graphing calcs.
The only 36X I have is the basic 36X. I don't have either of the others so I can't tell you how the integrator handles problem cases. If someone does have either of those machines, I'd love to know what they provide for the integral from 0 to 6.4 of the fractional part of x.
Re: OTTI36X Algorithms  Steve Simpkin  08312013 Quote: My TI36X Pro calculates the answer of 3.08 in about 8.5 seconds (assuming I understood and entered to problem correctly). Re: OTTI36X Algorithms  Kiyoshi Akima  08312013 3.08 is the correct answer, unlike the 1.28 my HP15C+ gives. But on the bright side the HP only requires about seven fewer seconds...
Re: OTTI36X Algorithms  Matt Agajanian  08312013 Well, I went to OfficeMax today and put a 36X Pro through my two litmus tests, that Bessel integral and a Pi integral I've known about, S(0.5, 0.5, 3/v(1x^2)). Both integrals, when set in Radians mode yielded exactly the right results!! And, since the 36X didn't prompt for a number of subintervals, I presume that, like our 34C, 15C and 42S, the display setting determines the accuracy of the result.
Re: OTTI36X Algorithms  Gerson W. Barbosa  08312013 Quote: Incidentally 1.28 is what I get when using Simpson's 1/3 Rule and two subintervals (the first program here). This is equivalent to integrating y = 0.4*x from 0 to 6.4. I wonder how the Romberg Method on the HP15C came up with exactly the same result, given the sampling intervals are not evenly spaced on the latter. Quoting from the HP15C Owner's Handbook, page 254:
 Conditions That Could Cause Incorrect Results The function y = frac(x) in not exactly erratic, but it is not continuous on the integration interval.
Re: OTTI36X Algorithms  Matt Agajanian  08312013 Yes, as I rember from even the 34C manual which talks about spikes and unconventional functions, it's either best to integrate regions of the function that are smooth and revise integrand or limits in areas of erratic function characteristics.
Re: OTTI36X Algorithms  Kiyoshi Akima  08312013 The Romberg's failure is easy enough to explain. It first evaluates the function at the midpoint, x=3.2. f(x) is 0.2, multiplied by the width of the interval gives 1.28 as the first estimate of the integral. It then evaluates the function at x=x=1.0 and x=5.4. Using the three points again gives 1.28 for the integral. It then evaluates at x=2.025, x=4.375, x=0.275, and x=6.125. With seven points, the integral again comes out as 1.28.
Since the first three estimates agree with each other, it doesn't matter what the display mode is and the algorithm halts with its "answer."
Re: OTTI36X Algorithms  Kiyoshi Akima  08312013 I'm not sure the display mode matters. The TI84's integrator takes an optional tolerance, and falls back on its defaults if none is given. I'd be surprised if the 36XPro's integrator is more sophisticated than the 84's.
Re: OTTI36X Algorithms  Steve Simpkin  08312013 For comparison, my Casio Classpad 330 takes about 3.5 seconds to arrive at the answer of 3.08.
Re: OTTI36X Algorithms  Les Koller  09012013 If I did this correctly, the HP50g also gives 1.28
Re: OTTI36X Algorithms  Steve Simpkin  09012013 So does the HP33S after about 1.5 seconds.
Re: OTTI36X Algorithms  Les Koller  09012013 In fact, all of my TI's give the correct answer in under a couple seconds. I have only tried it on the 50g in the HP series so far, but I have 4 or 5 of them too.
Re: OTTI36X Algorithms  Kiyoshi Akima  09012013 All the TIs and Casios I have give the correct answer, while every HP I have give the same incorrect answer. That is, all the calculators that have a builtin integrator.
Things change somewhat if you change the upper limit to 6.3 and/or 6.5 ...
Re: OTTI36X Algorithms  peacecalc  09012013 Hello folks, please help me, tell me please where I'm wrong. You are look for the right value of the integral:
INTEGRAL(0, 6.4, FRAC(X), X) = 3.2 The right value have to be 3.2 and not 3.08. The curve is a triangle graph and for every integer value of the upper limit you get an aera of 0.5 and for the fraction part you get 0.4*0.5 = 0.2. If you sum up, that is 3.2. Did I oversee something about precision? Of course 1.28 is much more bad.
Greetings peacecalc
Re: OTTI36X Algorithms  Bunuel66  09012013 Well; it seems that the analytical result should be 3.08...a 'primitive' of x is x^2/2, then the integral is 3+(0.4)²/2 which gives the 3.08 value.
Regards
Re: OTTI36X Algorithms  Massimo Gnerucci (Italy)  09012013 You should consider the square: 0.4 * 0.4 * 0.5 = 0.16 * 0.5 = 0.08 Massimo
P.S. Bunuel66 beat me while typing... :D Edited: 1 Sept 2013, 8:36 a.m.
Re: OTTI36X Algorithms  peacecalc  09012013 Hello folks, shame on me. Of course it is so easy, but it seems not for me.
Greetings Re: OTTI36X Algorithms  Dave Shaffer (Arizona)  09012013 Quote: Alternatively, you have a little triangle of base 0.4 and height 0.4 and the area of a triangle is 1/2 b h = 0.5 * 0.4 * 0.4 = 0.08
Of course, the triangle formula can be considered as coming from the integral of a right triangle as is discussed just above by Massimo and Bunuel66.
Re: OTTI36X Algorithms  Bunuel66  09012013 I have checked on an actual 34C. Unfortunately I got the 1.28 answer which is not what is expected. What puzzles me is that the HP 34C owner manual describes (somewhat...) in annex B the way the integral is computed. I thought that had caught the algorithm. It is not, as my implementation gives the correct answer while the HP not...I suspect that the algorithm is unchanged since the 34C ;(
Regards
Re: OTTI36X Algorithms  robert rozee  09012013 it seems to me that frac(x) is not a valid mathematical operation, and hence can not fairly be used in a function that is to be integrated by a generalized algorithm. why? because it requires reference to the written number  it is not totally 'abstract'. using frac(x) you can construct equations that are tied back to the number base you are working in. consider: y = [ (x*10)  frac(x*10) ] / 10 in base 10, this yields the digit to the left of the decimal point. yet in base 3 it does not. does this not trouble anyone else?
i feel that frac(x), int(x), x, and i am sure others too, are all operations that manipulate the representation of the number (as written down) as opposed to the abstract concept that lies behind the representation.
Re: OTTI36X Algorithms  Marcel Samek  09012013 What you say might be true, but what this discussion really exposes is the fact that functions with discontinuities might not be dealt with properly by numerical integration routines. I personally don't find anything unexpected in that. So, without wading into the "valid mathematical operation" discussion, I would propose that were you to construct another sawtoothlike function with "valid mathematical operations", the numerical integration algorithm would give equally incorrect results with certain start/end values.
Re: OTTI36X Algorithms  Bunuel66  09012013 Your comment is interesting but I'm not sure that this is the heart of the problem. From an integration standpoint frac(x) is not a very particular operator as it can be integrated classically (Riemann) or less classically (Lebesgue) without much troubles.
My 2 cents..;)
Re: OTTI36X Algorithms  Thomas Klemm  09012013 It's not related to the discontinuity. Just try to calculate: My HP48 gives 0 as a result whereas WolframAlpha returns 2.72663x10^{16}.
Cheers
Edited: 1 Sept 2013, 2:16 p.m.
Re: OTTI36X Algorithms  Bunuel66  09012013 In that particular case, which is the integration of a polynomial, rescaling can help. Try to integrate: In other words, just scale the all the numerical values by n and multiply the result by n^(k+1), where k is the order of the polynomial and n the scaling factor. With this method I get the same result than you (Wolfram) with a fairly simple algorithm.
My 3 cents...;) Edited: 2 Sept 2013, 8:18 a.m. after one or more responses were posted
Re: OTTI36X Algorithms  Thomas Klemm  09012013 Or you just split the interval into [128, 0] and [0, 128]. And then you might use that the function is even. But that's not the point: this example illustrates that even with a simple polynomial the result of the integration can be completely wrong. If you're not expecting this behavior you'll never split the interval or use a fancy transformation to doublecheck the result. The values 47, 88 and 117 were chosen deliberately with the knowledge of the algorithm. Thus I don't expect this glitch happens often with real world problems. However if I remember correctly Kiyoshi Akima stumbled upon the problem with the FRAC function by chance.
Cheers Re: OTTI36X Algorithms  Bunuel66  09012013 My point was not to use the symmetry of the function or even to integrate by hand, what is fairly easy in this case, but to use rescaling for having numbers in a better range regarding the internal representation. Actually, the same algorithm can be at pain in the given range and compute a fair value with rescaling.
Regards
Re: OTTI36X Algorithms  Thomas Klemm  09012013 Quote:
You can split the domain at another point, e.g. [128, 47] and [47, 128]. Using the symmetry is for lazy bums.
Re: OTTI36X Algorithms  robert rozee  09012013 you might well be right about the base thing  i was writing at around 3am in the morning here and not 100% awake. btw, what is the exact (symbolic) integral of frac(x), i've tried asking wolfram alpha but just get an animated 'game of life' graphic that goes on forever no matter what i type in (even "2+7") i would agree with everyone that any numeric integration method will have flaws, and at times will produce erroneous results. the algorithms generally assume they are working with a continuous function, and when presented with a discontinuity struggle. splitting the problem down the middle: (1) can anyone find a continuous function that [insert your favourite calculator model here] fails to be able to integrate numerically? (2) can anyone think of a method for an algorithm to (generically) spot a discontinuity and modify its behaviour to work around it successfully in all/most cases? and, one more question: is there an expansion of frac(x) that can be expressed in basic operators (+/*) as is the case with all other regular functions?
Re: OTTI36X Algorithms  Thomas Klemm  09012013 Quote:
That's not true. For x = Pi we get y = 3.1. How is that a digit?
Re: OTTI36X Algorithms  Thomas Klemm  09012013 Quote: My HP48 gives 0 as a result whereas WolframAlpha returns 2.72663x10^{16}.
Re: OTTI36X Algorithms  Thomas Klemm  09012013 Quote:
Only for positive values though. Or if you prefer Fourier series:
Edited: 1 Sept 2013, 9:03 p.m. after one or more responses were posted
Re: OTTI36X Algorithms  robert rozee  09012013 yep  you are right. as i said earlier, i was half asleep when i wrote the post! if you'll allow int(x) to return the nonfractional part, how about:
y = frac [ int(x) / 10 ] * 10
Re: OTTI36X Algorithms  robert rozee  09012013 Quote: when evaluated numerically, what result does this give for x=0.5 or indeed any value of x where frac(x)=0.5 this equality, from the perspective of numeric integration, is as problematic as trying to numerically integrate tan(x) over a range that spans 90, 270, etc degrees, at which points the function is undefined (and not computable).
Re: OTTI36X Algorithms  Les Koller  09012013 Result from Wolfram Alpha + (no result found in terms of standard mathematical functions)
Re: OTTI36X Algorithms  Thomas Klemm  09012013 Since this function is used in RAD mode we don't have singularities at 0.5, 1.5, 2.5, ... We can't enter Pi exactly. So the best we can do is using an approximation. Thus we may get a big number as an intermediate result but we still end up with 0.5. Numerically I don't see a problem. This is completely different from integrating tan(x) from 0 to Pi/2. Not only do we have a singularity at Pi/2, the integral does not converge.
Cheers
PS: With the HP48GX I get 1.28000000002 while the HP15C returns 1.280000002.
Re: OTTI36X Algorithms  Gerson W. Barbosa  09012013 It is very unlikely that the sampled points coincide with values for which the function is not defined. By the way, rewriting the function in this form won't help:
LBL B Re: OTTI36X Algorithms  Thomas Klemm  09012013 Quote:For the simple fact that there aren't any in RAD mode. Re: OTTI36X Algorithms  Gerson W. Barbosa  09012013 Actually not that unlikely, even in DEG mode. For 0 and 6.4 I did get an Error 0 message, but at least for 0 and 6.3999 (in FIX 4) I got 3.0858, which is very close to the correct answer.
Re: OTTI36X Algorithms  Thomas Klemm  09012013 In DEG mode the corresponding program using 180 instead of Pi doesn't work. For x = 1 we end up with a division by zero since tan(180) = 0. So we might want to check that case: 180 STO 0
Kind regards _{Edit: Corrected STO/ by RCL/.}
Edited: 1 Sept 2013, 10:54 p.m. after one or more responses were posted
Re: OTTI36X Algorithms  Thomas Klemm  09012013 In RAD mode the only problematic value is 0. But this value isn't evaluated since it's the lower limit.
Cheers Re: OTTI36X Algorithms  Kiyoshi Akima  09012013 Shouldn't the "STO/ 0" actually be a "RCL/ 0"?
Re: OTTI36X Algorithms  Thomas Klemm  09012013 Sure. Thanks for pointing that out.
Re: OTTI36X Algorithms  Kiyoshi Akima  09012013 Try changing the upper limit by the same amount in the other direction to 6.4001 .
Re: OTTI36X Algorithms  Gerson W. Barbosa  09012013 Alas, back to 1.2803...
Re: OTTI36X Algorithms  David Maier  09022013 I'd be interested to know if it is possible to calculate this with an actual WP34S (note: display setting ALL 9), before the batteries die. I tried it with brand new batteries (3.1 V), and didn't make it.
The emulator produces 3.08034599781.
Re: OTTI36X Algorithms  Gerson W. Barbosa  09022013 3.07830805875 after 12 minutes. Two more minutes and now 3.08173600892, but not willing to stop (last instruction is RND). 
P.S.: 3.08034599781 (Not sure about the running time, but no more than 35 minutes) Edited: 2 Sept 2013, 11:10 p.m.
