1

I'm a novice programmer trying to do some rudimentary math & statistics.

When I come across standard math formulas, I usually need to convert the mathematical notation to either computer code (i.e. Python) or Excel syntax.

For example, someone mentioned using the normal equation in a related post: Basic Exponential Regression.

"...you can get variable $a$ directly from the normal equation:"

$$a=\frac{\sum_{i=1}^n x_iz_i } { \sum_{i=1}^n x_i^2 }=\frac{\sum_{i=1}^n x_i \log(21-y_i)} { \sum_{i=1}^n x_i^2 }$$


Question:

Are there any recourses that contain mathematical formulas that are written in computer code? (paid or unpaid)

User1974
  • 425
  • Most programming resources can tell you how to implement formulas. Many sums are for loops, for example. – Sean Roberson Jan 03 '22 at 00:16
  • The formulas at https://functions.wolfram.com have a link that will give you the code in Mathematica form. Click on the little ▶︎ to the left of the formula, to see it written in four different forms. – GEdgar Jan 03 '22 at 00:16
  • 2
    Mathematical notation has been around a lot longer than computer languages. You should be better off learning to read mathematical notation. – Somos Jan 03 '22 at 00:16
  • 1
    As for the most commonly used by general public, those are available in standard packages and libraries that you can import. NumPy and SciPy should have anything you need in python for regressions like you ask about here, possibly after first rephrasing the question into a polynomial regression like shown here. – JMoravitz Jan 03 '22 at 00:55
  • https://ece.uwaterloo.ca/~dwharder/C++/CQOST/src/ – shawn_halayka Jan 03 '22 at 00:58
  • 1
    Python has quite the nice syntax for summations: $$\text{sum(x[i]*math.log(21-y[i]) for i in range(1,n+1))}$$represents the numerator of the fraction on the right. – Rushabh Mehta Jan 03 '22 at 01:34
  • Just to be clear: are you saying you need to convert formulas to code in order to understand them, not because you need to use them in software? I usually find it is the other way around for me, despite decades of programming experience, when the code starts involving serious mathematics I have to document it in mathematical syntax to make sure I have the right code. – David K Jan 03 '22 at 04:19
  • Seems to me what you're looking for are mathematical software libraries such as https://scipy.org/ – Bananach Jan 04 '22 at 02:27
  • @RushabhMehta For what it's worth, I tried to describe the equation on the right in pseudo code: Step-1: For each record in the set, calculate xLN(21-y). Calculate the sum of those values (we'll call it "sum 1"). Step-2:* For each record in the set, calculate x^2. Calculate the sum of those values (we'll call it "sum 2"). Step-3: Divide sum 1 by sum 2. – User1974 Jan 05 '22 at 01:37
  • 1
    "Computer code" is a bit broad. For instance, many formulas like the one you displayed could be input into Mathematica code as, essentially, "interpret the following TeX code: ...". – Mark S. Mar 15 '22 at 11:55

0 Answers0