File:RationalRepresentation.pdf

Original file(1,047 × 1,047 pixels, file size: 7 KB, MIME type: application/pdf)

Summary

Description
English: Representation of rational numbers (Q) as pairs of integers, equivalent pairs on the same line.
Français : Représentation des nombres rationnels comme des paires de nombres entiers, les paires équivalentes sur le même ligne.
Date 11 December 2009
Source Own work
Author TomT0m

Source of the file, in the en:asymptote graphic programming language: fr:Utilisateur:TomT0m/RationalRepresentation.asy

import settings;
import graph;
import math;
 
 
pdfviewer="/usr/bin/evince";
psviewer="evince";
 

// parameters

int num=10;
 
 
int gcd(int a,int b){
	if(b==0){
		return a;
	}else{
		return gcd(b,a-quotient(a,b)*b);
	}
}
bool isPrimeWith(int a,int b){
	return gcd(a,b)==1;
}

 
pen color_rational(int x,int y){

	if(y==0){
		return white;
	}else{
		real ratio = x
/y;
		return rgb(0.5*(1+ratio),0.7*(1+ratio),0.3*(1-ratio));
	}
}
unitsize(2,2);
 
picture damier;
// unitsize(damier,1,1);
size(damier,5000,5000,(-100,-100),(100,100));
 
dot(damier,(0,0));
dot(damier,(-num,-num),invisible);
dot(damier,(num,num),invisible);
 
 
 
for(int x=-num; x<=num;++x){	
 
	for(int y=-num; y<=num;++y){
 
		
		pen p=color_rational(x,y);
 
		if(y>0){
			pair far;
			if(isPrimeWith(abs(x),abs(y)) ){
				far=(x*100,y*100);
				drawline(damier,(0,0),far,p);
			}
		}

		if(y==0){
 
			dot(damier,(x,y));
			dot(damier,(x,y),rgb(0.9,0.9,0.9));

		}else
			dot(damier,(x,y),p);
 
	}
}

dot(damier,(0,0));
dot(damier,(0,0),rgb(0.9,0.9,0.9));
add(damier.fit(),(0,0));
// drawing the equivalent classes

Licensing

Public domain I, the copyright holder of this work, release this work into the public domain. This applies worldwide.
In some countries this may not be legally possible; if so:
I grant anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

11 December 2009

File history

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

Date/TimeThumbnailDimensionsUserComment
current21:59, 11 December 2009Thumbnail for version as of 21:59, 11 December 20091,047 × 1,047 (7 KB)TomT0m{{Information |Description={{en|1=Representation of rational numbers (Q) as pairs of integers, equivalent pairs on the same line.}} {{fr|1=Représentation des nombres rationnels comme des paires de nombres entiers, les paires équivalentes sur le même li

The following 2 pages use this file:

Global file usage

The following other wikis use this file:

Metadata