Re: !!!!!!!! Message #9 Posted by Katie on 30 Dec 2003, 9:09 p.m., in response to message #7 by Katie
Bill,
I don't think that I posted anything about using SIGMA, just a bubble sort routine for the 12C. But here's something that I wrote using SIGMA in the HP200LX solver. It calculates pi to any number of decimal places using the 123 interface to store the partial and final results. To use it you need to have an LX (100, 200 and I think this will work on a 95). The STOCELL and RCLCELL functions just store and recall from the specified cell in 123. To use this, make the following an equation in the solver, start 123 and create a range called OUT. The number of rows in the range determines the number of digits of pi calculated  10 digits per row. The number of columns in the range is unimportant.
{!calculate Pi to n places into OUT in 123!
calc_pi=
l(n,10000000000)*0+ !set the number of digits/cell!
sigma(x,1,length(out),1, !zero the output range!
stocell(0,out,x,1)+stocell(0,out,x,2) ) +
stocell(.28*g(n),out,1,1) + !initial value for 1st term!
SIGMA(x,length(out),1+l(c,0),1, !add to result!
STOCELL(l(t,g(c)+RCLCELL(out,x,1)+RCLCELL(out,x,2))
l(c,idiv( g(t),g(n)))*g(n),out,x,2)) +
sigma(i,2,2*log(g(n))*length(out)/log(50),2, !set up 1st term
loop!
SIGMA(x,l(c,0)+LENGTH(out),1, 1, !multiply by i!
STOCELL(mod((g(c)+i*RCLCELL(out,x,1)),g(n))+
0*l(c,idiv((g(c)+i*RCLCELL(out,x,1)),g(n))),
out,x,1)) +
SIGMA(x,1+l(c,0),LENGTH(out),1, !divide by 50*(i+1)!
STOCELL(idiv((g(c)*g(n)+RCLCELL(out,x,1)),(i+1)*50) +
0*l(c,mod((g(c)*g(n)+RCLCELL(out,x,1)),
(i+1)*50)),out,x,1)) +
SIGMA(x,Length(out),1+l(c,0),1, !add to result!
STOCELL(l(t,g(c)+RCLCELL(out, x,1)+RCLCELL(out,x,2)) 
l(c,idiv(g(t),g(n)))*g(n) ,out, x,2))) +
stocell(.030336*g(n),out,1,1) + !initial value for 2nd term!
SIGMA(x,length(out),1+l(c,0),1, !add to result!
STOCELL(l(t,g(c)+RCLCELL(out,x,1)+RCLCELL(out,x,2))
l(c,idiv( g(t),g(n)) ) * g( n) ,out,x,2)) +
SIGMA(i,2,2*log(g(n))*length(out)/log(6250/9),2, !setup 2nd
term loop!
SIGMA(x,l(c,0)+LENGTH(out),1, 1, !multiply by i*9!
STOCELL(mod((g(c)+i*9*RCLCELL(out,x,1)),g(n)) +
0*l( c, idiv((g(c)+i*9*RCLCELL(out,x,1)),
g(n))),out,x,1)) +
SIGMA(x,1+l(c,0),LENGTH(out),1, !divide by 50*(i+1)!
STOCELL(idiv((g(c)*g(n)+RCLCELL(out,x,1)),(i+1)*50) +
0*l(c,mod((g(c)*g(n)+RCLCELL(out,x,1)),
(i+1)*50)),out,x,1)) +
SIGMA(x,1+l(c,0),LENGTH(out),1, !divide by 125!
STOCELL(idiv((g(c)*g(n)+RCLCELL(out,x,1)),125) +
0*l( c,mod((g(c)*g(n)+RCLCELL(out,x,1)),125)),
out, x,1)) +
SIGMA(x,LENGTH(out),1+l(c,0),1, !add to result!
STOCELL(l(t,g(c)+RCLCELL(out,x,1)+RCLCELL(out,x,2))
l(c,idiv( g(t),g(n)) ) * g( n) ,out,x,2))
)
}
