A Fraction Drawing Program for MATLAB
    The following commands, when cut and pasted into MATLAB at the command prompt, will draw the graphical analysis graph of the fraction 1/29 in base 10. To draw the graph of 1/d in base b, first change the values of d and b to what you want. Then replace the 29s in the line "axis([0 29 0 29])" by your new value for d. (Note: you must type in the new numerical value for d, rather than typing just the letter d.) You will probably also want to change the title to reflect the new fraction. Then cut and paste the edited commands into a MATLAB command prompt.

    These commands will not only draw the graph of the fraction, but also the coordinate axes and the line y = x. If you do not want the line y = x, delete the two commands "q = [0 d+d*i]" and "plot(q)". If you do not want the coordinate axes, type "set(gca,'Visible','off')" just below the axis command. Unfortunately, this will also eliminate the title, and you will need to use the text command instead of the title command to put titles on your graph. These two commands have exactly the same syntax, the only difference being that with text you must specify a location, e.g. "text(12,32,'\it{1/29 base 13}','FontSize',10)", where 12,32 is the location of the text, relative to the (possibly invisible) coordinate axes.

    Some neat fractions (in addition to those in the April issue of the Magazine): 1/167 base 97, 1/37 base 2, 1/307 base 28, 1/313 base 34. It's also worthwhile to look at 1/157 in all of the bases 20-29.

    I'm curious to know what people's tastes are in fractions.  So if you find some fractions that you think are particularly beautiful, I'd like to know about them.  Also, if you have any questions or comments, do not hesitate to contact me.  My email address is rafe@math.brown.edu.

Happy drawing!

d = 29
b = 10
r = 1
e = [1+i]

for j = 1:d
    e = [e, r+r*i]
    l = rem(b*r,d)
    e = [e, r+l*i]
    r = l

axis([0 29 0 29])

title('\it{1/29 base 10}','FontSize',10)

hold on

q = [0 d+d*i]

hold off

Copyright ©2000 The Mathematical Association of America
Please send comments, suggestions, or corrections about this page to webmaster@maa.org.

MAA Online is edited by Fernando Q. GouvÍa (fqgouvea@colby.edu).
Last modified: Sat Jun 03 09:49:18 -0500 2000