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: desmos attempt 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.

The result should look like this (ignore the values and scale)

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:comparator which returns 0 if x>n; 1 if x<=n. This might help with the conditional function I'm looking for. Thank you.

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

1 Answer 1


I'll preface this by stating that I'm not entirely sure if I understand what kind of function you are trying to achieve.

Some points I noticed:

  • It appears that this function can only be iteratively defined, which puts it out of scope for graphing on Desmos. (see point 3)
  • 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<x\leq n_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)

I think that the path of least resistance for you would be to code the function in C++ and output its values to a .csv file and then plot that.

  • $\begingroup$ Cool, thanks! It's good to know that you "think that the path of least resistance for you would be to code the function in C++ and output its values to a .csv file and then plot that". I've done similar things before. Having a second opinion confirm what I guessed is good. It turns out that our control system is so precise and fast that, while I wrote something like described above, it hardly ever oscillates and hits the target velocity in less than a second, which is good enough for us. Although this is math stack exchange, I have to say that sometimes I think too much about the math! $\endgroup$ Commented Oct 19, 2022 at 23:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .