eigen_enthused
eigen_enthused

Reputation: 535

What are common approaches for implementing common white paper math idioms in code

I am looking for a resource that can explain common math operations found in white papers in terms that that coders with minimal math background can understand in terms of coding idioms -- for loops etc.

I frequently see the same kinds of symbols in different equations and that the often result in easily comprehensible algorithms. An overview of what the symbols mean would go a long way to making academic paper more comprehensible.

Upvotes: 1

Views: 162

Answers (3)

andrew cooke
andrew cooke

Reputation: 46882

the only ones i can think of that are not obvious (arithmetic, trig functions etc) and have a direct equivalent in code are sum, Σ, and product Π.

so something like Σ a[i] is:

 sum = 0;
 for (i = 0; i < len(a); ++i) sum += a[i];

and some related details: a subscript (small number below the line) is often the same as an array index (so the i in Σ a[i] might be written small, below and to the right of the a). similarly the range of the i value (here 0 to the length of a) may be given as two small numbers just to the right of the Σ (start value, 0, at the bottom, finish value, n, at the top).

and the equivalent product is Π a[i]:

product = 1;
for (i = 0; i < len(a); ++i) product *= a[i];

update in the comments xan suggests covering matrices too. those get complicated, but at the simplest you might see something like:

a[i] = M[i][j] b[j]

(where it's much more likely that the i and j are subscripts, as described above). and that has implied loops:

for (i = 0; i < len(a); ++i) {
    a[i] = 0;
    for (j = 0; j < len(b); ++j) a[i] += M[i][j] * b[j]
}

worse, often that will be written simply as a = M b and you're expected to fill everything in yourself....

update 2 the first equation in the paper you reference below is w(s[i],0) = alpha[d] * Size(s[i]). as far as i can see, that's nothing more than:

double Size(struct s) { ... }

double w(struct s, int x) {
    if (x == 0) return alpha[d] * Size(s);
    ...
}

and other terms are similarly fancy-looking but not actually complicated function calls and multiplications. note that |...| is abs(...) and the "dot" is multiplication (i think).

Upvotes: 2

Orbiting Eden
Orbiting Eden

Reputation: 1512

I use this site all the time for complex mathematical operations translated to code. I never graduated high school.

http://www.wolframalpha.com/

Upvotes: 2

duffymo
duffymo

Reputation: 308763

"Common math operations" depends on the kinds of problems you're used to solving. They can range all the way from simple arithmetic (+, -, *, /) to calculus (integrals, summations, derivatives, partial differential equations, matricies, etc.)

What does "common" mean to you and your development team?

Upvotes: 1

Related Questions