math

Sum of products of two arrays (dotproduct)

First off, I know my title can be formulated better, but my math classes are so far gone I can't remember the correct words anymore.. I need to do something like this (pseudo c#) int[] digits1 = new int[10]{0,1,2,3,4,5,6,7,8,9}; int[] digits2 = new int[10]{0,1,2,3,4,5,6,7,8,9}; int result = digits1*digits2 This would be the sum of th...

c#: whats the easiest way to subtract time?

Hey guys, ive seen a couple posts on this but nothing so far that is specific to this simple operation. I'm trying to put together a tool that will help me make work schedules. What is the easiest way to solve the following: 8:00am + 5 hours = 1:00pm and 5:00pm - 2 hours = 3:00pm and 5:30pm - :45 = 4:45 and so on. ...

Determine the Scale Factor in Maps

Given only the set of coordinates, is there a way to find the scale factor being used? It will then be used to compute the distances between the coordinates. Let's consider this: On a map scale: (This is the only given) pointA(33.511615, -86.778809) pointB(34.398558, -87.669116) On a real world scale: Distance between the 2 poi...

Quickly cross-check complex Math Results?

I am doing matrix operations on large matrices in my C++ program. I need to verify the results that I get, I used to use WolframAlpha for the task up until now. But my inputs are very large now, and the web interface does NOT accept such large values (textfield is limited). I am looking for a better solution to quickly cross-check/do ma...

what kind of programming requires math?

This is not a "is math required for programming?" question. I always thought that for programming, a scary amount of complicated math would be involved (I only got as far as intermediate algebra in college because I'm bad with it). However, I just got my first job as a developer and have found there is not a ton of math above basic ar...

Is there a mathematical relationship between a bitpattern and the mirror of that bitpattern?

For a given bitpattern, is there a mathematical relationship between that pattern and the mirror image of that pattern? E.g. we start with, say, 0011 1011. This mirrors to 1101 1100. We can mechanically mirror the pattern easily enough. But is there in fact a mathematical relationship between the pattern and its mirror? ...

General - Is there a way to calculate an average based off of an existing average and given new parameters for the resulting average?

Lets say, we're calculating averages of test scores: Starting Test Scores: 75, 80, 92, 64, 83, 99, 79 Average = 572 / 7 = 81.714... Now given 81.714, is there a way to add a new set of test scores to "extend" this average if you don't know the initial test scores? New Test Scores: 66, 89, 71 Average = 226 / 3 = 75.333... Normal ...

How can I take the modulus of two very large numbers?

I need an algorithm for A mod B with A is a very big integer and it contains digit 1 only (ex: 1111, 1111111111111111) B is a very big integer (ex: 1231, 1231231823127312918923) Big, I mean 1000 digits. ...

GPS coordinates: 1km square around a point

Greetings, I was hoping someone out there could provide me with an equation to calculate a 1km square (X from a.aaa to b.bbb, Y from c.ccc to c.ccc) around a given point, say lat=53.38292839 and lon=-6.1843984? I'll also need 2km, 5km and 10km squares around a point. I've tried googling around to no avail... It's late at night and was ...

Drawing a triangle in a coordinate plane given its three sides

The length of three sides of the triangle, a, b and c will be given, and I need to find the coordinates of the vertices. The center (probably the circumcenter) can either be the origin or (x,y). Can anyone point me in the right direction? ...

Probability of rolling a 5 on second roll...

Ok so not really a programming question but not sure where it would go on the stack network... Dice has 6 sides so rolling a 5 will be a 1/6 (16.6%) chance. If the dice roll is a 2, does that mean the changes of rolling a 5 now have gone up, and that the changes of rolling a 2 have gone down? Since the odds of rolling two 2's in a row ...

Selecting Randomly Lowest Weighted

There are plenty of SO questions on weighted random, but all of them rely on the the bias going to the highest number. I want to bias towards the lowest. My algorithm at the moment, is the randomly weighted with a bias towards the higher values. double weights[2] = {1,2}; double sum = 0; for (int i=0;i<2;i++) { sum += weights[i]; } d...

A traveling salesman like problem

Given a set of points in the 2D Euclidean plane: P={V1,V2,..,Vn}, and we assume that there are K different types of points:T1,T2,..,TK, every point Vi in P belongs to exactly one of the K types. Definition of KTSP tour: Given an arbitrary location point V0 in the same 2D Euclidean plane (V0 has no type), a path V0->V'1->V'2->V'3->....-...

how to add dynamic math to webpage

Hi, I'm a math teacher wanting to insert some dynamic math into a website. What I'd like to achieve is to have a button that a student can press to randomly vary a question so that it's the same type of question, but with different numbers. For example, Factor the quadratic expression of the form ax^2 + bx + c, where a = 1, and b and c ...

Is it OK to use Math.Pow (10, n)?

I need to compute power (10, n) Is it OK to use Math.Pow (10, n)? Or should I use a loop? for (int i = 0; i < n; i++){ x*=10; } Which one is better? and why? ...

Language or package for drawing geometric diagrams

I am looking for a language, or package in an existing language, that is good for specifying and drawing geometric diagrams. For example, I would like to draw a hexagonal grid, with its dual triangular grid superimposed on it. Now, I could sit down, put some elbow grease in to work out the trig by hand and come up with some Postscript o...

sequential search analysis

Hi All, I am reading algorithms in C++ by Robert Sedwick it was mentioned as follows Sequential search in an ordered table examines N numbers for each search in the worst case and about N/2 numbers for each search on average. This result follows from assuming that the search is equally likely to terminate at any ...

Write Euler's method in Mathematica

Hello, I would like to write a function that has a loop in it which preforms the operations necessary for Euler's method. Below it my poor attempt. In[15]:= Euler[icx_,icy_,h_,b_,diffeq_] := curx; cury; n=0; curx = icx; cury = icy; While [curx != b, Print["" + n + " | " + curx + cury]; n++; dq = StringReplace[diffeq, "y...

Rotated rectangle bounding box size

If I have a given rectangle, with the width w, height h and angle r How large does another rectangle which contains all points of the rotated rectangle need to be? I would need this to perform fast bounding box checks for a 2D physics engine I am making ...

Math Equations for Random Snow in a Snow Globe

I've been experimenting with this and I haven't been able to come up with an adequate solution. Hoping one of you Mathletes can point me in the right direction. I'm building a Snow Globe in ActionScript 3 and I need to come up with a set of equations to control two level of snowflakes - one level random, and the other interactive where ...