math

Better algorithm for estimating download time

Possible Duplicate: Estimating/forecasting download completion time We've all seen the download time running estimate that initially says something like "7 days", but keeps dropping wildly (e.g. "23 hours", "45 minutes", "1 min. 50 sec", etc) with each successive estimation as the chunks are downloaded. To avoid these initial...

is two's complement addition of two positive numbers the same as normal addition?

if i have two positive integers, say 0x1234 and 0x5678, is 0x8765 + 0xfedc = 0x8641, if the '+' means two's complement addition, mod 2^16? ...

Octave / Matlab: How to plot the roots of a polynomial

Hi everyone, Im trying to plot the roots of a polynomial, and i just cant get it. First i create my polynomial p5 = [1 0 0 0 0 -1] %x^5 - 1 r5 = roots(p5) stem (p5) Im using the stem function, but I would like to remove the stems, and just get the circle around the roots. Is this possible, is stem the right command? Thanks in adva...

PHP Find Coordinates between two points

Hi all, simple question here. Lets say I have two points: point 1 x = 0 y = 0 point 2 x = 10 y = 10 How would i find out all the coordinates inbetween that programmatically, assuming there is a strait line between two points... so the above example would return: 0,0 1,1 2,2 3,3 ... 8,8 9,9 10,10 Thanks :) ...

How to generate correlated binary variables

Dear All: I need to generate a series of N random binary variables with a given correlation function. Let x = {xi} be a series of binary variables (taking the value 0 or 1, i running from 1 to N). The marginal probability is given Pr(xi = 1) = p, and the variables should be correlated in the following way: Corr[ xi xj ] = const |ij| (...

floor of double(time_t)

I cannot understand why this throws undefined reference to `floor'": double curr_time = (double)time(NULL); return floor(curr_time); Hasn't it been casted to double, which is what floor receives? ...

Scale 2D coordinates and keep their relative euclidean distances intact?

I have a set of points like: pointA(3302.34,9392.32), pointB(34322.32,11102.03), etc. I need to scale these so each x- and y-coordinate is in the range (0.0 - 1.0). I tried doing this by first finding the largest x value in the data set (maximum_x_value), and the largest y value in the set (minimum_y_value). I then did the following: p...

How to get points that intersect the trendline?

Basically I did the Cavendish experiment, and I have a damped sinusoidal wave plotted on Excel. With Position (mm) against Time (s). My problem is that I have added a tread line through the wave function, and wish to calculate the points of which the wave function intersects the tread line. From this I will then be able to calculate the...

Detect&find intersection ray vs. cubic bezier triangle

While writing a model editor, besides enabling raytracing I can think about couple of operations where I'd like to find an very good approximation about the intersection point between a ray and a triangular bezier patch. How to do this? I know couple of ways but likely there's better ones. Exact use-cases: I might want to use one bezie...

MySQL Math - Is it possible to calculate a correlation in a query?

In a MySQL (5.1) database table there is data that represents: how long a user takes to perform a task and how many items the user handled during the task. Would MySQL support correlating the data or do I need to use PHP/C# to calcuate? Where would I find a good formula to calculate correlation (it's been a long time since I last d...

Fast, Vectorizable method of taking floating point number modulus of special primes?

Is there a fast method for taking the modulus of a floating point number? With integers, there are tricks for Mersenne primes, so that its possible to calculate y = x MOD 2^31-1 without needing division. integer trick Can any similar tricks be applied for floating point numbers? Preferably, in a way that can be converted into vect...

CODE1 Spoj - cannot solve it

I am trying to solve the problem Secret Code and it's obviously math problem. The full problem For those who are lazy to go and read, it's like this: a0,a1,a2,...,an - sequence of N numbers B - some number known to us X = a0 + a1*B + a2*(B^2) + a3*(B^3) + ... + an*(B^n) So if you are given B and X, you should find a0,a1,..an. I don...

Hexagonal Grid Coordinates To Pixel Coordinates

I am working with a hexagonal grid. I have chosen to use this coordinate system because it is quite elegant. This question talks about generating the coordinates themselves, and is quite useful. My issue now is in converting these coordinates to and from actual pixel coordinates. I am looking for a simple way to find the center of a hex...

Calculate total batch upload transfer percent with limited information

Hi there, I have a system which uploads to a server file by file and displays a progress bar on file upload progress, then underneath a second progress bar which I want to indicate percentage of batch complete across all files queued to upload. Information and algorithms I can work out are: Bytes Sent / Total Bytes To Send = First pro...

Normalize amplitude and phase with c#

Hey I'm in the situation where i need to do some math related stuff in c# and for that i need some external libarys. The tool i look for should do the following actions: Process sound(wave/mp3): Normalize the amplitude Normalize the phase Any idea which way to go? And is there a big difference if I should to it on mp3 instead of w...

Arrangement of n objects in a n x n square

if have multiples object, how to arrange it so that each number of object in row x column will form a near square? exp:14 objects arrange to something like this: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

Determining the popularity of a video with ratings and views

I am about to embark on a new project - a video website. Users will be able to register, and vote on videos by clicking "like" or "dislike", or something to that effect. In any event, it will be a 2-option voting system, not a 5-star system. Every X number of days, I will be generating a "chart" of the most popular videos. So my questi...

maple 13 tridiagonal matrix help

i am trying to make a 100 x 100 tridiagonal matrix with 2's going down the diagonal and -1's surrounding the 2's. i can make a tridiagonal matrix with only 1's in the three diagonals and preform matrix addition to get what i want, but i want to know if there is a way to customize the three diagonals to what ever you want. maplehelp doe...

how can i calculate the polynomial that has the following asymptotes

how can i calculate the polynomial that has the tangent lines (1) y = x where x = 1, and (2) y = 1 where x = 365 I realize this may not be the proper forum but I figured somebody here could answer this in jiffy. Also, I am not looking for an algorithm to answer this. I'd just like like to see the process. Thanks. I guess I should ha...

Is there any Mathematical Model or Theory behind Programming Languages?

RDBMS are based on Relational Algebra as well as Codd's Model. Do we have something similar to that for Programming languages or OOP? ...