I have problem to maximize a function

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

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}} *)

From your input I get the answer

{0.993421, {c -> 0.698707}}

I am using version 14.0.

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

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}.

With version 12.0 I get an answer with this:

Maximize[{F[r, c], FunctionDomain[F[r, c], c]}, c]

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.

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

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

thank you so much it worked.