# Maximize function with given parameter not working..

**URL:** <https://community.wolfram.com/t/maximize-function-with-given-parameter-not-working/15487>\
**Category:** Questions\
**Tags:** optimization\
**Created:** [March 12, 2020, 2:43am UTC](https://community.wolfram.com/t/maximize-function-with-given-parameter-not-working/15487 "2020-03-12T02:43:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jetestetout](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@jetestetout](https://community.wolfram.com/u/jetestetout)\
**Post date:** [March 12, 2020, 2:43am UTC](https://community.wolfram.com/t/maximize-function-with-given-parameter-not-working/15487/1 "2020-03-12T02:43:27Z")

</div>

Hi,  
Maybe a very basic syntax question…  
I tried to check functionality with text book example:

```
Maximize[{log(1+x) + b log(2-x), 1 >= x >= 0 },x] 

```

but it fails to find the analytical solution x = 2-b / 1+b  
(even if I add the explicit domain for b :

```
Maximize[{log(1+x) + b log(2-x), 1 >= x >= 0 && 1/2<=b<=2 },x] )

```

Do I miss something ?

 ![5922Capture.JPG](https://global.discourse-cdn.com/wolfram/original/3X/9/4/94f4a1d3308cd038d46fc2a7793c18acf8a5a615.jpeg)

If I choose a real value for b, it works.

 ![Capture.JPG](https://global.discourse-cdn.com/wolfram/original/3X/f/4/f417ed7555832494f437d6a02e83b12d1006e580.jpeg)

---

<div class="post-metadata">

**Author:** ![dontdont9](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@dontdont9](https://community.wolfram.com/u/dontdont9)\
**Post date:** [March 12, 2020, 5:38am UTC](https://community.wolfram.com/t/maximize-function-with-given-parameter-not-working/15487/2 "2020-03-12T05:38:34Z")

</div>

If you carefully consider all the cautions when using derivatives to find maxima then

```
solve {D[log(1+x) + b log(2-x),x] == 0, 1 >= x >= 0 } for x

```

immediately returns

```
x=(2-b)/(b+1) and 1/2 <= Re(b) <= 2 and Im(b) == 0

```

---

<div class="post-metadata">

**Author:** ![jetestetout](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@jetestetout](https://community.wolfram.com/u/jetestetout)\
**Post date:** [March 12, 2020, 7:08am UTC](https://community.wolfram.com/t/maximize-function-with-given-parameter-not-working/15487/3 "2020-03-12T07:08:27Z")

</div>

Thanks for the note. But I am still puzzled by the usage of this function.  
I had checked the reference : [Maximize—Wolfram Documentation](https://reference.wolfram.com/language/ref/Maximize.html)  
and it provides a similar example :

 ![8013Capture.JPG](https://global.discourse-cdn.com/wolfram/original/2X/1/175586d2ec59b7978d5c1a88baceb3a142cd9611.jpeg)

---

<div class="post-metadata">

**Author:** ![wjhnjust](https://avatars.discourse-cdn.com/v4/letter/w/45deac/32.png) [@wjhnjust](https://community.wolfram.com/u/wjhnjust)\
**Post date:** [March 12, 2020, 9:46am UTC](https://community.wolfram.com/t/maximize-function-with-given-parameter-not-working/15487/4 "2020-03-12T09:46:07Z")

</div>

I think it’s not a syntax question,the way you use function Maximize is right.

 ![360截图17610619073956.png](https://global.discourse-cdn.com/wolfram/original/3X/1/4/14a76e82891706482afadf983492cd37aae4b2bc.png)

---

<div class="post-metadata">

**Author:** ![anon\_91240867](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@anon\_91240867](https://community.wolfram.com/u/anon_91240867)\
**Post date:** [March 12, 2020, 11:45pm UTC](https://community.wolfram.com/t/maximize-function-with-given-parameter-not-working/15487/5 "2020-03-12T23:45:14Z")

</div>

I tried:

```
Maximize[{log (1 + x) + b log (2 - x), 1 >= x >= 0}, x]

```

and got plenty of output (conditional of course, as Neslon said must be).

Mathematica gives the maximum values with conditions and then the x coordinates which have them - together in a list.

x = 2-b / 1+b is an extraneous formula to the solution.

I suggest you think about whether the 3 solutions Mathematica gives can be put into that form using algebra and the conditions.
