Let $f(x)$ be any continuous, differentiable function that has extrema and that $f(x) \geq 0$ for all $x$ and has a finite amount of roots (it is not always a polynomial). Let $g(x)$ be a function (written in terms of $f(x)$) that flips sign only when a root of $f(x)$ is encountered. For example, let's say that $f(x)$ has roots at $2,3,7,11$. That means if from $0$ to $2$, $g(x)$ is positive, from $2$ to $3$, $g(x)$ should be negative. From $3$ to $7$ it should be positive and from $7$ to $11$ it should be negative. $g(x)$ should be written in terms of $f(x)$; therefore $g(x)$ should be a general equation. You should not need to know the roots of $f(x)$ in order to construct $f(x)$. $g(x)$ does not have to be continuous nor differentiable. Hopefully, $g(x)$ is closed form (ie. no $\sum$ or $\prod$). What is one definition of $g(x)$? Or is such a function possible to construct?
In any answer, please use $f(x)=\sin^2(\frac{33}{x}\pi)+sin^2(x \pi)$ as the example function.
Background: I was thinking about this problem because I wanted to know if it was possible to find roots numerically for functions that are all positive and have other extrema other than the roots (so something like f(x)/f'(x) wouldn't work). Newton's, fixed point, and so on are only valuable if you start near the root, and even then, with a function like the example, it's not guaranteed to work. Bisection is the only one guaranteed to work, but I need to get the equations in a form so that can work.
EDIT: After giving it some thought, I'm thinking that such $g(x)$, if possible, will probably include sine, cosine, and/or tangent in some way, but I'm not sure how. I was hoping someone could help me.