Image:Amoeba2.png

From Wikipedia, the free encyclopedia

Wikimedia Commons logo This is a file from the Wikimedia Commons. The description on its description page there is shown below.
Commons is attempting to create a freely licensed media file repository. You can help.

Contents

[edit] Summary

Made by myself with C++ and matlab.

[edit] Licensing

Public domain I, the copyright holder of this work, hereby release it into the public domain. This applies worldwide.

In case this is not legally possible:
I grant anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.


Afrikaans | Alemannisch | Aragonés | العربية | Български | Català | Česky | Cymraeg | Dansk | Deutsch | Ελληνικά | English | Español | Esperanto | Euskara | فارسی | Français | Galego | 한국어 | हिन्दी | Hrvatski | Ido | Bahasa Indonesia | Íslenska | Italiano | עברית | Kurdî / كوردي | Latina | Lietuvių | Magyar | Bahasa Melayu | Nederlands | Norsk (bokmål) | Norsk (nynorsk) | 日本語 | Polski | Português | Ripoarish | Română | Русский | Shqip | Slovenčina | Slovenščina | Српски | Svenska | ไทย | Türkçe | Українська | Tiếng Việt | | 简体中文 | 繁體中文 | 粵語 | +/-


[edit] C++ code


#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include<complex>
using namespace std;

double small = 1e-14;
double mylog (double);
int main(){

  complex<double> z2, root, z11, z12;
  double A=-5, B=5, x, y, h, a1, a2, b;
  double R, pi, r, theta0, theta;
  int N=1000, i, j;

  h= (B-A)/(N-1);
  theta0 = 2*M_PI/(N-1.0);

  ofstream mfile ("data.txt");

  for (i=0 ; i < N ; i++){
    r = exp(A+i*h);

    for (j=0 ; j < N ; j++){
      theta = j*theta0;

      z2 = r*complex<double>(cos(theta), sin(theta));
      root = sqrt(25.0*z2*z2-12.0*(z2*z2*z2+1.0));
      z11 = (-5.0*z2+root)/6.0;
      z12 = (-5.0*z2-root)/6.0;

      a1 = mylog(abs(z11));
      a2 = mylog(abs(z12));
      b  = mylog(abs(z2));

      mfile << a1  << ' ' << b << endl;
      mfile << a2  << ' ' << b << endl;
    }
  }
  mfile.close();
}
double mylog (double x){

  if (x< 0){
    cout << "Error in log, negative x!" << endl;
    exit(0);
  }

  if (x < small){
    return log (small);
  }

  return log (x);

}


[edit] Matlab code which reads the data output by the C++ code and graphs it


A=load('data.txt');

plot(A(:, 1), A(:, 2), '.');
axis equal; axis off;

axis([-4 6 -5 5])
saveas(gcf, 'amoeba2.eps', 'psc2');

The following pages on the English Wikipedia link to this file (pages on other projects are not listed):