# Maximum gradient of function within a domain

I am making something on desmos and I need the maximum gradient of a function within a domain. I have no idea where to start.

f(x) {x:a<=x<=b}
find f'(x) max

The desmos graph plots the function f(x) with circles which are different colors depending on the gradient of the function. This works fine but, when dealing with a curve like x^2 where the gradient is forever increasing, we run out of colors quickly. This can be solved by dividing the gradient fed into the hue parameter by the maximum gradient but this will be a different number for each function you use as f(x).

Here is my desmos graph: https://www.desmos.com/calculator/xgrgkvnoqc

I tried searching this up online but everything went over my head and I don't know what to do with this. I also posted this to r/mathematics and was removed because too difficult. I then posted to another subreddit, nobody has been able to answer, and I was referred to this website.

Thanks :)

• Mathe

1. For a difficult question the bounty should be much larger. 2. Are you dealing only with functions of one variable? 3. Are you always restricted to a closed domain like [a,b]?

• Nahte2004

1. I’m not sure how hard this question is. I am studying towards my second year of A levels, it may just be something we haven’t covered yet. 2. I might not understand what you mean but things like an ellipse where you have x and y, don’t worry about that, just in terms of x. 3. Yes the function is always restricted to the domain, between a and b. If it was unrestricted I would have thought it would make it harder for some graph though where the gradient tends to infinity.

• Nirenberg

Do you have formulas for your functions in terms of x?

• Nahte2004

Sorry I don’t really understand what anyone is talking about. I want to be able to put things like polynomials, cos, cosh, all that stuff into it and it works.

• Nirenberg

What do you mean by "it works"? If you have explicit formulas for your functions, you can find the maximum points of $f'$ by computing the second derivative $f''$. Is this acceptable?

• Mathe

It's not clear what you want to do, sadly. But if you care only about the maximum of f'(x), you could take its derivative, set it to zero, find critical points and evaluate those critical points and the endpoints of the interval [a,b] to find its maximum. Because you are only working in an interval [a,b] you are guaranteed to find a maximum for f'(x) like this.

• Nahte2004

Sorry. Yes this is what I want it to do. I’m just not sure how to implement it on the graph.

• Nahte2004

I have formulas for my functions

• Nirenberg

You don't have to graph the functions to find the maximum of f'. Is that ok? It would be extremely easier as long as you can compute and solve f'' (x)=0.

• Nirenberg

I can give more details if that's ok with you.

• Nahte2004

Desmos doesn’t allow you to do that

• Nahte2004

I want to be able to set f(x) to anything I want and it calculates the second derivative, sets it to 0, solves it… I understand I could do this manually but I want this to be something it calculates and does itself

• Nirenberg

Desmos is not the right way to do this then. This problem is indeed very challenging, and needs a much more sophisticated approach.

• M F H

I will try to provide an answer as good as possible, but I also don't think desmos is the right tool to deal with this. I will give you better proposals. Also, your desmos graph (link) appears empty to me.

• Nahte2004

Oh god 🤦‍♂️ that would help. Hopefully what I am trying to do will be a more more clear when you see the graph. I have updated the link

• Nahte2004

If anyone is interested, I actually managed to get this working… to some extent. I made a list of the gradient at all plotted points, sorted it from smallest to largest, got the last value. I understand this is not going to be the true maximum gradient and only an estimation but it is close enough that for what I wanted it to do, it works fine. It doesn’t work for all graph. For some values of an and b the values of the sorted gradient list become undefined for some reason

• Nahte2004