How can I find the domain of $x$ for which the function $g(x)\geq0\;$?

I have this function ($$x>0$$) $$f (x)=\frac{\sqrt{g (x)}+4 x \left(x^2+1\right) \sin (\pi x) \cos ((3+\pi ) x)}{x^4+2 x^2+1+\left(4 x^2+\left(x^2-1\right)^2 \cos (2 \pi x)\right)}$$

f[x_] := (
Sqrt[g[x]] + 4 x (1 + x^2) Cos[(3 + π) x] Sin[π x])/(
1 + 2 x^2 + x^4 + (4 x^2 + (-1 + x^2)^2 Cos[2 π x]));

where $$g(x)=4 x^2+\left(x^2-1\right)^2 \cos (2 \pi x)-\left(x^2+1\right)^2 \cos (2 (3+\pi ) x)\;$$.

g[x_] := 4 x^2 + (-1 + x^2)^2 Cos[2 π x] - (1 + x^2)^2 Cos[
2 (3 + π) x];

I want to check the range of function $$f(x)$$ for those values of $$x$$ in which $$g(x)\geq0\;$$.

-How can I find the domain of $$x$$ for which $$g(x)\geq0\;$$?

• Did you try to use FunctionDomain[f,x]? Commented Aug 24, 2020 at 8:42
• @tabi_k Yes, but the result is weird!
– user73597
Commented Aug 24, 2020 at 8:46
• To get a quick impression of the range of f under condition g>=0, define f2[x_] = ConditionalExpression[f[x], g[x] >= 0] and plot Plot[f2[x], {x, 0, 5}, PlotRange -> All, PlotPoints -> 1000, MaxRecursion -> 15, GridLines -> Automatic] Commented Aug 24, 2020 at 11:10

Try ( Thanks @SjoerdSmit helpful comment )

cond=FunctionDomain[{f[x], g[x] >= 0 }, x, Reals] //FullSimplify
(*1 + 6 x^2 + x^4 + (-1 + x^2)^2 Cos[2 \[Pi] x] != 0 &&
4 x^2 + (-1 + x^2)^2 Cos[2 \[Pi] x] >= (1 + x^2)^2 Cos[2 (3 + \[Pi]) x]*)

This condition gives (Thanks @user64494 )

Reduce[N[1 + 6 x^2 + x^4 + (-1 + x^2)^2 Cos[2 \[Pi] x] != 0 &&      4 x^2 +(-1 + x^2)^2 Cos[2 \[Pi] x] >= (1 + x^2)^2 Cos[        2 (3 + \[Pi]) x]] && x>= 0 && x <= 10, x, Reals]
(*0 <= x <= 0.386763 || 0.590121 <= x <= 1.02279 ||
1.02333 <= x <= 1.47324 || 1.60461 <= x <= 2.03514 ||
2.06742 <= x <= 2.43253 || 2.67214 <= x <= 3.049 ||
3.11778 <= x <= 3.42438 || 3.70494 <= x <= 4.06349 || ...<= x <= 10.*)

visualization:

Plot[1, {x, 0, 10},
RegionFunction ->Function[{x},1 + 6 x^2 + x^4 + (-1 + x^2)^2 Cos[2 \[Pi] x] != 0 &&4 x^2 + (-1 + x^2)^2 Cos[2 \[Pi] x] >= (1 + x^2)^2 Cos[2 (3 + \[Pi]) x]]]

• You can use FullSimplify to make the result a little more compact. Commented Aug 24, 2020 at 10:43
• @SjoerdSmit Thanks, I modified my answer. Commented Aug 24, 2020 at 10:56
• Additionally, the command Reduce[N[1 + 6 x^2 + x^4 + (-1 + x^2)^2 Cos[2 \[Pi] x] != 0 && 4 x^2 + (-1 + x^2)^2 Cos[2 \[Pi] x] >= (1 + x^2)^2 Cos[ 2 (3 + \[Pi]) x]] && x >= 0 && x <= 10, x, Reals] results in 0 <= x <= 0.386763 || 0.590121 <= x <= 1.02279 || 1.02333 <= x <= 1.47324 || 1.60461 <= x <= 2.03514 || 2.06742 <= x <= 2.43253 || 2.67214 <= x <= 3.049 || 3.11778 <= x <= 3.42438 || 3.70494 <= x <= 4.06349 || 4.168 <= x <= 4.42848 || 4.72776 <= x <= 5.07828 || ... 9.40322 <= x <= 9.49744 || 9.81264 <= x <= 10.. Commented Aug 24, 2020 at 11:11
• @user64494 Tricky definition off "~NReduce" , I didn't know the use Reduce[ N@expr,...] Commented Aug 24, 2020 at 11:50
• With TrigExpand you can get the exact values of the zero-crossings sol = Solve[0 <= x < 5 && TrigExpand[g[x]] == 0, x] in form of root expressions like {x -> Root[{Tan[(\[Pi] #1)/2] - #1^2 Tan[(\[Pi] #1)/2] + Tan[1/2 (3 + \[Pi]) #1] + #1^2 Tan[1/2 (3 + \[Pi]) #1] + Tan[(\[Pi] #1)/2]^2 Tan[ 1/2 (3 + \[Pi]) #1] + #1^2 Tan[(\[Pi] #1)/2]^2 Tan[ 1/2 (3 + \[Pi]) #1] + Tan[(\[Pi] #1)/2] Tan[ 1/2 (3 + \[Pi]) #1]^2 - #1^2 Tan[(\[Pi] #1)/2] Tan[ 1/2 (3 + \[Pi]) #1]^2 &, 0.59012140371407271166281}]} . Commented Aug 24, 2020 at 17:34