GithubHelp home page GithubHelp logo

complex-functions's Introduction

Complex Functions

This is a python program that uses the pygame module to animate complex functions. It displays four boxes (of distance 0, 1, 2, 3, and 4 from 0) and shows an animation detailing their movement from z to f(z).

How to use

This program is mainly to be used from the command line. Here is an example usage to animate f(z) = z*i :

C:\YourDirectoryHere\complex-functions\src> python animate.py "z*i"

Have a go experimenting with each of the operators available, and see what you can come up with! Here's another example to get you started that animates f(z) = z / (z.realpart*i + z.imaginarypart) :

C:\YourDirectoryHere\complex-functions\src> python animate.py "z/(z.r*i+z.i)"

You may be suprised to see that all values are mapped onto the unit circle! The command below shows the use of a non-continuous function that multiplies z by it's imaginary part if it has a magnitude less than five - otherwise, it rotates it 45 degree clockwise.

C:\YouDirectoryHere\complex-functions\src> python animate.py "z*(z.i) if z<5 else z*complex(0.707,0.707)"

Here is a list of some of the things you can do:

complex(real, imaginary)        returns x*imaginary+real
+                               adds two numbers
-                               subtracts two numbers
/                               divides two numbers
*                               multiplies two numbers
abs(z)                          returns the magnitude of the number
int(z)                          returns the real part of the number as an integer
float(z)                        returns the real part of the number as a float
z.i                             returns the imaginary component of z
z.r                             returns the real component of z
z.get()                         returns a tuple containing (z.r, z.i)

value if condition else value
<                               compares the magnitudes
>                               compares the magnitudes
==                              compares the whole value
!=                              compares the whole value

complex-functions's People

Contributors

mileswatson avatar

Stargazers

 avatar  avatar

Watchers

 avatar

complex-functions's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.