Message Boards Message Boards

0
|
8495 Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Maximize not working properly with constraints

Posted 9 years ago

I want to find the maximums of

Sqrt[x]*Abs[BesselJ[1,x]]
Sqrt[x]*Abs[BesselJ[2,x]-BesselJ[0,x]]

in a specified interval, for example Interval[{0,10}].

This code doesn't work:

NMaximize[{Sqrt[Abs[x]]*BesselJ[1, x], x \[Element] Interval[{0, 10}]}, x]

It returns the peculiar error that "the objective function ..... should be scalar-valued."

What is the correct way to go about this, and why does what I tried not work?

Incidentally, does Mathematica compute maxima rigorously to however many significant figures? Such that if mathematica says the maximum of a function is 1.57, you can say with certainty that it is less that 1.6?

POSTED BY: Jonathan Holmes
3 Replies

Not sure why Interval[] is not working, but try the following.

NMaximize[{Sqrt[Abs[x]]*BesselJ[1, x], 0 <= x <= 10}, x]

POSTED BY: Gerard Kopcsay

Hi,

this should work:

NMaximize[Sqrt[Abs[x]]*BesselJ[1, x], 0 < x < 10, x]

and likewise

NMaximize[Sort[x]*Abs[BesselJ[2, x] - BesselJ[0, x]], 0 < x < 10, x]

If you want to work with interval, this should help

NMaximize[
 Sqrt[Abs[x]]*BesselJ[1, x], {x} \[Element] Interval[{0, 10}]]

If you want to increase the precision, this should do

NMaximize[Sqrt[Abs[x]]*BesselJ[1, x], {x} \[Element] Interval[{0, 10}], WorkingPrecision -> 30]

Cheers,

Marco

PS: Sorry posted nearly at the same time as the previous answer.

POSTED BY: Marco Thiel

Thanks! I have another problem now, but it's a topic for another thread... The problem I had here is solved.

POSTED BY: Jonathan Holmes
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