0

I am trying to complete the following sigma notation sum but I am honestly stuck, I am not sure how to proceed with the (Xi/2) to the power of i/2. I don't know if I am doing it right in the first place any help would be appreciated it this is the code i have so far.

public static double ComplexSumFunctionA (int[] input) {
    double [] arr15  = {1, 2, 3, 4, 5};
    double sum = 0;
    for (double i = 0; (i < arr15.length/2); i++) {

     }

    return 0;
}

enter image description here

Complex Sum Function

azro
  • 53,056
  • 7
  • 34
  • 70
Code
  • 23
  • 4
  • While I appreciate that you are only asking for help and not to actually do your homework for you, this question is one we cannot answer without defeating the purpose of this assignment. Please review your class notes and feel free to [edit] this question to be more specific with where you are having difficulty. Read also: [An open letter to students with homework problems](https://softwareengineering.meta.stackexchange.com/questions/6166/open-letter-to-students-with-homework-problems) – Joe C Dec 20 '18 at 21:04
  • What are `n` and `N` ? – azro Dec 20 '18 at 21:07
  • Well I am assuming that n is = to the amount of times the loop is to be ran which would be 5 and I have no clue what N is @azro – Code Dec 20 '18 at 21:11
  • @JoeC trust me I only come here as a last resort and very rarely and I also have read all the class notes the problem is there is no example code or any thing to do with this it only have standard sum for loop. – Code Dec 20 '18 at 21:12
  • Unfortunately, we cannot help you unless you can tell us where exactly you are having issues. Some useful resources: [Why is "Can someone help me?" not an actual question?](http://meta.stackoverflow.com/q/284236) and [How to ask a good question when I'm not sure what I'm looking for?](https://meta.stackoverflow.com/questions/262527/how-to-ask-a-good-question-when-im-not-sure-what-im-looking-for) – Joe C Dec 20 '18 at 21:14
  • Why 5 ? Why use arr15 and not input array ? – azro Dec 20 '18 at 21:14
  • @azro n is the array length that's what I meant sorry as the for loop while cycle 5 times – Code Dec 20 '18 at 21:17
  • @JoeC does stating that I do not know how to proceed with the (Xi/2) to the power of i/2 count as a specific issue? I do not know how to do to the power of – Code Dec 20 '18 at 21:18
  • Possible duplicate of [Raising a number to a power in Java](https://stackoverflow.com/questions/8842504/raising-a-number-to-a-power-in-java) – Joe C Dec 20 '18 at 21:20
  • Do a few iterations **on paper**, and write out all the details of the intermediate calculations. Those intermediate steps could become private methods used within the main loop. – Andrew S Dec 20 '18 at 21:20

1 Answers1

1

The notation xi means the value of ith value of x, so if x is an array it's the value in x[i]

  • I assumed N is also the array length
  • You get the value x[i]
  • You divide by 2
  • Then power to i/2
  • sum it as Sigma is for sum computation

Here it is

public static double complexSumFunctionA(int[] input) {
    double sum = 0, val;
    for (int i = 0; i < input.length; i++) {
        val = Math.pow(input[i] / 2.0, i / 2.0);
        sum += val;
    }
    return sum / (input.length + 3);
}
azro
  • 53,056
  • 7
  • 34
  • 70
  • So by looking at your code I'm guessing I had to you Math.pow to do the "to the power of"? – Code Dec 20 '18 at 21:25
  • @Code Also note that the `for` upper bound is `input.length` (not `input.length / 2`). I would also add `N` as another argument to the method – fps Dec 20 '18 at 21:27
  • @FedericoPeraltaSchaffner yes your right I see I will thank you – Code Dec 20 '18 at 21:35