math

calculation not working as expected.. any ideas?? (iphone / int)

I have a calculation which isn't working and I cannot work out why! int numHoursInWeek; int numDays; int averageSalary; int total_seconds_in_year = ((numHoursInWeek * 60 * 60) * numDays); NSLog(@"average sal in pence=%i", (averageSalary * 100)); NSLog(@"num seconds in year=%i", total_seconds_in_year); NSLog(@"cost per second=%i", ((a...

Is there a standard user interface paradigm for configuring the partition of a set of elements?

Consider you have a set of objects X (e.g., A, B, C, D) that you wish to divide into non-empty subsets that cover all of X. Mathematically, a partition of the set. So, at first you might treat them as all different, {{A}, {B}, {C}, {D}}. Alternatively, you could separate them into vowels and consonants, i.e. {{A}, {B,C,D}}. Or, arbitra...

Smooth local celing function

I have a gray-scale image and I want to make a function that closely follows the image is always grater than it the image smooth at some given scale. In other words I want a smooth function that approximates the maximum of another function in the local region while over estimating the that function at all points. Any ideas? My...

Function to determine number of unordered combinations with non-unqiue choices

I'm trying to determine the function for determining the number of unordered combinations with non-unique choices. Given: n = number of unique symbols to select from r = number of choices Example... for n=3, r=3, the result would be: (edit: added missing values pointed out by Dav) 000 001 002 011 012 022 111 112 122 222 I know th...

Solution to overdetermined systems

How to find solution to overdetermined systems in Macsyma, Scilab, Octave? ...

Different math rounding behaviour between Linux, Mac OS X and Windows

HI, I developed some mixed C/C++ code, with some intensive numerical calculations. When compiled in Linux and Mac OS X I get very similar results after the simulation ends. In Windows the program compiles as well but I get very different results and sometimes the program does not seem to work. I used GNU compilers in all systems. Some ...

Given 3 pts, how do I calculate the normal vector?

Given three 3D points (A,B, & C) how do I calculate the normal vector? The three points define a plane and I want the vector perpendicular to this plane. Can I get sample C# code that demonstrates this? ...

Counting solutions to linear inequalities

I am trying to solve a problem which I have reduced down to counting the number of integer solutions to a number of linear inequalities. I need to be able to count the number of solutions for any number of variables c_1, ..., c_n, but for n=3 the equations could be written as: Now, I know the values of n and r in advance and wish to f...

exploring mathematics of/in computer science

Hi, I have been working for two years in software industry. Some things that have puzzled me are as follows: There is lack of application of mathematics in current software industry. e.g.: When a mechanical engineer designs an electricity pole , he computes the stress on the foundation by using stress analysis techniques(read mathema...

Mapping Math and Javascript

After extensive research and fun learning about Google's mapping api, I am building a digital antenna map application. At this point, the next step in the project plan is to build a memory-map replication of the google map that is locating digital tv stations based upon input from the user's address. So, I am using this math code to form...

Math.random() - Not random

I created a jQuery plugin but I have a problem, I use the following code: Math.floor(Math.random()*500) I add the result to a element, but bizarrely the result is every time the same. If I add a alert() to the line after the random-number-generation, I get random values, why? I want to get without the alert() random integers. But how...

Best way to perform linear regression

Hi, I have a set of 5 values from experiment, E1, ..., E5 and results from 10000 different simulations, sim_A_B_C.out . From each simulation I get S1, ..., S5 . I want to study the correlation between experimental and simulated values. So I would like to perform linear regression for each set in a script that loops for the whole set of...

Extreme big/small number programming.

I am trying to do some extreme precise maths calculation of very big/small number. The very big number may have 10 - 50 digits and the very small number may have 10 - 50 decimal places. Can C++ do this? If not is there any other programming language that can handle this kind of number? ...

Generate all of the unique combinations of numbers that add up to a certain number.

Hi Everyone, I am writing a program to try to solve a math problem. I need to generate a unique list of all of the numbers that add up to another number. For example, all of the unqiue combinations of 4 numbers that add up to 5 are: 5 0 0 0 4 1 0 0 3 2 0 0 3 1 1 0 2 2 1 0 2 1 1 1 This is easy to brute force in perl but I am workin...

Format string into scientific notation [C++]

I have a string that looks like this: "0.4794255386042030002732879352156" which is approximately the sin(0.5). I would like to format the string to look a much nicer "4.794255386042e-1" How can I achieve this? Remember I am dealing with strings and not numbers (float, double). Also I need to round to keep the number as accurate as ...

Implementing a Hilbert map of the Internet

In the XKCD comic 195 a design for a map of the Internet address space is suggested using a Hilbert curve so that items from a similar IP adresses will be clustered together. Given an IP address, how would I calculate its 2D coordinates (in the range zero to one) on such a map? ...

What is the fastest semi-arbitrary precision math library?

I'm using long double in a C program to compute 2D images of the Mandelbrot Set but wish to have further precision to zoom deeper. Are there any performance gains to be had from an arbitrary precision maths library that can restrict the amount of precision as required, rather than leaping from long double precision straight into arbitra...

Why there is a discrepancy in the result?

If I apply Binet Formula and Recursive formula for finding the fibonaci series, there is a discrepancy in result. Why? Basically I am a student and it is our assignment to implement the fibbonacci series. So I while making the experiment I came across this situation. Thanks in advance ...

understanding matrix.transition(); as3

I am trying to understand the method transition that falls in the Matrix Class. I am using it to copy pieces of a bitMapData. But I need to better understand what transitions do. I have a tilesheet that has 3 images on it. all 30x30 pixels. the width of the total bitmap is 90pxs. The first tile is green, the second is brown, and the ...

Polarized shift of percentage values

Hi I have this in AS3 differencePercentage = Math.round(((Pay.init / Pay.current) * 100) - 100); and that gives me the difference in percent between initial and current pay, but it's reversed. When it's positive i.e. pay is above the initial value it says -X%, and when it's below it says X%. Is there any obvious way I'm not seeing to...