A New Kind of Science: The NKS Forum > Applied NKS > Trouble with Maximizing a function
Author
Sudarshan Baruah
Greifswald University
Germany

Registered: Nov 2004
Posts: 5

Trouble with Maximizing a function

hi,
I have got a problem to maximize a function which is:
total[m_]:=sqrt(q[m]^2+r[m]^2)

where,
q[m_]:=NIntegrate[t[s]*Sin[m*s],{s,0,2Pi}]
and
r[m_]:=NIntegrate[t[s]*Cos[m*s],{s,0,2Pi}]

Here, integration is over s and it is from 0 to 2 Pi. Values of t[s] are as follows:

t[s]=One, when s is between 0 and 3pi/18
t[s]=Two, when s is between 3pi/18 and 7pi/18

and so on in the interval 0 to Pi of s.
One, Two etc are unknown variables. This is achieved as:

t[s]:=Which[0 ≤ s ≤ 3Pi/18, One, 3Pi/18 ≤ s ≤ 7Pi/18, Two, 7Pi/18 ≤ s ≤ 10Pi/18, Three, 10Pi/18 ≤ s ≤ 18Pi/18, Four, 18Pi/18 ≤ s ≤ 21Pi/18, Five, 21Pi/18 ≤ s ≤ 25Pi/18, Six, 25Pi/18 ≤ s ≤ 28Pi/18, Seven, 28Pi/18 ≤ s ≤ 36Pi/18, Eight]

Now, when trying to maximize, for eaxmple, total[4_] as follows

Maximize[total[4_], {One, Two, Three, Four, Five, Six, Seven, Eight}]

I dont get a result. Could anyone point me the mistake?

Ultimately, I want to find the variables One, Two, Three....., Eight for which the function total[m_] for m=4 is maximum.

Report this post to a moderator | IP: Logged

12-01-2005 06:06 PM
Jason Cawley
Wolfram Science Group
Phoenix, AZ USA

Registered: Aug 2003
Posts: 712

First, this is not the right place for general Mathematica questions like this. You want the MathGroup list, which you can find here -

http://forums.wolfram.com/mathgroup/

To start with you can use Integrate, and do NMaximize on the resulting function of 9 variables - m, and your One, Two, etc. But I don't think it is particularly bounded, unless there are constraints on One, Two, etc that you haven't explained.

funct[m_, {One_, Two_, Three_, Four_, Five_, Six_, Seven_, Eight_}] :=
N[Sqrt[(Integrate[
Which[0 <=  s <  3Pi/18, One, 3Pi/18 <= s <  7Pi/18, Two,
7Pi/18 <=  s <  10Pi/18, Three, 10Pi/18 <=  s < 18Pi/18, Four,
18Pi/18 <=  s < 21Pi/18, Five, 21Pi/18 <=  s < 25Pi/18, Six,
25Pi/18 <=  s < 28Pi/18, Seven, 28Pi/18 <= s < 36Pi/18, Eight]*
Sin[m*s], {s, 0, 2Pi}]^2 +
Integrate[
Which[0 <=  s <  3Pi/18, One, 3Pi/18 <= s <  7Pi/18, Two,
7Pi/18 <=  s <  10Pi/18, Three, 10Pi/18 <=  s < 18Pi/18, Four,
18Pi/18 <=  s < 21Pi/18, Five, 21Pi/18 <=  s < 25Pi/18, Six,
25Pi/18 <=  s < 28Pi/18, Seven, 28Pi/18 <= s < 36Pi/18, Eight]*
Cos[m*s], {s, 0, 2Pi}]^2)]]

That is your function, and it gives numerical values for any arguments just fine. When you set m = 4 you still have eight more degrees of freedom though, and unless you have constraints on them...

See if that helps. If you need more, please ask at the link above rather than here - this is a forum for New Kind of Science discussions, rather than general Mathematica how-to's.

Report this post to a moderator | IP: Logged

12-01-2005 09:08 PM
Sudarshan Baruah
Greifswald University
Germany

Registered: Nov 2004
Posts: 5

Hi,
Thanks a lot for your reply. As you have said, there are constraints in each of the variables (One...Eight) for maximizing the function. I will try with NMaximize implementing the constraints.
Once again, thank you.

Report this post to a moderator | IP: Logged

12-02-2005 08:12 AM
Alex001

Registered: Aug 2012
Posts: 5

re

on the problem of maximizing submodular functions. That is, we are interested in solving problems of the form max. S⊆V f(S) subject to some constraints on S.

Report this post to a moderator | IP: Logged

02-16-2013 10:17 AM

wolframscience.com  |  wolfram atlas  |  NKS online  |  Wolfram|Alpha  |  Wolfram Science Summer School  |  web resources  |  contact us