# Code for a simple optimization problem in Criq

For a demonstration, I would like to code a simple optimization problem in Cirq. I don't care what the problem is, but I want it understandable to someone who has had only basic algebra.

One idea is to find the value of $$x$$ such that $$x-(x-3)^2$$ is optimal. From inspection it is the value of 3.5. How do I code that in Cirq? If that's too complicated, what is not too complicated?

But if I can code up any function I want, I'd like to find the minimum value of $$y=\frac{x^4-8x^2+x}{10}$$ because the graph is really nice:

It's obvious from inspection that the minimum value of $$y$$ is when $$x=-2$$. And we can do that because we can see all of the points at the same time and pick the minimum. So this is kind of what a quantum computer running a Criq program would do, right?