# Numerical real solution of derivative

I would like to know where a function attains its maximum, so I'm trying to solve some

diff(y,x),x

where y depends on y. I have difficulties with Sage returning equations, complex roots, converting equations, find_maximum_on_interval command etc, and instead of spending another hour trying to figure it out myself, I thought I would try asking here...

Here is a more concrete example:

f = log(2.02 * x + 1) / 2 + log( -2 * x + 1) / 2

find_local_maximum(diff(f,x), 0, 1)

What is mysterious for me, is that the above works if instead I have

f = log(1.01 * x + 1) / 2 + log( -x + 1) / 2

It would make it easier to understand your problem, and to provide an answer, if you could provide a reproducible example, i.e. enough code to reproduce the equations, complex roots, and converting equations you mention. This would also increase the value of both question and answer for others who might face similar a challenge in the future.

I have added an example.

Check this. It seems to work fine. If you need precision it is possible you need to use octave or matlab instead of sage.

The same issue persists - changing the variable x to 2x shouldn't make a difference, but it does. This might not even be an issue with precision, very weird.