title: Mathematical notation to programming code
body: <p>I have difficulties with transcripting the following two functions written in mathematical notation into Java code (the input of both functions is an array with D elements):</p>
  
  <p><img src="https://i.stack.imgur.com/adQTN.png" alt="enter image description here"></p>
  
  <p>Can somebody take a look at the code below and tell me if something is wrong with it?</p>
  
  <pre><code>public double firstFunction(double[] arrayOfElements) {
  
  double sum = 0;
  double sumTwo = 0;
  
  for(int i = 0; i &lt; arrayOfElements.length; i++) {
      for(int j = 0; j &lt; i; j++){
          sumTwo = sumTwo + arrayOfElements[j];
      }
      sum = sum + Math.pow(sumTwo, 2);
      }
      return sum;
  }
  
  public double secondFunction(double[] arrayOfElements) {
      double maximum = Math.abs(arrayOfElements[0]);
      for (int i = 0; i &lt; arrayOfElements.length; i++) {
          if (Math.abs(arrayOfElements[i]) &gt; maximum) {
              maximum = Math.abs(arrayOfElements[i]); 
          }
      }
      return maximum;
  }
  </code></pre>