math

How do I find the next multiple of 10 of any integer?

Dynamic integer will be any number from 0 to 150. i.e. - number returns 41, need to return 50. If number is 10 need to return 10. Number is 1 need to return 10. Was thinking I could use the ceiling function if I modify the integer as a decimal...? then use ceiling function, and put back to decimal? Only thing is would also have to kn...

camera translation vector - relation to rotation matrix

I am working with some code which outputs a 3x3 rotation matrix and a translation vector representing a cameras orientation and location. However, the documentation states that to get the location of the camera one must multiply the transposed and inverted rotation matrix by the translation vector. Does that mean that the original vect...

Cartesian product of several vectors

Hi, similar questions have been asked before but I cant find an exact match to my question. I have 4 vectors each of which hold between 200-500 4 digit integers. The exact number of elements in each vector varies but I could fix it to a specific value. I need to find all possible combinations of the elements in these 4 vectors. eg: ...

Non-linear counter

So I have a counter. It is supposed to calculate the current amount of something. To calculate this, I know the start date, and start amount, and the amount to increment the counter by each second. Easy peasy. The tricky part is that the growth is not quite linear. Every day, the increment amount increases by a set amount. I need to recr...

Can you explain(mathematical calculations) gesture example (Levenshtein )?

I got the example in this link. I can't understand the addmove, costLeven and meatureGesture methods. Can you explain it step by step? ...

Any math approaches to state management of complex objects?

I usually use ASP.net web forms for GUI, maybe one of most "stateful" technologies. But it applies to any technology which has states. Sometimes forms are tricky and complex, with >30 elements and > 3 states of each element. Intuitive way of designing such a form usually works for 90%. Other 10% usually find testers or end-users:). The...

How to break up data into good sized parts

I'm writing a multi-length-output hash function, but I've hit as stumbling block: how can i break up input data in such a way that the program will not have to deal with extremely long lists or run too many loops for the given data? a = input length in bytes, a>=0 b = output length in nibbles, b>0 minimal padding is done to the data be...

How to find a factorial?

How can I write a program to find the factorial of any number? ...

Should I Teach My Son Programming? What approaches should I take?

I was wondering if it's a good idea to teach object oriented programming to my son? I was never really good at math as a kid, but I think since I've started programming it's given me a greater ability to understand math by being better able to visualise relationships between abstract models. I thought it might give him a better advantage...

Random Number generator function ran2 Numerical Recipes

Hi, Given that we start the call to the function ran2 with a negative integer [the seed] it will produce a series of random numbers. The sequence can be regenerated exactly if the same seed is used. Now my question is that is there a way that we can directly enter into some point in the sequence and then continue from that point onwar...

C - Rounding integer division up (instead of truncating)

I was curious to know how I can round a number to the nearest tenth whole number. For instance, if I had: int a = 59 / 4; which would be 14.75 calculated in floating point; how can I store the number as 15 in "a"? ...

Uses of a C++ Arithmetic Promotion Header

I've been playing around with a set of templates for determining the correct promotion type given two primitive types in C++. The idea is that if you define a custom numeric template, you could use these to determine the return type of, say, the operator+ function based on the class passed to the templates. For example: // Custom nume...

Infix to Postfix and unary/binary operators

I have a piece of code that converts an infix expression to an expression tree in memory. This works just fine. There's just one small trouble. I just connect work out how to involve the unary operators correctly (the right associative ones). With the following infix expression : +1 + +2 - -3 - -4 I would expect an RPN of: 1+2++3-4...

Test if a number is fibonacci

I know how to make the list of the Fibonacci numbers, but i don't know how can i test if a given number belongs to the fibonacci list - one way that comes in mind is generate the list of fib. numbers up to that number and see if it belongs to the array, but there's got to be another, simpler and faster method. Any ideas ? ...

Distance from a point to a polyhedron or to a polygon

I have a surface which is a polyhedron and I want to find the minimal distance between it and a given point P. Since the polyhedron is defined by many polygons in a 3d space, one way that occurs to me is to compare the distance to each polygon and choose the shortest distance. Still I am not sure about it. ...

Given a decimal number, find the smallest integer multiplier that gives an integer result

Best to use an example to describe the problem. Lets say I have a decimal value 100.227273. 100.227273 * X = Y I need to find the smallest positive integer X that gives integer Y. ...

Ruby factorial function

I'm going crazy: Where is the Ruby function for factorial? No, I don't need tutorial implementations, I just want the function from the library. It's not in Math! I'm starting to doubt, is it a standard library function? ...

Looking for interesting formula

I'm creating a game where players can make an alloy. To make it less predictable and more interesting, I thought that the durability and hardness of an alloy should not be calculated by a simple formula, because it will be extremely easy to find extrema, where alloy have best statistics. So the questions is, is there any formula for a f...

What is the the relation between programming and mathematics?

Possible Duplicate: Is Programming == Math? Programmers seem to think that their work is quite mathematical. I understand this when you try to optimize something in performance, find the most efficient alogithm, etc.. But it patently seems false when you look at a billing application for a shop, or a systems software riddled...

Can you help me optimize this code for finding factors of a number? I'm brushing up on my math programming.

I've never really bothered with math programming, but today I've decided to give it a shot. Here's my code and it's working as intended: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; us...