0

My question is about Java programming.

The question is 1.

I struggle with where the $M$ comes from, and I do not understand this question very well. As in the final, it needs to find the array of $c$. The above are thoughts of mine. If they are wrong, please figure them out for me. and help me what this asks for, and what parameters I could use to find $c_j$ (the array) ? best wishes

Nerrit
  • 402
  • 1
    Could you try to be more specific about what you don't understand? Equation (7) is the definition of $M$, so there's not much to say about that. And the array $c$ isn't something that you should find, it's the input to the function that you're supposed to write. – Hans Lundmark Jan 03 '23 at 15:42
  • Does it match the subject if take xn and yn for the calculation of M (for equation 7)? Or M is got only with parameter yn, without xn, alpha, beta, gamma, k and array Cj? – Sophie Ma Jan 05 '23 at 02:35
  • As the text says, just compute all $x_j$ and $y_j$ up to $j=k$ (and the values you get will of course depend on all the parameters), then let $M$ be the greatest of the $y_j$. – Hans Lundmark Jan 05 '23 at 05:49

1 Answers1

0

Something like this (I do not do Java, but you get the idea...), so you see that array c is an input:

double minimizeM(double[] c, int k)
{
    doube min_M = Inf;
    double min_M_c;
    for (i = 0; i <size(c); i++) {
       this_M = max_M(...., gamma = c[i], ....);
       if min_M > this_M
           min_M = this_M;
           min_M_c = c[i];
    }
     return min_M_c;
}

double max_M(double x0, double y0, double alpha, double beta, double gamma, int k) { // Calculate xn and yn according to equation 4

....

// Return the maximum yn, equation 7.

return max(yn); }

In function max_M, instead of calculating x[n] and y[n] first, you can keep track of the maximum M you get for all 'k' in the loop itself.