Popular recipes tagged "math" but not "mathematics"http://code.activestate.com/recipes/tags/math-mathematics/2017-06-06T03:48:09-07:00ActiveState Code RecipesInteractive Mandelbrot Fractal Using HTML5 Canvas (JavaScript)
2017-06-06T03:48:09-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/580804-interactive-mandelbrot-fractal-using-html5-canvas/
<p style="color: grey">
JavaScript
recipe 580804
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/canvas/">canvas</a>, <a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/math/">math</a>).
</p>
<p>Interactive Mandelbrot Fractal Using HTML5 Canvas.</p>
<p>(Download and save as html file and open it.)</p>
<p>(Tested only using Firefox browser.)</p>
Roman Numeral Converter (Python)
2016-12-13T05:05:52-08:00Brandon Martinhttp://code.activestate.com/recipes/users/4194238/http://code.activestate.com/recipes/580731-roman-numeral-converter/
<p style="color: grey">
Python
recipe 580731
by <a href="/recipes/users/4194238/">Brandon Martin</a>
(<a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/numbers/">numbers</a>, <a href="/recipes/tags/numerals/">numerals</a>, <a href="/recipes/tags/roman/">roman</a>).
</p>
<p>Provides two functions:
romanToNumber - Converts a string of Roman Numerals (I,V,X,L,C,D,M) into an integer. (ignores formatting, will return best guess if improperly formatted)
numberToRoman - Converts an integer into a string of Roman Numerals</p>
Auto differentiation (Python)
2016-08-07T22:02:10-07:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/580610-auto-differentiation/
<p style="color: grey">
Python
recipe 580610
by <a href="/recipes/users/178123/">Raymond Hettinger</a>
(<a href="/recipes/tags/autodifferentiation/">autodifferentiation</a>, <a href="/recipes/tags/calculus/">calculus</a>, <a href="/recipes/tags/descent/">descent</a>, <a href="/recipes/tags/gradient/">gradient</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/optimization/">optimization</a>, <a href="/recipes/tags/vector/">vector</a>).
Revision 5.
</p>
<p>Directly computes derivatives from ordinary Python functions using auto differentiation. The technique directly computes the desired derivatives to full precision without resorting to symbolic math and without making estimates bases on numerical methods.</p>
<p>The module provides a Num class for "dual" numbers that performs both regular floating point math on a value and its derivative at the same time. In addition, the module provides drop-in substitutes for most of the functions in the math module. There are also tools for partial derivatives, directional derivatives, gradients of scalar fields, and the curl and divergence of vector fields.</p>
Projectile Motion (Python)
2016-04-08T01:42:01-07:00Tage Burnetthttp://code.activestate.com/recipes/users/4193902/http://code.activestate.com/recipes/580638-projectile-motion/
<p style="color: grey">
Python
recipe 580638
by <a href="/recipes/users/4193902/">Tage Burnett</a>
(<a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/physics/">physics</a>, <a href="/recipes/tags/python/">python</a>).
</p>
<p>This program calculates the characteristics of a projectile in a vacuum at several different locations in our solar system.</p>
Get the inversion number of a permutation (Python)
2016-02-21T06:00:46-08:00Samuel James Ericksonhttp://code.activestate.com/recipes/users/4187478/http://code.activestate.com/recipes/579051-get-the-inversion-number-of-a-permutation/
<p style="color: grey">
Python
recipe 579051
by <a href="/recipes/users/4187478/">Samuel James Erickson</a>
(<a href="/recipes/tags/combinatorics/">combinatorics</a>, <a href="/recipes/tags/discrete/">discrete</a>, <a href="/recipes/tags/inversion/">inversion</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/permutations/">permutations</a>).
Revision 2.
</p>
<p>This function takes a permutation in the form of a list and returns the number of inversions in the permutation. </p>
Garden Requirements Calculator (Python)
2014-09-17T22:04:36-07:00Ethan Hannhttp://code.activestate.com/recipes/users/4190746/http://code.activestate.com/recipes/578935-garden-requirements-calculator/
<p style="color: grey">
Python
recipe 578935
by <a href="/recipes/users/4190746/">Ethan Hann</a>
(<a href="/recipes/tags/calculator/">calculator</a>, <a href="/recipes/tags/garden/">garden</a>, <a href="/recipes/tags/math/">math</a>).
</p>
<p>This program takes input from the user and determines the amount of gardening materials needed for a garden. The garden is a perfect square. The four outer flowerbeds are congruent semicircles and the central flowerbed is a perfect circle. Everything else inside the garden is considered fill: stone, mulch, or other fill material.</p>
Factorial (Python)
2014-03-08T13:09:41-08:00Johnhttp://code.activestate.com/recipes/users/4189390/http://code.activestate.com/recipes/578848-factorial/
<p style="color: grey">
Python
recipe 578848
by <a href="/recipes/users/4189390/">John</a>
(<a href="/recipes/tags/factorial/">factorial</a>, <a href="/recipes/tags/loop/">loop</a>, <a href="/recipes/tags/loops/">loops</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/range/">range</a>, <a href="/recipes/tags/simple/">simple</a>).
</p>
<p>Just a simple factorial program I made in Python 3.</p>
dynamic mathjax demo page (HTML)
2015-02-12T13:10:17-08:00yotahttp://code.activestate.com/recipes/users/4184815/http://code.activestate.com/recipes/578679-dynamic-mathjax-demo-page/
<p style="color: grey">
HTML
recipe 578679
by <a href="/recipes/users/4184815/">yota</a>
(<a href="/recipes/tags/latex/">latex</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathjax/">mathjax</a>).
Revision 7.
</p>
<p>Html web page to preview latex equations rendered by mathjax. <a href="http://jsfiddle.net/r82p49xx/5/">demo here</a></p>
<p>Equations are updated when shift, space or enter keys are pressed, or when the Textarea lose focus.</p>
<p>In the first block you can try inline-style math, in the second one, display-style math.</p>
Russian Multiplication in Python (Python)
2013-06-18T15:25:02-07:00Captain DeadBoneshttp://code.activestate.com/recipes/users/4184772/http://code.activestate.com/recipes/578567-russian-multiplication-in-python/
<p style="color: grey">
Python
recipe 578567
by <a href="/recipes/users/4184772/">Captain DeadBones</a>
(<a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/multiplication/">multiplication</a>, <a href="/recipes/tags/python/">python</a>).
</p>
<p>Here is a very simple program in Python to multiply 2 numbers. This version follows the Russian Multiplication Algorithm. I worte for my blog <a href="http://thelivingpearl.com/basic-multiplication-in-python/">Captain DeadBones Chronicles</a></p>
Dynamical Billiards Simulation (Python)
2013-06-20T06:57:57-07:00Steve Wadleyhttp://code.activestate.com/recipes/users/4186942/http://code.activestate.com/recipes/578572-dynamical-billiards-simulation/
<p style="color: grey">
Python
recipe 578572
by <a href="/recipes/users/4186942/">Steve Wadley</a>
(<a href="/recipes/tags/chaos/">chaos</a>, <a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/pil/">pil</a>, <a href="/recipes/tags/random/">random</a>).
</p>
<p>It simulates reflections of a ball on a billiards table that has one or more circular obstacles.
(This can also be thought as a 2d ray-tracing.)</p>
<p>Most of the time the path of the ball would be chaotic (meaning, if another ball started from any slightly different location or direction then its path would be very different after a short while). </p>
<p>See Wikipedia for more info:
<a href="http://en.wikipedia.org/wiki/Dynamical_billiards" rel="nofollow">http://en.wikipedia.org/wiki/Dynamical_billiards</a></p>
Simple Addition Multiplication in Python (Python)
2013-06-18T15:21:45-07:00Captain DeadBoneshttp://code.activestate.com/recipes/users/4184772/http://code.activestate.com/recipes/578565-simple-addition-multiplication-in-python/
<p style="color: grey">
Python
recipe 578565
by <a href="/recipes/users/4184772/">Captain DeadBones</a>
(<a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/multiplication/">multiplication</a>, <a href="/recipes/tags/python/">python</a>).
</p>
<p>Here is a very simple program in Python to multiply 2 numbers. I worte for my blog <a href="http://thelivingpearl.com/basic-multiplication-in-python/">Captain DeadBones Chronicles</a></p>
Ten's Multiplication Algorithms in Python (Python)
2013-06-18T15:23:36-07:00Captain DeadBoneshttp://code.activestate.com/recipes/users/4184772/http://code.activestate.com/recipes/578566-tens-multiplication-algorithms-in-python/
<p style="color: grey">
Python
recipe 578566
by <a href="/recipes/users/4184772/">Captain DeadBones</a>
(<a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/multiplication/">multiplication</a>, <a href="/recipes/tags/python/">python</a>).
</p>
<p>Here is a very simple program in Python to multiply 2 numbers. This is following a Ten's multiplication algorithms. I worte for my blog <a href="http://thelivingpearl.com/basic-multiplication-in-python/">Captain DeadBones Chronicles</a></p>
Archimedes Method for PI (arbitrary precision) (Python)
2013-03-02T21:56:42-08:00Bjorn Madsenhttp://code.activestate.com/recipes/users/4176352/http://code.activestate.com/recipes/578478-archimedes-method-for-pi-arbitrary-precision/
<p style="color: grey">
Python
recipe 578478
by <a href="/recipes/users/4176352/">Bjorn Madsen</a>
(<a href="/recipes/tags/decimal/">decimal</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/pi/">pi</a>, <a href="/recipes/tags/precision/">precision</a>, <a href="/recipes/tags/python3/">python3</a>).
</p>
<p>The code below incorporates the newly revised python 3.3.0 decimal module to permit arbitrary precision (<a href="http://docs.python.org/3/library/decimal.html%29" rel="nofollow">http://docs.python.org/3/library/decimal.html)</a></p>
<p>The recipe was originally by FB35 from <a href="http://code.activestate.com/recipes/576981-archimedes-method-for-calculating-pi/" rel="nofollow">http://code.activestate.com/recipes/576981-archimedes-method-for-calculating-pi/</a> </p>
Greatest Common Divisor using Recursion in Python (Python)
2013-01-16T16:44:46-08:00Captain DeadBoneshttp://code.activestate.com/recipes/users/4184772/http://code.activestate.com/recipes/578421-greatest-common-divisor-using-recursion-in-python/
<p style="color: grey">
Python
recipe 578421
by <a href="/recipes/users/4184772/">Captain DeadBones</a>
(<a href="/recipes/tags/gcd/">gcd</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/python/">python</a>).
</p>
<p>I wrote this little piece of code as part of my ongoing python-math projects. For more information please checkout <a href="http://thelivingpearl.com">The Living Pearl</a>. </p>
Simple linear regression (Python)
2012-05-12T13:36:55-07:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/578129-simple-linear-regression/
<p style="color: grey">
Python
recipe 578129
by <a href="/recipes/users/4174477/">Thomas Lehmann</a>
(<a href="/recipes/tags/decrease/">decrease</a>, <a href="/recipes/tags/increase/">increase</a>, <a href="/recipes/tags/linear/">linear</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/percental/">percental</a>, <a href="/recipes/tags/regression/">regression</a>, <a href="/recipes/tags/simple/">simple</a>).
Revision 3.
</p>
<p><strong>What?</strong></p>
<ul>
<li>It's about forecasting.</li>
<li>It's about calculating a linear function.</li>
<li><em>Details I found</em>: <a href="http://www.faes.de/Basis/Basis-Statistik/Basis-Statistik-Korrelation-Re/basis-statistik-korrelation-re.html" rel="nofollow">http://www.faes.de/Basis/Basis-Statistik/Basis-Statistik-Korrelation-Re/basis-statistik-korrelation-re.html</a> (in german)</li>
</ul>
<p>Also I don't know how the formula have been created the practical part was very easy to me. I have verified one example (see code) using Open Office Calc (I've learned: you can display the formula for the trend line as well as the coefficient of correlation - great).</p>
<p><strong>Why?</strong></p>
<ul>
<li>In <a href="http://code.activestate.com/recipes/578111/">recipe 578111</a> I'm printing out current error rate for different training sessions in mental arithmetic.</li>
<li>Anyway I would like to be able to given information - approximately - about how many you have improved since you train yourself.</li>
</ul>
<p><strong>What has changed?</strong></p>
<ul>
<li><strong>Revision2</strong>: Didn't compile with Jython 2.5.3b1 because of not supported exception syntax. Now it does work without exception.</li>
<li><strong>Revision3</strong>: Test data row for failure not removed.</li>
</ul>
Learning to calculate (mental arithmetic) (Python)
2012-05-11T03:49:48-07:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/578111-learning-to-calculate-mental-arithmetic/
<p style="color: grey">
Python
recipe 578111
by <a href="/recipes/users/4174477/">Thomas Lehmann</a>
(<a href="/recipes/tags/learning/">learning</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/persistence/">persistence</a>, <a href="/recipes/tags/statistic/">statistic</a>, <a href="/recipes/tags/training/">training</a>).
Revision 4.
</p>
<p><strong>What is it about?</strong></p>
<ul>
<li>Learning to use the basic math operation (+, -, *,/).</li>
<li>Print out of statistics to show you where you are.</li>
<li>Being able to define your own training sessions.</li>
<li>Sessions with number of tasks or with a time limit.</li>
</ul>
<p><strong>What has changed?</strong></p>
<ul>
<li>Revision 2: Contains now the <strong>tasks numbering</strong>.</li>
<li>Revision 2: You can see overall how long you didn't a training.</li>
<li>Revision 2: You also can see per kind of session how long you didn't a training.</li>
<li>Revision 3: <strong>Trainings parameter as kind of policy</strong> in a separate class also used as key for statistic.</li>
<li>Revision 3: <strong>New session type</strong>: timeout (as many tasks as possible until timeout exceeded)</li>
<li>Revision 3: I'm also sorry to say that this revision breaks compatibility with previously stored sessions.</li>
<li>Revision 4: <strong>Integer division</strong> supported.</li>
</ul>
Solve simultaneous linear equations in two variables (Python)
2012-01-24T14:20:01-08:00Anand B Pillaihttp://code.activestate.com/recipes/users/4169530/http://code.activestate.com/recipes/578024-solve-simultaneous-linear-equations-in-two-variabl/
<p style="color: grey">
Python
recipe 578024
by <a href="/recipes/users/4169530/">Anand B Pillai</a>
(<a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/shortcuts/">shortcuts</a>, <a href="/recipes/tags/solver/">solver</a>).
</p>
<p>A function to solve simultaneous equations in two variables. </p>
<pre class="prettyprint"><code>>>> solve('3*x + 5*y = 29; 12*x - 3*y = 24')
(3.0, 4.0)
</code></pre>
Random Binary List (Python)
2011-11-09T19:38:14-08:00Alexander James Wallarhttp://code.activestate.com/recipes/users/4179768/http://code.activestate.com/recipes/577944-random-binary-list/
<p style="color: grey">
Python
recipe 577944
by <a href="/recipes/users/4179768/">Alexander James Wallar</a>
(<a href="/recipes/tags/base/">base</a>, <a href="/recipes/tags/binary/">binary</a>, <a href="/recipes/tags/list/">list</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/numbers/">numbers</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/random/">random</a>, <a href="/recipes/tags/random_binary_list/">random_binary_list</a>).
</p>
<p>This recipe returns a list of size n such that the contents of the returned list are random 0s and 1s. It returns a random binary list of size n.</p>
Encrypt and Decrypt Text and Text Files (BETA) (Python)
2011-11-22T04:18:15-08:00Alexander James Wallarhttp://code.activestate.com/recipes/users/4179768/http://code.activestate.com/recipes/577954-encrypt-and-decrypt-text-and-text-files-beta/
<p style="color: grey">
Python
recipe 577954
by <a href="/recipes/users/4179768/">Alexander James Wallar</a>
(<a href="/recipes/tags/cryptography/">cryptography</a>, <a href="/recipes/tags/cryptology/">cryptology</a>, <a href="/recipes/tags/decrypt/">decrypt</a>, <a href="/recipes/tags/decryption/">decryption</a>, <a href="/recipes/tags/encrypt/">encrypt</a>, <a href="/recipes/tags/encryption/">encryption</a>, <a href="/recipes/tags/hidding/">hidding</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/text/">text</a>, <a href="/recipes/tags/text_files/">text_files</a>).
Revision 7.
</p>
<p>This program interactively lets you encrypt and decrypt text as well as text files using a key system as well as a cipher.</p>
Wasted Money Calculator (Python)
2012-01-26T02:27:25-08:00userendhttp://code.activestate.com/recipes/users/4179007/http://code.activestate.com/recipes/578026-wasted-money-calculator/
<p style="color: grey">
Python
recipe 578026
by <a href="/recipes/users/4179007/">userend</a>
(<a href="/recipes/tags/calculate/">calculate</a>, <a href="/recipes/tags/calculator/">calculator</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/money/">money</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/save/">save</a>, <a href="/recipes/tags/tkinter/">tkinter</a>).
Revision 2.
</p>
<p>Calculate the amount of money you waste on the unnecessary items you buy everyday. </p>