# how to make a function, on Desmos, that, if h(x) is over n, then h(x) = f(x), but if h(x) is below n, then h(x)=g(x)

I'm trying to represent on Desmos what my C++ Vex robotics flywheel control code would do, so that I can close in on an optimal constant in the equation without testing it on the robot, because that is 10s of x more time consuming, and imprecise. I have three equations: The bottom one is obviously incorrect but I am including it because it explains more concisely than words could what I want the function to be. The image below also shows what I know the graph of the speed control would look like, oscillation down towards minimal error, a threshold at which I would tell it to give up oscillating and just put in the end voltage; I didn't include that here because I didn't want more of a struggle with Desmos.

If you know an answer that uses another software besides Desmos, that's fine with me, I just use Desmos because it's what I know and it generally works great for me. I'm basically asking what is the syntax for representing this with a graphing software; I could write it in C++ code, but then I wouldn't see what it looks like, and seeing it greatly helps me find solutions faster.

In the desmos image, b is the initial velocity at the first check, since the flywheel will be stimulated before the first check. v is the desired velocity of the flywheel. I also found this equation: which returns 0 if x>n; 1 if x<=n. This might help with the conditional function I'm looking for. Thank you.

• Welcome to Math SE! Pease use MathJAX to type the math in your questions. You can find a nice tutorial here. Thank you! Commented Oct 16, 2022 at 23:03
• ok, I will next time, but it's done now, and it's plenty readable, if not copy-pasteable Commented Oct 16, 2022 at 23:06

• Does your function $$h$$ take into account that there is a critical $$n$$ value (define this to be $$n_0:=e^{1/e}$$). Where $$g(x) < f(x)$$ for all $$x>n_0$$. However, no such inequality holds on $$0 because you can get intervals in $$\mathbb{R}$$ such that $$g(x)\geq f(x)$$.
• The example you've provided at the bottom of the question $$I(x,n)$$ behaves like an indicator on the x-inputs of $$I$$. Whereas the question in the title is concerned with some indicator behavior conditioned on the outputs of $$h$$ (ie. they are describing two different things)