WeixiangYan/CodeTransOcean huggingface dataset:
Task: Julia set



C#: using System.Drawing;



using System.Linq;

namespace RosettaJuliaSet
{
    class Program
    {
        static void Main(string[] args)
        {
            const int w = 800;
            const int h = 600;
            const int zoom = 1;
            const int maxiter = 255;
            const int moveX = 0;
            const int moveY = 0;
            const double cX = -0.7;
            const double cY = 0.27015;
            double zx, zy, tmp;
            int i;

            var colors = (from c in Enumerable.Range(0, 256)
                          select Color.FromArgb((c >> 5) * 36, (c >> 3 & 7) * 36, (c & 3) * 85)).ToArray();

            var bitmap = new Bitmap(w, h);
            for (int x = 0; x < w; x++)
            {
                for (int y = 0; y < h; y++)
                {
                    zx = 1.5 * (x - w / 2) / (0.5 * zoom * w) + moveX;
                    zy = 1.0 * (y - h / 2) / (0.5 * zoom * h) + moveY;
                    i = maxiter;
                    while (zx * zx + zy * zy < 4 && i > 1)
                    {
                        tmp = zx * zx - zy * zy + cX;
                        zy = 2.0 * zx * zy + cY;
                        zx = tmp;
                        i -= 1;
                    }
                    bitmap.SetPixel(x, y, colors[i]);
                }
            }
            bitmap.Save("julia-set.png");
        }
    }
}








Fortran: C     ==================================================================
      PROGRAM JULIA
C     ------------------------------------------------------------------
      INTEGER    NMAP,NROW,NCOL
      COMPLEX*16 C
      PARAMETER(NMAP=11,NROW=40,NCOL=100,C=(-0.798D0,0.1618D0))
      CHARACTER*1 MAP(NMAP)
      DATA MAP /' ','.',':','-','=','+','*','#','%','$','@'/
      REAL*8      X(NCOL), Y(NROW)
      INTEGER     IR, IC, I, J, MX
      CHARACTER*1 CLR, LINE(NCOL)
      COMPLEX*16  Z

      MX = (NMAP-1)*5
      CALL LINSPACE( NCOL, X, -1.5D0,  1.5D0 )
      CALL LINSPACE( NROW, Y,  1.0D0, -1.0D0 )

      WRITE (*,*) C

      DO 110 IR=1,NROW
         DO 100 IC=1,NCOL
            Z = DCMPLX( X(IC), Y(IR) )
            I  = 1
            CLR = ' '
 10         CONTINUE
            Z = Z*Z + C
            IF ( 2.0D0 .LT. CDABS(Z) ) THEN
               CLR = MAP(MOD(I,NMAP-1)+1)
               GOTO 20
            END IF
            I = I + 1
            IF ( MX .GT. I ) GOTO 10
 20         CONTINUE
            LINE(IC) = CLR
 100     CONTINUE
         WRITE(*,*) (LINE(J),J=1,NCOL)
 110  CONTINUE
      
      STOP
      END

C     ==================================================================
      SUBROUTINE LINSPACE( N, A, S, F )
C     ------------------------------------------------------------------
      INTEGER N
      REAL*8  N A(N), S, F
      INTEGER I
      REAL*8  D
      D = (F-S)/DBLE(N-1)
      A(1) = S
      DO 10 I=2,N
         A(I) = A(I-1) + D
 10   CONTINUE
      RETURN
      END
Task: Julia set

C: #include<graphics.h>
#include<stdlib.h>
#include<math.h>

typedef struct{
	double x,y;
}complex;

complex add(complex a,complex b){
	complex c;
	c.x = a.x + b.x;
	c.y = a.y + b.y;
	return c;
}

complex sqr(complex a){
	complex c;
	c.x = a.x*a.x - a.y*a.y;
	c.y = 2*a.x*a.y;
	return c;
}

double mod(complex a){
	return sqrt(a.x*a.x + a.y*a.y);
}

complex mapPoint(int width,int height,double radius,int x,int y){
	complex c;
	int l = (width<height)?width:height;
	
	c.x = 2*radius*(x - width/2.0)/l;
	c.y = 2*radius*(y - height/2.0)/l;
	
	return c;
}

void juliaSet(int width,int height,complex c,double radius,int n){
	int x,y,i;
	complex z0,z1;
	
	for(x=0;x<=width;x++)
		for(y=0;y<=height;y++){
			z0 = mapPoint(width,height,radius,x,y);
			for(i=1;i<=n;i++){
				z1 = add(sqr(z0),c);
				if(mod(z1)>radius){
					putpixel(x,y,i%15+1);
					break;
				}
				z0 = z1;
			}
			if(i>n)
				putpixel(x,y,0);
		}
}

int main(int argC, char* argV[])
{
	int width, height;
	complex c;
	
	if(argC != 7)
		printf("Usage : %s <width and height of screen, real and imaginary parts of c, limit radius and iterations>");
	else{
		width = atoi(argV[1]);
		height = atoi(argV[2]);
		
		c.x = atof(argV[3]);
		c.y = atof(argV[4]);
		
		initwindow(width,height,"Julia Set");
		juliaSet(width,height,c,atof(argV[5]),atoi(argV[6]));
		
		getch();
	}
	
	return 0;
}










Fortran: C     ==================================================================
      PROGRAM JULIA
C     ------------------------------------------------------------------
      INTEGER    NMAP,NROW,NCOL
      COMPLEX*16 C
      PARAMETER(NMAP=11,NROW=40,NCOL=100,C=(-0.798D0,0.1618D0))
      CHARACTER*1 MAP(NMAP)
      DATA MAP /' ','.',':','-','=','+','*','#','%','$','@'/
      REAL*8      X(NCOL), Y(NROW)
      INTEGER     IR, IC, I, J, MX
      CHARACTER*1 CLR, LINE(NCOL)
      COMPLEX*16  Z

      MX = (NMAP-1)*5
      CALL LINSPACE( NCOL, X, -1.5D0,  1.5D0 )
      CALL LINSPACE( NROW, Y,  1.0D0, -1.0D0 )

      WRITE (*,*) C

      DO 110 IR=1,NROW
         DO 100 IC=1,NCOL
            Z = DCMPLX( X(IC), Y(IR) )
            I  = 1
            CLR = ' '
 10         CONTINUE
            Z = Z*Z + C
            IF ( 2.0D0 .LT. CDABS(Z) ) THEN
               CLR = MAP(MOD(I,NMAP-1)+1)
               GOTO 20
            END IF
            I = I + 1
            IF ( MX .GT. I ) GOTO 10
 20         CONTINUE
            LINE(IC) = CLR
 100     CONTINUE
         WRITE(*,*) (LINE(J),J=1,NCOL)
 110  CONTINUE
      
      STOP
      END

C     ==================================================================
      SUBROUTINE LINSPACE( N, A, S, F )
C     ------------------------------------------------------------------
      INTEGER N
      REAL*8  N A(N), S, F
      INTEGER I
      REAL*8  D
      D = (F-S)/DBLE(N-1)
      A(1) = S
      DO 10 I=2,N
         A(I) = A(I-1) + D
 10   CONTINUE
      RETURN
      END
Task: Julia set




Go: package main

import (
	"image"
	"image/color"
	"image/png"
	"log"
	"os"
	"sync"
)

func main() {
	const (
		width, height = 800.0, 600.0
		maxIter       = 255
		cX, cY        = -0.7, 0.27015
		fileName      = "julia.png"
	)
	img := image.NewNRGBA(image.Rect(0, 0, width, height))

	var wg sync.WaitGroup
	wg.Add(width)
	for x := 0; x < width; x++ {
		thisx := float64(x)
		go func() {
			var tmp, zx, zy float64
			var i uint8
			for y := 0.0; y < height; y++ {
				zx = 1.5 * (thisx - width/2) / (0.5 * width)
				zy = (y - height/2) / (0.5 * height)
				i = maxIter
				for zx*zx+zy*zy < 4.0 && i > 0 {
					tmp = zx*zx - zy*zy + cX
					zy = 2.0*zx*zy + cY
					zx = tmp
					i--
				}
				img.Set(int(thisx), int(y), color.RGBA{i, i, i << 3, 255})
			}
			wg.Done()
		}()
	}
	wg.Wait()
	imgFile, err := os.Create(fileName)
	if err != nil {
		log.Fatal(err)
	}
	defer imgFile.Close()
	if err := png.Encode(imgFile, img); err != nil {
		imgFile.Close()
		log.Fatal(err)
	}
}







Fortran: C     ==================================================================
      PROGRAM JULIA
C     ------------------------------------------------------------------
      INTEGER    NMAP,NROW,NCOL
      COMPLEX*16 C
      PARAMETER(NMAP=11,NROW=40,NCOL=100,C=(-0.798D0,0.1618D0))
      CHARACTER*1 MAP(NMAP)
      DATA MAP /' ','.',':','-','=','+','*','#','%','$','@'/
      REAL*8      X(NCOL), Y(NROW)
      INTEGER     IR, IC, I, J, MX
      CHARACTER*1 CLR, LINE(NCOL)
      COMPLEX*16  Z

      MX = (NMAP-1)*5
      CALL LINSPACE( NCOL, X, -1.5D0,  1.5D0 )
      CALL LINSPACE( NROW, Y,  1.0D0, -1.0D0 )

      WRITE (*,*) C

      DO 110 IR=1,NROW
         DO 100 IC=1,NCOL
            Z = DCMPLX( X(IC), Y(IR) )
            I  = 1
            CLR = ' '
 10         CONTINUE
            Z = Z*Z + C
            IF ( 2.0D0 .LT. CDABS(Z) ) THEN
               CLR = MAP(MOD(I,NMAP-1)+1)
               GOTO 20
            END IF
            I = I + 1
            IF ( MX .GT. I ) GOTO 10
 20         CONTINUE
            LINE(IC) = CLR
 100     CONTINUE
         WRITE(*,*) (LINE(J),J=1,NCOL)
 110  CONTINUE
      
      STOP
      END

C     ==================================================================
      SUBROUTINE LINSPACE( N, A, S, F )
C     ------------------------------------------------------------------
      INTEGER N
      REAL*8  N A(N), S, F
      INTEGER I
      REAL*8  D
      D = (F-S)/DBLE(N-1)
      A(1) = S
      DO 10 I=2,N
         A(I) = A(I-1) + D
 10   CONTINUE
      RETURN
      END
Task: Julia set







Python: from __future__ import division

cX = -0.7
cY = 0.27015
maxIter = 300

def setup():
    size(640, 480)

def draw():
    for x in range(width):
        for y in range(height):
            zx = 1.5 * (x - width / 2) / (0.5 * width)
            zy = (y - height / 2) / (0.5 * height)
            i = maxIter
            while zx * zx + zy * zy < 4 and i > 0:
                tmp = zx * zx - zy * zy + cX
                zy = 2.0 * zx * zy + cY
                zx = tmp
                i -= 1
            colorMode(HSB)
            c = color(i / maxIter * 255, 255, 255 if i > 1 else 0)
            set(x, y, c)




Fortran: C     ==================================================================
      PROGRAM JULIA
C     ------------------------------------------------------------------
      INTEGER    NMAP,NROW,NCOL
      COMPLEX*16 C
      PARAMETER(NMAP=11,NROW=40,NCOL=100,C=(-0.798D0,0.1618D0))
      CHARACTER*1 MAP(NMAP)
      DATA MAP /' ','.',':','-','=','+','*','#','%','$','@'/
      REAL*8      X(NCOL), Y(NROW)
      INTEGER     IR, IC, I, J, MX
      CHARACTER*1 CLR, LINE(NCOL)
      COMPLEX*16  Z

      MX = (NMAP-1)*5
      CALL LINSPACE( NCOL, X, -1.5D0,  1.5D0 )
      CALL LINSPACE( NROW, Y,  1.0D0, -1.0D0 )

      WRITE (*,*) C

      DO 110 IR=1,NROW
         DO 100 IC=1,NCOL
            Z = DCMPLX( X(IC), Y(IR) )
            I  = 1
            CLR = ' '
 10         CONTINUE
            Z = Z*Z + C
            IF ( 2.0D0 .LT. CDABS(Z) ) THEN
               CLR = MAP(MOD(I,NMAP-1)+1)
               GOTO 20
            END IF
            I = I + 1
            IF ( MX .GT. I ) GOTO 10
 20         CONTINUE
            LINE(IC) = CLR
 100     CONTINUE
         WRITE(*,*) (LINE(J),J=1,NCOL)
 110  CONTINUE
      
      STOP
      END

C     ==================================================================
      SUBROUTINE LINSPACE( N, A, S, F )
C     ------------------------------------------------------------------
      INTEGER N
      REAL*8  N A(N), S, F
      INTEGER I
      REAL*8  D
      D = (F-S)/DBLE(N-1)
      A(1) = S
      DO 10 I=2,N
         A(I) = A(I-1) + D
 10   CONTINUE
      RETURN
      END
Task: Julia set








VB: 


cmap=array(" ", ".", ":", "-", "=", "+", "*", "#", "%", "$", "@" )
for y = -1.0 to 1.0 step 0.05
  for x = -1.5 to 1.5 step 0.025
    zr=x
    zi=y
    i=0
    do while i < 100
       zr1 = zr*zr - zi*zi - 0.79 
       zi=zr * zi * 2 + 0.15
       zr=zr1
      if (zr*zr + zi*zi) > 4. then exit do
      i = i + 1 
    loop 
    wscript.stdout.write cmap(i\10)
  next
  wscript.stdout.write vbcrlf
next



Fortran: C     ==================================================================
      PROGRAM JULIA
C     ------------------------------------------------------------------
      INTEGER    NMAP,NROW,NCOL
      COMPLEX*16 C
      PARAMETER(NMAP=11,NROW=40,NCOL=100,C=(-0.798D0,0.1618D0))
      CHARACTER*1 MAP(NMAP)
      DATA MAP /' ','.',':','-','=','+','*','#','%','$','@'/
      REAL*8      X(NCOL), Y(NROW)
      INTEGER     IR, IC, I, J, MX
      CHARACTER*1 CLR, LINE(NCOL)
      COMPLEX*16  Z

      MX = (NMAP-1)*5
      CALL LINSPACE( NCOL, X, -1.5D0,  1.5D0 )
      CALL LINSPACE( NROW, Y,  1.0D0, -1.0D0 )

      WRITE (*,*) C

      DO 110 IR=1,NROW
         DO 100 IC=1,NCOL
            Z = DCMPLX( X(IC), Y(IR) )
            I  = 1
            CLR = ' '
 10         CONTINUE
            Z = Z*Z + C
            IF ( 2.0D0 .LT. CDABS(Z) ) THEN
               CLR = MAP(MOD(I,NMAP-1)+1)
               GOTO 20
            END IF
            I = I + 1
            IF ( MX .GT. I ) GOTO 10
 20         CONTINUE
            LINE(IC) = CLR
 100     CONTINUE
         WRITE(*,*) (LINE(J),J=1,NCOL)
 110  CONTINUE
      
      STOP
      END

C     ==================================================================
      SUBROUTINE LINSPACE( N, A, S, F )
C     ------------------------------------------------------------------
      INTEGER N
      REAL*8  N A(N), S, F
      INTEGER I
      REAL*8  D
      D = (F-S)/DBLE(N-1)
      A(1) = S
      DO 10 I=2,N
         A(I) = A(I-1) + D
 10   CONTINUE
      RETURN
      END
Task: Julia set







Python: from __future__ import division

cX = -0.7
cY = 0.27015
maxIter = 300

def setup():
    size(640, 480)

def draw():
    for x in range(width):
        for y in range(height):
            zx = 1.5 * (x - width / 2) / (0.5 * width)
            zy = (y - height / 2) / (0.5 * height)
            i = maxIter
            while zx * zx + zy * zy < 4 and i > 0:
                tmp = zx * zx - zy * zy + cX
                zy = 2.0 * zx * zy + cY
                zx = tmp
                i -= 1
            colorMode(HSB)
            c = color(i / maxIter * 255, 255, 255 if i > 1 else 0)
            set(x, y, c)



COBOL: IDENTIFICATION DIVISION.
PROGRAM-ID. JULIA-SET-PROGRAM.
DATA DIVISION.
WORKING-STORAGE SECTION.
01  WS-COMPLEX-CONSTANT.
    05 C-REAL             PIC S9V999.
    05 C-IMAGINARY        PIC S9V999.
01  WS-ARGAND-PLANE.
    05 X                  PIC S9(9)V999.
    05 Y                  PIC S9(9)V999.
01  WS-COMPLEX-VARIABLE.
    05 Z-REAL             PIC S9(9)V999.
    05 Z-IMAGINARY        PIC S9(9)V999.
01  WS-TEMPORARY-RESULTS.
    05 X-SQUARED          PIC S9(9)V999.
    05 Y-SQUARED          PIC S9(9)V999.
    05 X-TIMES-Y          PIC S9(9)V999.
    05 Z-REAL-SQUARED     PIC S9(9)V999.
01  WS-LOOP-COUNTERS.
    05 HORIZONTAL         PIC 999.
    05 VERTICAL           PIC 999.
    05 ITERATIONS         PIC 99.
77  WS-PLOT-CHARACTER     PIC X.
PROCEDURE DIVISION.
INPUT-COMPLEX-CONSTANT-PARAGRAPH.
    ACCEPT C-REAL      FROM CONSOLE.
    ACCEPT C-IMAGINARY FROM CONSOLE.
CONTROL-PARAGRAPH.
    PERFORM OUTER-LOOP-PARAGRAPH  VARYING VERTICAL   FROM 1 BY 10
    UNTIL VERTICAL IS GREATER THAN 320.
    STOP RUN.
OUTER-LOOP-PARAGRAPH.
    PERFORM COMPUTATION-PARAGRAPH VARYING HORIZONTAL FROM 1 BY 10
    UNTIL HORIZONTAL IS GREATER THAN 560.
    DISPLAY '' UPON CONSOLE.
COMPUTATION-PARAGRAPH.
    SUBTRACT 280   FROM HORIZONTAL GIVING X.
    SUBTRACT 160   FROM VERTICAL   GIVING Y.
    DIVIDE   X     BY   200        GIVING X.
    DIVIDE   Y     BY   100        GIVING Y.
    MOVE     '#'   TO   WS-PLOT-CHARACTER.
    PERFORM COMPLEX-MULTIPLICATION-PARAGRAPH
    VARYING ITERATIONS FROM   1  BY      1
    UNTIL   ITERATIONS        IS GREATER THAN 50
    OR      WS-PLOT-CHARACTER IS EQUAL   TO   SPACE.
    DISPLAY WS-PLOT-CHARACTER UPON CONSOLE WITH NO ADVANCING.
COMPLEX-MULTIPLICATION-PARAGRAPH.
    MULTIPLY X         BY   X         GIVING X-SQUARED.
    MULTIPLY Y         BY   Y         GIVING Y-SQUARED.
    SUBTRACT Y-SQUARED FROM X-SQUARED GIVING Z-REAL.
    ADD      C-REAL    TO   Z-REAL.
    MULTIPLY X         BY   Y         GIVING X-TIMES-Y.
    MULTIPLY X-TIMES-Y BY   2         GIVING Z-IMAGINARY.
    ADD C-IMAGINARY    TO   Z-IMAGINARY.
    MULTIPLY Z-REAL    BY   Z-REAL    GIVING Z-REAL-SQUARED.
    IF  Z-REAL-SQUARED IS   GREATER   THAN   10000 THEN
    MOVE SPACE         TO   WS-PLOT-CHARACTER.
    MOVE Z-REAL        TO   X.
    MOVE Z-IMAGINARY   TO   Y.
Task: Julia set








VB: 


cmap=array(" ", ".", ":", "-", "=", "+", "*", "#", "%", "$", "@" )
for y = -1.0 to 1.0 step 0.05
  for x = -1.5 to 1.5 step 0.025
    zr=x
    zi=y
    i=0
    do while i < 100
       zr1 = zr*zr - zi*zi - 0.79 
       zi=zr * zi * 2 + 0.15
       zr=zr1
      if (zr*zr + zi*zi) > 4. then exit do
      i = i + 1 
    loop 
    wscript.stdout.write cmap(i\10)
  next
  wscript.stdout.write vbcrlf
next


COBOL: IDENTIFICATION DIVISION.
PROGRAM-ID. JULIA-SET-PROGRAM.
DATA DIVISION.
WORKING-STORAGE SECTION.
01  WS-COMPLEX-CONSTANT.
    05 C-REAL             PIC S9V999.
    05 C-IMAGINARY        PIC S9V999.
01  WS-ARGAND-PLANE.
    05 X                  PIC S9(9)V999.
    05 Y                  PIC S9(9)V999.
01  WS-COMPLEX-VARIABLE.
    05 Z-REAL             PIC S9(9)V999.
    05 Z-IMAGINARY        PIC S9(9)V999.
01  WS-TEMPORARY-RESULTS.
    05 X-SQUARED          PIC S9(9)V999.
    05 Y-SQUARED          PIC S9(9)V999.
    05 X-TIMES-Y          PIC S9(9)V999.
    05 Z-REAL-SQUARED     PIC S9(9)V999.
01  WS-LOOP-COUNTERS.
    05 HORIZONTAL         PIC 999.
    05 VERTICAL           PIC 999.
    05 ITERATIONS         PIC 99.
77  WS-PLOT-CHARACTER     PIC X.
PROCEDURE DIVISION.
INPUT-COMPLEX-CONSTANT-PARAGRAPH.
    ACCEPT C-REAL      FROM CONSOLE.
    ACCEPT C-IMAGINARY FROM CONSOLE.
CONTROL-PARAGRAPH.
    PERFORM OUTER-LOOP-PARAGRAPH  VARYING VERTICAL   FROM 1 BY 10
    UNTIL VERTICAL IS GREATER THAN 320.
    STOP RUN.
OUTER-LOOP-PARAGRAPH.
    PERFORM COMPUTATION-PARAGRAPH VARYING HORIZONTAL FROM 1 BY 10
    UNTIL HORIZONTAL IS GREATER THAN 560.
    DISPLAY '' UPON CONSOLE.
COMPUTATION-PARAGRAPH.
    SUBTRACT 280   FROM HORIZONTAL GIVING X.
    SUBTRACT 160   FROM VERTICAL   GIVING Y.
    DIVIDE   X     BY   200        GIVING X.
    DIVIDE   Y     BY   100        GIVING Y.
    MOVE     '#'   TO   WS-PLOT-CHARACTER.
    PERFORM COMPLEX-MULTIPLICATION-PARAGRAPH
    VARYING ITERATIONS FROM   1  BY      1
    UNTIL   ITERATIONS        IS GREATER THAN 50
    OR      WS-PLOT-CHARACTER IS EQUAL   TO   SPACE.
    DISPLAY WS-PLOT-CHARACTER UPON CONSOLE WITH NO ADVANCING.
COMPLEX-MULTIPLICATION-PARAGRAPH.
    MULTIPLY X         BY   X         GIVING X-SQUARED.
    MULTIPLY Y         BY   Y         GIVING Y-SQUARED.
    SUBTRACT Y-SQUARED FROM X-SQUARED GIVING Z-REAL.
    ADD      C-REAL    TO   Z-REAL.
    MULTIPLY X         BY   Y         GIVING X-TIMES-Y.
    MULTIPLY X-TIMES-Y BY   2         GIVING Z-IMAGINARY.
    ADD C-IMAGINARY    TO   Z-IMAGINARY.
    MULTIPLY Z-REAL    BY   Z-REAL    GIVING Z-REAL-SQUARED.
    IF  Z-REAL-SQUARED IS   GREATER   THAN   10000 THEN
    MOVE SPACE         TO   WS-PLOT-CHARACTER.
    MOVE Z-REAL        TO   X.
    MOVE Z-IMAGINARY   TO   Y.
Task: Julia set






PHP: set_time_limit(300);
header("Content-Type: image/png");

class Julia {
	
	static private $started = false;
	
	public static function start() {
		if (!self::$started) {
			self::$started = true;
			new self;
		}
	}
	
	const AXIS_REAL 	= 0;
	const AXIS_IMAGINARY 	= 1;
	const C 		= [-0.75, 0.1];
	const RADII 		= [1, 0.5];
	const CENTER 		= [0, 0];
	const MAX_ITERATIONS 	= 100;
	const TICK_SPACING 	= 0.001;
	
	private $maxDistance;
	private $imageResource;
	private $whiteColorResource;
	private $z0 = [];
	
	private function __construct() {
		$this->maxDistance = max($this->distance(self::C), 2);
		$this->imageResource = imagecreate(
			$this->coordinateToPixel(self::RADII[self::AXIS_REAL], self::AXIS_REAL),
			$this->coordinateToPixel(self::RADII[self::AXIS_IMAGINARY], self::AXIS_IMAGINARY)
		);
		imagecolorallocate($this->imageResource, 0, 0, 0);
		$this->whiteColorResource = imagecolorallocate($this->imageResource, 255, 255, 255);
		
		for ($x = self::CENTER[self::AXIS_REAL] - self::RADII[self::AXIS_REAL];
		$x <= self::CENTER[self::AXIS_REAL] + self::RADII[self::AXIS_REAL]; $x += self::TICK_SPACING) {
			$z0[self::AXIS_REAL] = $x;
			
			for ($y = self::CENTER[self::AXIS_IMAGINARY] - self::RADII[self::AXIS_IMAGINARY];
			$y <= self::CENTER[self::AXIS_IMAGINARY] + self::RADII[self::AXIS_IMAGINARY]; $y += self::TICK_SPACING) {
				$z0[self::AXIS_IMAGINARY] = $y;
				$iterations = 1;
				do {
					$z0 = $this->q($z0);
					$iterations++;
				} while($iterations < self::MAX_ITERATIONS && $this->distance($z0) <= $this->maxDistance);
				
				if ($iterations !== self::MAX_ITERATIONS) {
					imagesetpixel(
						$this->imageResource,
						$this->coordinateToPixel($x, self::AXIS_REAL),
						$this->coordinateToPixel($y, self::AXIS_IMAGINARY),
						$this->whiteColorResource
					);
				}
				$z0[self::AXIS_REAL] = $x;
			}
		}
	}
	
	public function __destruct() {
		imagepng($this->imageResource);
		imagedestroy($this->imageResource);
	}
	
	private function q($z) {
		return [ ($z[self::AXIS_REAL] ** 2) - ($z[self::AXIS_IMAGINARY] ** 2) + self::C[self::AXIS_REAL],
                       (2 * $z[self::AXIS_REAL] * $z[self::AXIS_IMAGINARY]) + self::C[self::AXIS_IMAGINARY] ];
	}
	
	private function distance($z) {
		return sqrt( ($z[self::AXIS_REAL] ** 2) + ($z[self::AXIS_IMAGINARY] ** 2) );
	}
	
	private function coordinateToPixel($coordinate, $axis) {
		return ($coordinate + self::RADII[$axis]) * (self::TICK_SPACING ** -1);
	}
}

Julia::start();
Task: Calculating the value of e



C#: using System;

namespace CalculateE {
    class Program {
        public const double EPSILON = 1.0e-15;

        static void Main(string[] args) {
            ulong fact = 1;
            double e = 2.0;
            double e0;
            uint n = 2;
            do {
                e0 = e;
                fact *= n++;
                e += 1.0 / fact;
            } while (Math.Abs(e - e0) >= EPSILON);
            Console.WriteLine("e = {0:F15}", e);
        }
    }
}









Ada: with Ada.Text_IO;            use Ada.Text_IO;
with Ada.Long_Float_Text_IO; use Ada.Long_Float_Text_IO;

procedure Euler is
   Epsilon : constant     := 1.0E-15;
   Fact    : Long_Integer := 1;
   E       : Long_Float   := 2.0;
   E0      : Long_Float   := 0.0;
   N       : Long_Integer := 2;
  
begin

   loop
      E0   := E;
      Fact := Fact * N;
      N    := N + 1;
      E    := E + (1.0 / Long_Float (Fact));
      exit when abs (E - E0) < Epsilon;
   end loop;

   Put ("e = ");
   Put (E, 0, 15, 0);
   New_Line;

end Euler;
Task: Calculating the value of e

C: #include <stdio.h>
#include <math.h>

int main(void)
{
    double e;

    puts("The double precision in C give about 15 significant digits.\n"
         "Values below are presented with 16 digits after the decimal point.\n");

    
    
    e = exp(1);
    printf("Euler constant e = %.16lf\n", e);

    
    
    e = 1.0 + 0x1p-26;
    for (int i = 0; i < 26; i++)
        e *= e;
    printf("Euler constant e = %.16lf\n", e);

    
    
    
    const int N = 1000;
    double a[1000];
    a[0] = 1.0;
    for (int i = 1; i < N; i++)
    {
        a[i] = a[i-1] / i;
    }
    e = 1.;
    for (int i = N - 1; i > 0; i--)
        e += a[i];
    printf("Euler constant e = %.16lf\n", e);

    return 0;
}











Ada: with Ada.Text_IO;            use Ada.Text_IO;
with Ada.Long_Float_Text_IO; use Ada.Long_Float_Text_IO;

procedure Euler is
   Epsilon : constant     := 1.0E-15;
   Fact    : Long_Integer := 1;
   E       : Long_Float   := 2.0;
   E0      : Long_Float   := 0.0;
   N       : Long_Integer := 2;
  
begin

   loop
      E0   := E;
      Fact := Fact * N;
      N    := N + 1;
      E    := E + (1.0 / Long_Float (Fact));
      exit when abs (E - E0) < Epsilon;
   end loop;

   Put ("e = ");
   Put (E, 0, 15, 0);
   New_Line;

end Euler;
Task: Calculating the value of e


C++: #include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main() {
    const double EPSILON = 1.0e-15;
    unsigned long long fact = 1;
    double e = 2.0, e0;
    int n = 2;
    do {
        e0 = e;
        fact *= n++;
        e += 1.0 / fact;
    }
    while (fabs(e - e0) >= EPSILON);
    cout << "e = " << setprecision(16) << e << endl;
    return 0;
}










Ada: with Ada.Text_IO;            use Ada.Text_IO;
with Ada.Long_Float_Text_IO; use Ada.Long_Float_Text_IO;

procedure Euler is
   Epsilon : constant     := 1.0E-15;
   Fact    : Long_Integer := 1;
   E       : Long_Float   := 2.0;
   E0      : Long_Float   := 0.0;
   N       : Long_Integer := 2;
  
begin

   loop
      E0   := E;
      Fact := Fact * N;
      N    := N + 1;
      E    := E + (1.0 / Long_Float (Fact));
      exit when abs (E - E0) < Epsilon;
   end loop;

   Put ("e = ");
   Put (E, 0, 15, 0);
   New_Line;

end Euler;