Popular recipes tagged "mathematics" but not "graphics"http://code.activestate.com/recipes/tags/mathematics-graphics/2016-07-23T07:58:14-07:00ActiveState Code RecipesHamming Error Correction Code (Python)
2016-07-23T07:58:14-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/580691-hamming-error-correction-code/
<p style="color: grey">
Python
recipe 580691
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/encoding/">encoding</a>, <a href="/recipes/tags/engineering/">engineering</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/utility/">utility</a>).
</p>
<p>Hamming(7,4) Error Correction Code (ECC).</p>
Simple Infix Expression Evaluation (Python)
2015-11-07T18:44:05-08:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/579122-simple-infix-expression-evaluation/
<p style="color: grey">
Python
recipe 579122
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/algorithm/">algorithm</a>, <a href="/recipes/tags/algorithms/">algorithms</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/stack/">stack</a>).
</p>
<p>Simple infix expression evaluation using a stack.</p>
Infix Expression Evaluation (Python)
2015-11-08T05:08:26-08:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/579123-infix-expression-evaluation/
<p style="color: grey">
Python
recipe 579123
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/algorithm/">algorithm</a>, <a href="/recipes/tags/algorithms/">algorithms</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/stack/">stack</a>).
</p>
<p>Infix expression evaluation using two stacks.</p>
2D Discrete Fourier Transform (Python)
2015-01-03T03:39:34-08:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/578997-2d-discrete-fourier-transform/
<p style="color: grey">
Python
recipe 578997
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/images/">images</a>, <a href="/recipes/tags/image_processing/">image_processing</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/signal_processing/">signal_processing</a>).
</p>
<p>2D Discrete Fourier Transform (DFT) and its inverse.</p>
<p>Calculates 2D DFT of an image and recreates the image using inverse 2D DFT.</p>
<p>Computation is slow so only suitable for thumbnail size images.</p>
Discrete Fourier Transform (Python)
2014-12-27T21:43:53-08:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/578994-discrete-fourier-transform/
<p style="color: grey">
Python
recipe 578994
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/signal/">signal</a>, <a href="/recipes/tags/signal_processing/">signal_processing</a>).
</p>
<p>Discrete Fourier Transform and Inverse Discrete Fourier Transform</p>
<p>To test, it creates an input signal using a Sine wave that has known frequency, amplitude, phase.
Later it calculates DFT of the input signal and finds its frequency, amplitude, phase to compare.</p>
Mandelbrot Fractal image output to ppm file (Python)
2015-01-17T19:21:47-08:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/579006-mandelbrot-fractal-image-output-to-ppm-file/
<p style="color: grey">
Python
recipe 579006
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/images/">images</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>).
</p>
<p>It creates image output without using any external library.</p>
<p>PPM image files can be viewed and converted to other image file formats using many applications, GIMP or IrfanView for example.</p>
Perfect Square Checker (Python)
2014-09-10T02:21:27-07:00Ethan Hannhttp://code.activestate.com/recipes/users/4190746/http://code.activestate.com/recipes/578931-perfect-square-checker/
<p style="color: grey">
Python
recipe 578931
by <a href="/recipes/users/4190746/">Ethan Hann</a>
(<a href="/recipes/tags/check/">check</a>, <a href="/recipes/tags/checker/">checker</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/root/">root</a>, <a href="/recipes/tags/square/">square</a>).
</p>
<p>This program will take input from the user and either check if a number is a perfect square or square a number, depending on user's choice.</p>
2D Fluid Simulation using FHP LGCA (Python)
2014-08-18T05:01:04-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/578924-2d-fluid-simulation-using-fhp-lgca/
<p style="color: grey">
Python
recipe 578924
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/physics/">physics</a>, <a href="/recipes/tags/simulation/">simulation</a>).
</p>
<p>2D Fluid Simulation using FHP LGCA (Lattice Gas Cellular Automata)</p>
<p>Simulates fluid flow in a circular channel.</p>
<p>It works really slow but I think it can be a lot faster if it modified for NumPy and possibly Py2Exe.</p>
<p>But my main goal was to provide easy to understand code (not performance) anyway. </p>
A Fun Perfect Square Checker Using Integer Arithmetic Only... ;o) (Bash)
2014-09-16T22:27:04-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578934-a-fun-perfect-square-checker-using-integer-arithme/
<p style="color: grey">
Bash
recipe 578934
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/arithmetic/">arithmetic</a>, <a href="/recipes/tags/bash/">bash</a>, <a href="/recipes/tags/check/">check</a>, <a href="/recipes/tags/checker/">checker</a>, <a href="/recipes/tags/cygwin/">cygwin</a>, <a href="/recipes/tags/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/perfect/">perfect</a>, <a href="/recipes/tags/root/">root</a>, <a href="/recipes/tags/square/">square</a>).
</p>
<p>A recent Python upload here gave me the inspiration to do a bash version...
This is a little tongue-in-cheek but an enjoyable bit of fun.</p>
<p>It took around 11 seconds to prove 90000000000 had a perfect square of 300000...</p>
<p>It is a stand alone program and has a degree of INPUT error correction...</p>
<p>It was done on a MacBook Pro, OSX 10.7.5, default bash terminal and should work on Linux flavours but it is untested...</p>
<p>Enjoy finding simple solutions to often very difficult problems...</p>
<p>Bazza...</p>
A simple Matrix class (Python)
2012-05-14T13:34:31-07:00Anand B Pillaihttp://code.activestate.com/recipes/users/4169530/http://code.activestate.com/recipes/578131-a-simple-matrix-class/
<p style="color: grey">
Python
recipe 578131
by <a href="/recipes/users/4169530/">Anand B Pillai</a>
(<a href="/recipes/tags/algebra/">algebra</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/matrix/">matrix</a>).
Revision 3.
</p>
<p>A simple class in Python representing a Matrix with basic operations, operator overloading and class factory methods to make Matrices from different sources.</p>
Automated Stock Market Trading Simulation (Python)
2014-05-16T02:40:28-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/578881-automated-stock-market-trading-simulation/
<p style="color: grey">
Python
recipe 578881
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/simulation/">simulation</a>, <a href="/recipes/tags/stock/">stock</a>, <a href="/recipes/tags/stock_market/">stock_market</a>).
</p>
<p>It simulates an automated trading strategy against a simulated stock.</p>
<p>I think the results are interesting.
It seems number of wins are always higher than number of losses
but average amount of loss is also always higher than average amount of win! </p>
Circle Inversion Fractals (Python)
2013-10-30T03:53:31-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/578765-circle-inversion-fractals/
<p style="color: grey">
Python
recipe 578765
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>).
</p>
<p>Circle Inversion Fractals (Apollonian Gasket)</p>
Random Spiral Fractals (Python)
2013-09-29T05:35:20-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/578658-random-spiral-fractals/
<p style="color: grey">
Python
recipe 578658
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>).
Revision 2.
</p>
<p>This based on another of my posted codes, titled "Spiral IFS Fractals".</p>
Hofstadter Butterfly Fractal (Python)
2013-09-23T03:18:02-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/578670-hofstadter-butterfly-fractal/
<p style="color: grey">
Python
recipe 578670
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/physics/">physics</a>).
Revision 2.
</p>
<p>Hofstadter Butterfly Fractal</p>
Calculating e using Continued Fraction (Python)
2013-09-02T18:49:53-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/578653-calculating-e-using-continued-fraction/
<p style="color: grey">
Python
recipe 578653
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>).
</p>
<p>Calculating e using Continued Fraction</p>
Riemann Zeta Function Graph (Python)
2013-07-21T08:03:39-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/578616-riemann-zeta-function-graph/
<p style="color: grey">
Python
recipe 578616
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>).
</p>
<p>Riemann Zeta Function Graph</p>
Calculating PI using trigonometric iterations (Python)
2013-08-25T06:24:56-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/578651-calculating-pi-using-trigonometric-iterations/
<p style="color: grey">
Python
recipe 578651
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/pi/">pi</a>).
</p>
<p>Calculating PI using trigonometric iterations</p>
Gravner-Griffeath Snowflake Simulation (Python)
2013-05-27T00:13:09-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/578533-gravner-griffeath-snowflake-simulation/
<p style="color: grey">
Python
recipe 578533
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/physics/">physics</a>, <a href="/recipes/tags/simulation/">simulation</a>).
Revision 2.
</p>
<p>Gravner-Griffeath snowflake simulation.</p>
<p>For better results increase the image size and number of growth steps and prepare to wait!</p>
Relativistic Rocket Kinematics (Python)
2013-06-09T06:09:52-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/578555-relativistic-rocket-kinematics/
<p style="color: grey">
Python
recipe 578555
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/physics/">physics</a>).
</p>
<p>Relativistic Rocket Kinematics</p>
Fixed Point Iteration in Python (Python)
2013-01-16T16:39:08-08:00Captain DeadBoneshttp://code.activestate.com/recipes/users/4184772/http://code.activestate.com/recipes/578418-fixed-point-iteration-in-python/
<p style="color: grey">
Python
recipe 578418
by <a href="/recipes/users/4184772/">Captain DeadBones</a>
(<a href="/recipes/tags/fixed_point/">fixed_point</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/python/">python</a>).
</p>
<p>The code utilizes fixed point iteration to solve equations in python. This code was wrriten for <a href="http://thelivingpearl.com/2013/01/15/the-easy-way-to-solve-equations-in-python/">How to solve equations using python</a>.</p>