0

I am trying to use Maximize function Maximize[{x^2 + y^2, a*x^4 + b *y^4 + c == 1}, {x, y}] But I want Mathematica to consider only b to be the parameter, because a and c is only some constants (with many values). I need only to study how the maxima change with b.

Is there anyway to Mathematica which is parameters and which is constant? I tried to set the SetAttribute[a, Constant], but Mathematica still consider a to be parameter. hope someone can help.

  • 2
    Why isn't the result of Maximize[{x^2 + y^2, a*x^4 + b*y^4 + c == 1}, {x, y}] useful? You might want to add constraints to a,b,c as well; surely there are constraints for those constants too? – J. M.'s missing motivation Aug 01 '17 at 03:24
  • I just want to see the evolution of the maximum when the parameter b change. For example, a and c are material parameters and b is the applied force, which I can vary continuously. I have only 3 materials, so for each material, I consider a and c as constant and just want to check how the maximum change when the applied force changes. – KhoaPhan Aug 01 '17 at 04:57
  • also can you explain what is the meaning of True in the result of Maximize[{x^2 + y^2, x^4 + a y^4 == 1}, {x, y}] It does not mean that "this is always true". Why Mathematica don't just say " a<0" – KhoaPhan Aug 01 '17 at 04:59
  • The line with the True condition is the "otherwise" case; see this for instance. You say that a and c are "material parameters", and b is a force. Can they be negative? – J. M.'s missing motivation Aug 01 '17 at 05:30
  • In my case all material parameters are positive. About force it can be negative. Thank – KhoaPhan Aug 02 '17 at 07:32
  • 1
    See, you had constraints on the constants after all! If so, you should be doing Maximize[{x^2 + y^2, a*x^4 + b *y^4 + c == 1 && a > 0 && c > 0}, {x, y}]. – J. M.'s missing motivation Aug 02 '17 at 14:20

1 Answers1

1

First solve for the y that fulfill the conditions in dependance of x (since a and c are material parameters, I supposed them to be greater 0)

sol[x_, a_, b_, c_] = 
   Solve[a*x^4 + b*y^4 + c == 1 && a > 0 && c > 0, y, Reals]

(*     {{y -> ConditionalExpression[-((1 - c - a x^4)/b)^(
 1/4), (0 < a < (1 - c)/x^4 && 0 < c < 1 && b > 0 && 
   x > 0) || (0 < a < (1 - c)/x^4 && 0 < c < 1 && x < 0 && 
   b > 0) || (0 < c < 1 && b < 0 && a > (1 - c)/x^4 && 
   x > 0) || (0 < c < 1 && b < 0 && x < 0 && 
   a > (1 - c)/x^4) || (b < 0 && a > 0 && c > 1 && 
   x > 0) || (b < 0 && x < 0 && a > 0 && c > 1)]}, {y -> 
      ConditionalExpression[((1 - c - a x^4)/b)^(
1/4), (0 < a < (1 - c)/x^4 && 0 < c < 1 && b > 0 && 
   x > 0) || (0 < a < (1 - c)/x^4 && 0 < c < 1 && x < 0 && 
   b > 0) || (0 < c < 1 && b < 0 && a > (1 - c)/x^4 && 
   x > 0) || (0 < c < 1 && b < 0 && x < 0 && 
   a > (1 - c)/x^4) || (b < 0 && a > 0 && c > 1 && 
   x > 0) || (b < 0 && x < 0 && a > 0 && c > 1)]}}     *)

Calculate the xmax depending on a,b,c

xmax[a_, b_, c_] = 
    x /. Maximize[x^2 + y^2 /. sol[x, a, b, c][[1]], x][[2]]

enter image description here

(Maximize of course also gives you the hight of the maximum, not shown here)

For example plot for a=1 ond c=1/2

Plot[xmax[1, b, 1/2], {b, 0, 3}]

enter image description here

Plot[y /. sol[xmax[1, b, 1/2], 1, b, 1/2], {b, 0, 3}]

enter image description here

At last, consider, that there are two equal maxima, one at xmax and one at -xmax. Have a look with

Manipulate[
    Plot[Evaluate[x^2 + y^2 /. sol[x, a, b, c][[1]]], {x, -1, 1}], {{a, 
       1}, -3, 3}, {{b, 1}, -4, 4}, {{c, 1/2}, -3, 3}]
Akku14
  • 17,287
  • 14
  • 32
  • Thank you very much for reply. Although this is not my purpose, but your answer is very informative for me. interwhat – KhoaPhan Aug 04 '17 at 02:55
  • Actually, I recognize that Mathematica can not give answer to optimize a function vs a parameter while you tell it to ignore other parameters. I think it is impossible, mathematically, because the number of solution and the solution value depend on the condition of all parameters. – KhoaPhan Aug 04 '17 at 09:14