math

Is there an easily available implementation of erf() for Python?

I can implement the error function, erf, myself, but I'd prefer not to. Is there a python package with no external dependencies that contains an implementation of this function? I have found http://pylab.sourceforge.net/packages/included_functions.html>this but this seems to be part of some much larger package (and it's not even clear wh...

Best preparation material for TAOCP?

There are apparently a lot of people who don't finish reading TAOCP. One thing I've consistently noted in people's responses is being unable to handle all of the math in the series. What books or other materials do people recommend reading/understanding prior to TAOCP to make it more digestible? Assume the reader already has a good under...

linear transformation function

Problem: I need to write a function that takes 4 bytes as input, performs a reversible linear transformation on this, and returns it as 4 bytes. But wait, there is more: it also has to be distributive, so changing one byte on the input should affect all 4 output bytes. The issues: if I use multiplication it won't be reversible after ...

Math Resources for C/C++ Programmers

My degree is in Electrical and Computer Engineering but i'm currently employed as a Software Engineer. I took all of the algebra, geometry and calculus classes that one would expect from someone with my degree however I must admit, I think I learned just enough to pass the test but never really saw a use for it and therefore never really...

Rotate image math (C#)

I have an image with two points, aligned something like this: |----------------| | | | . | | | | . | | | |----------------| I have both X, Y coordinates for both points and I need to rotate the image X degrees so it looks like this instead: |----------------| | ...

Best way to represent a fraction in Java?

I'm trying to work with fractions in Java. I want to implement arithmetic functions. For this, I will first require a way to normalize the functions. I know I can't add 1/6 and 1/2 until I have a common denominator. I will have to add 1/6 and 3/6. A naive approach would have me add 2/12 and 6/12 and then reduce. How can I achieve a...

Way to infer the size of the userbase of a site from sampling taken usernames

I just had a clever idea (I think). Suppose you wanted to estimate the size of a userbase of a site which does not publicize this information. People are more likely to have acquired different usernames with different probabilities. For instance, if the username 'nick' doesn't exist on the system, it's likely to have an extremely small...

Why can't programs be proven?

Why can't a computer program be proven just as a mathematical statement can? A mathematical proof is built up on other proofs, which are built up from yet more proofs and on down to axioms - those truths truths we hold as self evident. Computer programs don't seem to have such a structure. If you write a computer program, how is it th...

How useful are math and science in programming?

Much of the material taught these days under the guise of computer science could be more accurately called software engineering, and a great deal of programming is more about gluing together widgets rather than coming up with brand new widgets that work better or do something weird and new. However, there are some clever people who have ...

Algorithm to find two points furthest away from each other

Im looking for an algorithm to be used in a racing game Im making. The map/level/track is randomly generated so I need to find two locations, start and goal, that makes use of the most of the map. The algorithm is to work inside a two dimensional space From each point, one can only traverse to the next point in four directions; up, dow...

Efficient evaluation of hypergeometric functions

Does anyone have experience with algorithms for evaluating hypergeometric functions? I would be interested in general references, but I'll describe my particular problem in case someone has dealt with it. My specific problem is evaluating a function of the form 3F2(a, b, 1; c, d; 1) where a, b, c, and d are all positive reals and c+d >...

Algorithm for modeling expanding gases on a 2D grid

I have a simple program, at it's heart is a two dimensional array of floats, supposedly representing gas concentrations, I have been trying to come up with a simple algorithm that will model the gas expanding outwards, like a cloud, eventually ending up with the same concentration of the gas everywhere across the grid. For example a giv...

What is the equation to calculate the CurrentGroup

Trying to figure out an equation to get the current group a page would be in if they were grouped like below. Variables: PageSize = 5 PageIndex = 21 GroupSize = 5 TotalItems = 1000 CurrentPage = PageIndex + 1 Find: **CurrentGroup = ?** If there are 1000 items and you have a group size of 5 then there are 200 groups (TotalItems / G...

Java: Round to arbitrary values

In Java, how do I round to an arbitrary value? Specifically, I want to round to .0025 steps, that is: 0.032611 -> 0.0325 0.034143 -> 0.0350 0.035233 -> 0.0350 0.037777 -> 0.0375 ... Any ideas or libs? ...

Learning game programming (part 2) (math)

So, it's been a few months since I wrote this question, since then I've toyed with "raw" C++ D3D, The Ogre and Irrlicht graphics engines and lately Microsoft XNA. I've built a few 2D games (mostly replicas of old stuff like tetris, astreoids, etc.) and made some (very) small steps into the 3D world in the above mentioned technologies. I...

How to split a NSDecimalnumber between decimal & integer & back

I can't figure how get the integral & decimal value from a NSDecimalnumber. For example, if I have 10,5, how get 10 & 5? And if I have 10 & 5, how return to 10,5? ...

Best language to program some math? (free, fast, easy, cool, etc)

I'm trying to teach some guys who don't know much of programming and need to do lots of math. We need to optimize some functions using derivatives, max, min and some sums. But then again we are talking of functions, not numbers, so i was going to teach them matlab, but apparently they had a bad experience trying to learn matlab (and pr...

Converting polar coordinates to rectangular coordinates

Convert angle in degrees to a point How could I convert an angle (in degrees/radians) to a point (X,Y) a fixed distance away from a center-point. Like a point rotating around a center-point. Exactly the opposite of atan2 which computes the angle of the point y/x (in radians). Note: I kept the original title because that's what peo...

How do you calculate the average of a set of angles?

I want to calculate the average of a set of angles. For example, I might have several samples from the reading of a compass. The problem of course is how to deal with the wraparound. The same algorithm might be useful for a clockface. The actual question is more complicated - what do statistics mean on a sphere or in an algebraic space...

How to add two NSNumber objects?

Now this must be easy, but how can sum two NSNumber? Is like: [one floatValue] + [two floatValue] or exist a better way? ...