math

crafting a class representing a fraction

what are some of the things i need to consider when designing this object this is all i can think of int nominator int denominator int sign this object can be used in a math operation ...

Javascript: Why is my code alerting to nothing?

I've written the following: var pages=["[www.facebook.com] Facebook is cool. ","[www.bbc.co.uk] British broadcasting corporation. "]; function findScoreC2(s){ var scores=[]; var percentageScores=[]; var contentsArray=[]; s=s.toLowerCase(); for(i=0;i<pages.length; i++){ contentsArray=pages[i].substring(pages[i].indexOf("]...

Calculating distance from latitude, longitude and height using a geocentric co-ordinate system

I've implemented this method in Javascript and I'm roughly 2.5% out and I'd like to understand why. My input data is an array of points represented as latitude, longitude and the height above the WGS84 ellipsoid. These points are taken from data collected from a wrist-mounted GPS device during a marathon race. My algorithm was to conve...

Recursion and permutations

Hi. Let's say that we have two boxes of pencils (in first box just blue and in second just red pencils). So the question now is, in how many ways can we put x red and y blue pencils in the line? Example: we have 3 Red pencils, and 1 Blue. Then we have 4 different ways. Combinations: BRRR, RBRR, RRBR, RRRB. So with 10 Red and 10 Blue ...

Rotating coordinates around an axis

I'm representing a shape as a set of coordinates in 3D, I'm trying to rotate the whole object around an axis (In this case the Z axis, but I'd like to rotate around all three once I get it working). I've written some code to do this using a rotation matrix: //Coord is a 3D vector of floats //pos is a coordinate //angles is a 3d vector...

Find a point between two point

I two concentric circles on the screen and I want the circle on the inside to move around while the user drags their finger around the outside of the larger circle. This means that I have two point, center of the larger circle and the point at which the user touched. How do I calculate where the center of the smaller circle should be? ...

Simple math question with LinQ, simple Join query, Nulls, etc.

I have 2 tables   1. Client   2. Operations Operations can result in: Credits or Debits ('C' or 'D' in a char field) along with date and ammount fields. I must calculate the balance for each client's account using linQ... The result should also show balance 0 for clients whom didn't make operations yet I have the following function wi...

Subsequent weighted algorithm for comparison

I have two rows of numbers ... 1) 2 2 1 0 0 1 2) 1.5 1 0 .5 1 2 Each column is compared to each other. Lower values are better. For example Column 1, row 2's value (1.5) is more accurate than row 1 (2) In normal comparison I would take to the sum of each row and compare to the other row to find the lowest sum (most...

Numpy, problem with long arrays.

I have two arrays (a and b) with n integer elements in the range (0,N). typo: arrays with 2^n integers where the largest integer takes the value N = 3^n I want to calculate the sum of every combination of elements in a and b (sum_ij_ = a_i_ + b_j_ for all i,j). Then take modulus N (sum_ij_ = sum_ij_ % N), and finally calculate the fre...

horner's rule C++

While trying to evaulate polynomials using Horner's Rule I have a sample code segment like so: int Horner( int a[], int n, int x ) { int result = a[n]; for(int i=n-1; i >= 0 ; --i) result = result * x + a[i]; return result; } I understand that a is an array of coefficients and that x is the value that I would like...

How to calculate the 3D line segment of two rectangles?

I am looking for a fast way to calculate the line segment of two given rectangles in 3D. For instance, each 3D rectangle is defined by its four vertices. A solution in any reasonable programming language will do. ...

making a variable value positive

I have a variable that will sometimes be negative and sometimes positive. Before I use it I need to make it positive. How can I accomplish this? ...

How can I modify the Smith-Waterman algorithm using substitution matrix to align proteins in Perl?

How can I modify the Smith-Waterman algorithm using a substitution matrix to align proteins in Perl? [citations needed] ...

numerical differentiation and integration in Java

Hi This is a bit of a longshot. Suppose I am sampling signal at a fixed rate (say once per second). Is there mathematical Java Library I can use to calculate/extract the following metrics from the sampled data? 1) The rate of change of the signal 2) An extrapolation/prediction of what the signal value will be in X seconds/minutes time Th...

String in scientific notation C++ to double conversion

Hi, I've got a database filled up with doubles like the following one: 1.60000000000000000000000000000000000e+01 Does anybody know how to convert a number like that to a double in C++? Is there a "standard" way to do this type of things? Or do I have to roll my own function? Right now I'm doing sth like this: #include <string> #in...

How to do the square root in PowerPoint VBA?

Here is some math code that adds A to B: Sub math() A = 23 B = 2 ABSumTotal = A + B strMsg = "The answer is " & "$" & ABSumTotal & "." MsgBox strMsg End Sub But how can I calculate a square root of ABSumTotal? Is it possible in PowerPoint VBA? ...

C/C++ Integer Operation

I found by chance that int a = (h/2)*w+ ( (h+1)/2-h/2 ) * (w+1)/2 ; is equal to int b = (w * h + 1) / 2 ; when w and h are positive integers (assume no overflow). Can you show me why these 2 are the same? edit : integer -> positive integer. ...

Prolog parse postfix math expressions

I solved this my self. I'll post the solution when were past due date for my homework. Okay, I'm going to build a parser or an evaluator. The de facto standard when parsing with prefix notation is to just use a stack. Add to the stack if input is a number, if it is an operator you can pop twice apply operator and put the result back on...

Calculating variance with large numbers

I haven't really used variance calculation that much, and I don't know quite what to expect. Actually I'm not too good with math at all. I have a an array of 1000000 random numeric values in the range 0-10000. The array could grow even larger, so I use 64 bit int for sum. I have tried to find code on how to calc variance, but I don't ...

3D Software Renderer with VB6

Hi, I am IT student and I have to make a project in VB6, I was thinking to make a 3D Software Renderer but I don't really know where to start, I found a few tutorials but I want something that goes in depth with the maths and algorithms, I will like something that shows how to make 3D transformations, Camera, lights, shading ... It does...