0
$\begingroup$

I am given $\alpha = \sin \theta \cos \phi$ and $\beta =\sin \theta \sin \phi$.

How should I proceed to find the maximum and minimum values for the below function subject to the constraint $x^2 +y^2 \leq 1$: $$f(\theta, \phi, x, y) =(\alpha x+\beta y)\left(x^2 +y^2 -2(\alpha x+\beta y)^2\right)$$

Also, what is the point which attains the maxima/minima?

What is the best way to do this?

$\endgroup$
3
  • 2
    $\begingroup$ Look up Minimize or NMinimize or the equivalent Maximize functions in the documentation. Try to express your functions in MMA code. Try to use those minimizers, then come back with any specific issues you run into. $\endgroup$
    – MarcoB
    Jan 31 at 15:03
  • $\begingroup$ @MarcoB I tried the following: Maximize[{(ax+by) (y^2 + x^2) -2 (ax^2 + by^2)^2 , x^2 + y^2 <= 1, a=sin(p)cos(q),b=sin(p)sin(q)}, {x, y}] It is saying no global maxima $\endgroup$
    – wanderer
    Jan 31 at 15:17
  • 2
    $\begingroup$ @wanderer 1) you're missing some spaces in there. It should read a x + b y for example. 2) In Mathematica you use [ ] for function calls, not ( ) so it's not sin(p) but Sin[p]. 3) You should not do the assignment of a,b inside the maximize, and 4) you are not constraining theta or phi and are not maximizing over those at all. $\endgroup$
    – flinty
    Jan 31 at 15:27

1 Answer 1

5
$\begingroup$
f[θ_, ϕ_, x_, y_] := (* here we set u = {α, β} *)
 With[{u = Sin[θ] {Cos[ϕ], Sin[ϕ]}, v = {x, y}},
  (u . v)*(v . v - 2 (u . v)^2)]
Minimize[{f[θ, ϕ, x, y], 0 <= θ <= 2 π, 
  0 <= ϕ <= 2 π, x^2 + y^2 <= 1}, {θ, ϕ, x, y}]
Maximize[{f[θ, ϕ, x, y], 0 <= θ <= 2 π, 
  0 <= ϕ <= 2 π, x^2 + y^2 <= 1}, {θ, ϕ, x, y}]
$\endgroup$
3
  • $\begingroup$ Thanks. It is working well. Just a follow up question, If I want to optimize the absolute value of the function, what do I use? Is there an abs function or anything similar? $\endgroup$
    – wanderer
    Jan 31 at 16:27
  • $\begingroup$ Also, when i changed the limit from $2\pi$ to $\pi$, I did not get a solution. What I got is this: Minimize[{(x Cos[[Phi]] Sin[[Theta]]+y Sin[[Theta]] Sin[[Phi]]) (x^2+y^2-2 (x Cos[[Phi]] Sin[[Theta]]+y Sin[[Theta]] Sin[[Phi]])^2),0<=[Theta]<=[Pi],0<=[Phi]<=[Pi],x^2+y^2<=1},{[Theta],[Phi],x,y}] $\endgroup$
    – wanderer
    Jan 31 at 16:43
  • $\begingroup$ @wanderer yes it's just Abs. Please search the documentation and have a read, as it sounds like you are very new to Mathematica. For the other question, I'm not sure why that happens, but try using the numerical methods NMaximize and NMinimize instead of Minimize/Maximize. $\endgroup$
    – flinty
    Jan 31 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.