~ubuntu-branches/debian/squeeze/maxima/squeeze

« back to all changes in this revision

Viewing changes to demo/cf.dem

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2006-10-18 14:52:42 UTC
  • mto: (1.1.5 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20061018145242-vzyrm5hmxr8kiosf
ImportĀ upstreamĀ versionĀ 5.10.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
/* the 2 last lines gives erroneous results  */
5
5
/* CONTINUED FRACTIONS. THIS IS GOOD STUFF. */
6
6
 
7
 
FRAC1:CF([1,2,3,4]);
8
 
FRAC2:CF([2,3,4,5]);
9
 
CFDISREP(FRAC1);
10
 
CF(FRAC1+FRAC2);
11
 
CFDISREP(%);
 
7
frac1:cf([1,2,3,4]);
 
8
frac2:cf([2,3,4,5]);
 
9
cfdisrep(frac1);
 
10
cf(frac1+frac2);
 
11
cfdisrep(%);
12
12
 
13
13
 
14
14
cf(467288576/469097433);
16
16
ratsimp(%);
17
17
 
18
18
 
19
 
/* CF can make the continued fraction expansion of SQRT(N) to
20
 
   CFLENGTH terms. */
 
19
/* cf can make the continued fraction expansion of sqrt(n) to
 
20
   cflength terms. */
21
21
 
22
 
BLOCK([CFLENGTH:4],CFDISREP(CF(SQRT(3))));
23
 
RATSIMP(%);
 
22
block([cflength:4],cfdisrep(cf(sqrt(3))));
 
23
ratsimp(%);
24
24
%^2-3;
25
25
 
26
 
RATSQRT(N,CFLENGTH):=RATSIMP(CFDISREP(CF(SQRT(N))))$
 
26
ratsqrt(n,cflength):=ratsimp(cfdisrep(cf(sqrt(n))))$
27
27
 
28
 
RATSQRT(1776,25);
 
28
ratsqrt(1776,25);
29
29
%^2-1776;
30
30
 
31
31
/* With the primitives of SQRT and rational operations