File:Amoeba2.svg

Summary

Description
English: The amoeba of
Date
Source Own work based on: Amoeba2.png:  by Oleg Alexandrov
Author
Original:
Vector:
SVG development
InfoField
 The source code of this SVG is invalid due to 2 errors.
 This W3C-invalid trigonometry was created with C++.Category:Invalid SVG created with C++:Trigonometry#0500Amoeba2.svg
This trigonometry is a retouched picture, which means that it has been digitally altered from its original version. Modifications: Vectorization. The original can be viewed here: Amoeba2.png: . Modifications made by Zerodamage.

Category:SVG retouched pictures from raster#Amoeba2.svg

Licensing

Zerodamage, the copyright holder of this work, hereby publishes it under the following license:
w:en:Creative Commons
attribution
This file is licensed under the Creative Commons Attribution 3.0 Unported license.
Attribution:
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.
Category:CC-BY-3.0#Amoeba2.svg
Category:Self-published work

Source code

The logo of C++ – general-purpose programming language
The logo of C++ – general-purpose programming language
This media was created with C++ (general-purpose programming language)Category:Images with C++ source code and MATLAB (numerical computing environment)Category:Images with MATLAB source code
Here is a listing of the source used to create this file.

Deutsch  English  +/−

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

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

  double A=-5, B=5;
  int N=1000;

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

  ofstream mfile ("data.txt");

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

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

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

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

      mfile << a1  << ' ' << b << endl;
      mfile << a2  << ' ' << b << endl;
    }
  }
  mfile.close();

  return 0;
}
double mylog (double x){

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

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

  return log (x);

}

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');

Original upload log

This image is a derivative work of the following images:

Uploaded with derivativeFX Category:Uploaded with derivativeFX

Category:Amoeba (mathematics) Category:Images with C++ source code Category:Images with MATLAB source code
Category:Amoeba (mathematics) Category:CC-BY-3.0 Category:Images with C++ source code Category:Images with MATLAB source code Category:Invalid SVG created with C++:Trigonometry Category:Pages with syntax highlighting errors Category:SVG retouched pictures from raster Category:Self-published work Category:Uploaded with derivativeFX Category:Vectorizations