2
$\begingroup$

I'm a student at a college with only two units of mathematics and I don't know if I'm asking in the right place so please bear with me.

I'm currently reading GPU Gems by nvidia and I have a question. It uses Sigma, as in summation, and integral a lot, but when look at the implementation of some of these algorithms, for example, Perlin noise, I can't find any sort of "summation" i.e.:

sum = 0
for i in range(x):
    sum += f(i)

They just convert the Sigma's formula to code. As for integral, I was never very good at them so I have a very weak foundation in them --- Therefore I can't even close to imagine how to convert an integral from an algorithm to code. I know integrals are two things: the area beneath the curve, and the reverse of the derivative --- But how can you derive an algorithm?

For example, this is from the Worely noise algorithm. How do you translate it to code, like Python, or anything?

Worely noise

I'm not asking for code, just explanation. And I hope this is the right place. Thank you.

$\endgroup$
4
  • $\begingroup$ This like asking ask "code $x^2 + 3x = 0$". I'm not sure what that means. I suspect that some context is missing. $\endgroup$ Commented Mar 6, 2019 at 8:09
  • $\begingroup$ @YuvalFilmus You've touched on exactly what I want. Just as x^2+3x = 0 -> x * x* + 3 * x, I want to know how to deal with Summation and Integrals in algorithm -> Summation and Integrals in code. If you think there's a book that can help me, please don't hesitate to introduce it. There are many books on the subject of algorithms, and my college doesn't have algorithms as a separate topic. Thank you. $\endgroup$ Commented Mar 6, 2019 at 8:16
  • $\begingroup$ My point was that your program never contains anything that corresponds to "$x^2 + 3x = 0$". It could possibly contain something like "let $x$ be a solution of $x^2 + 3x = 0$". This is why I'm not sure how to related your clip to an algorithm. As it stands, it's just a random equation. $\endgroup$ Commented Mar 6, 2019 at 8:19
  • $\begingroup$ @YuvalFilmus I understand what you mean. I got my answer, and the answer is that I should stop looking for short solutions and read a book on computer algebra. Thanks. $\endgroup$ Commented Mar 6, 2019 at 8:21

1 Answer 1

2
$\begingroup$

You are probably looking at a rather mathematical sketch of an algorithm. There are two general roads to implement non-trivial mathematical expressions such as series, integrals, and differential equations.

  1. If you want exact, potentially symbolic results you have to simplify "complex" expressions into closed forms on paper, and/or employ computer algebra.
  2. If you are satisfied with numerical, potentially approximate solutions, you want to employ numerical algorithms, including error estimations.
$\endgroup$
2
  • $\begingroup$ I don't have good book recommendations on either; both are full-fledged fields of active research with decades of history. Specific questions are ontopic here, but the numerical end of things is probably better served over on Computational Science. The mathematical parts of both avenues can certainly be asked on Mathematics as well. There is also Mathematica if you decide to use Mathematica, a good but proprietary and expensive computer algebra system. $\endgroup$
    – Raphael
    Commented Mar 6, 2019 at 8:26
  • $\begingroup$ As I said in the main topic, computer algebra is what I want, because GPU want exact results. Thanks. $\endgroup$ Commented Mar 6, 2019 at 8:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.