All Downloads are FREE. Search and download functionalities are using the official Maven repository.

JSci.maths.chaos.MandelbrotMap Maven / Gradle / Ivy

Go to download

JSci is a set of open source Java packages. The aim is to encapsulate scientific methods/principles in the most natural way possible. As such they should greatly aid the development of scientific based software. It offers: abstract math interfaces, linear algebra (support for various matrix and vector types), statistics (including probability distributions), wavelets, newtonian mechanics, chart/graph components (AWT and Swing), MathML DOM implementation, ... Note: some packages, like javax.comm, for the astro and instruments package aren't listed as dependencies (not available).

The newest version!
package JSci.maths.chaos;

import JSci.maths.*;

/**
* The MandelbrotMap class provides an object that encapsulates the Mandelbrot map.
* zn+1 = zn2 + c.
* @version 1.0
* @author Mark Hale
*/
public final class MandelbrotMap extends Object implements ComplexMapping {
        /**
        * A complex number z such that |z| > CONVERGENT_BOUND
        * will diverge under this map.
        */
        public final static double CONVERGENT_BOUND=2.0;
        private Complex a;
        /**
        * Constructs a Mandelbrot map.
        * @param aval the value of the constant.
        */
        public MandelbrotMap(double aval) {
                a=new Complex(aval,0.0);
        }
        /**
        * Constructs a Mandelbrot map.
        * @param aval the value of the constant.
        */
        public MandelbrotMap(Complex aval) {
                a=aval;
        }
        /**
        * Returns the constant.
        */
        public Complex getConstant() {
                return a;
        }
        /**
        * Sets the constant.
        */
        public void setConstant(Complex aval) {
                a=aval;
        }
        /**
        * Performs the mapping.
        * @param x a double
        */
        public double map(double x) {
                return x*x+a.real();
        }
        /**
        * Performs the mapping.
        * @param z a complex number.
        */
        public Complex map(Complex z) {
                return map(z.real(),z.imag());
        }
        /**
        * Performs the mapping.
        */
        public Complex map(double real,double imag) {
                return new Complex(real*real-imag*imag+a.real(),2.0*real*imag+a.imag());
        }
        /**
        * Iterates the map.
        * @param n the number of iterations
        * @param x the initial value
        */
        public double iterate(int n,double x) {
                for(int i=0;i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy