Reputation: 1392
How should it be representation of math functions while writing pseudocode for example for square, square root vs.?
if (b[i] > 0) {
axb = axb + (a[i] * b[i]);
asquare = asquare + Math.pow(a[i], 2);
bsquare = bsquare + Math.pow(b[i], 2);
}
How can I represent this expression in pseudocode?
Upvotes: 1
Views: 3988
Reputation: 28292
Represent them in whatever way is clear and concise. You can use standard mathematical notation, if you like, or if that's too hard to use in your editor, the caret operator ^
is often used for exponentiation, sqrt()
is used for the square root, and for other powers and roots, exponentiation should be sufficient (i.e., x^3
or x^(1/3)
, etc.).
Upvotes: 1