This is a file from the Wikimedia Commons

File:Finite continued fractions 0;1,1,1,.....png

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Original file(700 × 700 pixels, file size: 24 KB, MIME type: image/png)

Summary

Description
English: finite continued fractions aproximation to [0;1,1,1,....]
Date
Source Own work
Author Adam majewski

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

Maxima CAS src code

/* 
 
It is approximated by finite continued  fractions :

[0;1,1,1,....]

https://commons.wikimedia.org/wiki/File:Finite_continued_fractions_0;1,1,1,.....png

*/

kill(all);


a:[0,3,2,1000,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1];/* continuead fraction - golden mean */



/* floating point value of n-th convergent */
f(i):=block
(
	b : firstn(a,i), /* first n terms of a */
	c : cfdisrep(b),
	c: ratsimp(c),
	print(c), 
	float(c)
)$




iMax : length(a);


/* save the values to 2 lists */
xx:makelist (i, i, 1, iMax); /* list of positive integers  */
yy:makelist (f(i), i, 1, iMax); /* list of cf  */

/*
for i:1 thru iMax step 1 do 
(  
   xx:cons(i,xx),  
   y:float(f(i)),
   yy:cons(y,yy)

);
*/
load(draw);
draw2d(
   file_name = "g700",
   terminal  = 'png,
  
  
   dimensions  = [700,700],
   yrange = [0.0,0.35],
   xrange = [0, iMax+1],
   title= "Finite continued fraction aproximation for [0,3,2,1000,1,...] = .2857346851349422",
   key = "nth-covergent",
   xlabel     = "n",
   ylabel     = "n-continued fractions",
   point_type    = filled_circle,
   point_size    = 1.0,
   points_joined = true,

   color         = red,
   points(xx,yy),
   color = blue,
   key = "[0,3,2,1000,1,...]",
   explicit(0.2857346725405882,x,1,iMax)

  );

Text output:

 batch("c.mac");

read and interpret file: #p/home/a/maxima/batch/cf/limit/c.mac
(%i9) kill(all)
(%o0)                                done
(%i1) a:[0,3,2,1000,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
(%o1) [0, 3, 2, 1000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
(%i2) f(i):=block(b:firstn(a,i),c:cfdisrep(b),c:ratsimp(c),print(c),float(c))
(%i3) iMax:length(a)
(%o3)                                 21
(%i4) xx:makelist(i,i,1,iMax)
(%o4) [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 
                                                                            21]
(%i5) yy:makelist(f(i),i,1,iMax)
0 
1
- 
3
2
- 
7
2001
---- 
7003
2003
---- 
7010
4004
----- 
14013
6007
----- 
21023
10011
----- 
35036
16018
----- 
56059
26029
----- 
91095
42047
------ 
147154
68076
------ 
238249
110123
------ 
385403
178199
------ 
623652
288322
------- 
1009055
466521
------- 
1632707
754843
------- 
2641762
1221364
------- 
4274469
1976207
------- 
6916231
3197571
-------- 
11190700
5173778
-------- 
18106931
(%o5) [0.0, 0.3333333333333333, 0.2857142857142857, 0.2857346851349421, 
0.2857346647646219, 0.2857346749446942, 0.2857346715502069, 
0.2857346729078662, 0.2857346723987228, 0.2857346725945441, 
0.2857346725199451, 0.2857346725484682, 0.2857346725375775, 0.285734672541738, 
0.2857346725401489, 0.2857346725407559, 0.2857346725405241, 
0.2857346725406126, 0.2857346725405788, 0.2857346725405917, 0.2857346725405868]
(%i6) load(draw)
(%o6)            /usr/share/maxima/5.41.0/share/draw/draw.lisp
(%i7) draw2d(file_name = "g700",terminal = 'png,dimensions = [700,700],
             yrange = [0.0,0.35],xrange = [0,iMax+1],
             title = "Finite continued fraction aproximation for [0,3,2,1000,1,...] = .2857346851349422",
             key = "nth-covergent",xlabel = "n",
             ylabel = "n-continued fractions",point_type = filled_circle,
             point_size = 1.0,points_joined = true,color = red,points(xx,yy),
             color = blue,key = "[0,3,2,1000,1,...]",
             explicit(0.2857346725405882,x,1,iMax))
(%o7)                      [gr2d(points, explicit)]
(%o7)                                c.mac
(%i8) 

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

21 October 2011

image/png

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current17:33, 16 January 2020Thumbnail for version as of 17:33, 16 January 2020700 × 700 (24 KB)Soul windsurferbetter code, show values from 0 to iMax convergents
19:09, 21 October 2011Thumbnail for version as of 19:09, 21 October 2011700 × 700 (25 KB)Soul windsurfer

The following page uses this file: