# Thread: Program/method to find the maxima of a large (yet simple) equation

1. ## Program/method to find the maxima of a large (yet simple) equation

I have an equation that looks like:

$\displaystyle \frac{x m_1 + (1-x) m_2}{\sqrt{x^2 v_1 +(1-x)^2 v_2 + 2x(1-x)c}}$

where m1 and m2 are means, v1 and v2 are variances and c is the covariance(m1, m2).

My objective is to find the absolute maxima of this equation.

This can be easily solved by taking the first derivative, set the equation to zero and solving for x.

Now, suppose that I have N of that equation, where the i index refers to the index of the ith equation, i.e., i = 1,...N.

My objective would be to find the maxima of the following equation:

$\displaystyle \sum_{i = 1}^N \omega_i\frac{x m_1_i + (1-x) m_2_i}{\sqrt{x^2 v_1_i +(1-x)^2 v_2_i + 2x(1-x)c_i}}$

where W_i is the weight in the running sum of the ith equation. Note that I have all values W_i, m1_i, m2_i, var1_i, var2_i and c_i. I need to find the value of x that maximizes the above mentioned sum.

I can easily solve this numerically, but I believe there is a smarter way. Since my background is in Biomedical Sciences, I would be really grateful for any help from math experts. There is any program/algorithm that I might use, for example?

Cheers!

Alonso

P.S. I can easily solve that problem numerically, because I now the value of x will be constrained on the interval [-5,+5]

2. It might be helpful to see the equation in Latex. Is the following correct?

$\displaystyle \frac{x m_1 + (1-x) m_2}{\sqrt{x^2 var_1 +(1-x)^2 var_2 + 2x(1-x)c}}$

This can be reproduced by the following latex statement (for future reference):

$$\frac{x m_1 + (1-x) m_2}{\sqrt{x^2 var_1 +(1-x)^2 var_2 + 2x(1-x)c}}$$

3. Hi, Bryan. Thank you very much for the example. I could not use latex, because I could not understant it here. With you example, I could figure it out. Thanks!

4. There's a forum around here somewhere that is dedicated to Latex question. If you keep talking math, you have to learn it! There's also plenty of online resources to look up examples and codes for what you want to express. Good job on converting your first post to latex.