Message Boards Message Boards

0
|
195 Views
|
9 Replies
|
5 Total Likes
View groups...
Share
Share this post:

I have problem to maximize a function

Posted 8 days ago

I have the below code, it does not give me the answer. can somebody help me?

POSTED BY: Reza rho
9 Replies

With version 12.0 I get an answer with this:

Maximize[{F[r, c], FunctionDomain[F[r, c], c]}, c]
POSTED BY: Gianluca Gorni
Posted 8 days ago

im sorry to say it doesnt work.

it gives these errors:

FunctionDomain::nmet: Unable to find the domain with the available methods.

FunctionDomain::ivar: 0.633070356251368` is not a valid variable.

FunctionDomain::ivar: 0.633070356251368` is not a valid variable.

POSTED BY: Reza rho

From your input I get the answer

{0.993421, {c -> 0.698707}}

I am using version 14.0.

POSTED BY: Gianluca Gorni
Posted 8 days ago

i have version 12. currently can't updade it.

POSTED BY: Reza rho
Posted 8 days ago

I foolishly assumed that the OP was using 14.0 and didn't even run the original code. After plotting the function and seeing that it was real only for -1 < c < +1, I (wrongly) assumed that did the trick.

So to get to the point: My answer is not necessary and yours works for both 14.0.0.0 and 13.3.1.0.

For Mathematica 12.3.1.0 adding in a restriction works:

Subscript[M, r] = Maximize[{F[r, c], -0.9539 < c < 0.9539}, c]
(* {0.993421, {c -> 0.698707}} *)

Also for 14.0.0.0 you can get an "exact" answer (in terms of a Root object) if you rationalize the constants, $a$ and $r$.

Jim

POSTED BY: Jim Baldwin
Posted 8 days ago

thank you so much it worked.

POSTED BY: Reza rho
Posted 8 days ago

Adding in a restriction on $c$ so that you only get real numbers on $F$ seeems to work:

Subscript[M, r] = Maximize[{F[r, c], -1 < c < 1}, c]
(* {0.993421, {c -> 0.698707}} *)
POSTED BY: Jim Baldwin
Posted 8 days ago

this didnt work it gives the below error:

NMaximize::nnum: The function value -F[0.2,-0.868794] is not a number at {c} = {-0.868794}.

POSTED BY: Reza rho
Posted 8 days ago

Sounds like you'll need to use FindMaximum instead of Maximize.

POSTED BY: Jim Baldwin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract