How can I find $f(x)$ in the interval $(x_1,x_2)$? I know the values of the coefficients as $c=0.5$, $b=1.1$ and $(x_1,x_2)=(-10,10)$.
f[x] == c Cos[2 f[x]] + b x
I want to find $f(x)$ and plot $\sin(f(x))$ in the interval $(x_1,x_2)$.
Clear["Global`*"]
c = 1/2;
b = 11/10;
{x1, x2} = {-10, 10};
eqn = f[x] == c Cos[2 f[x]] + b x;
f[x_] = f[x] /.
DSolve[{D[eqn, x], f[0] == (f0 /.
Solve[(eqn /. x -> 0 /. f[0] -> f0), f0,
Reals][[1]])}, f[x], {x, x1, x2}][[1]] //
FullSimplify
(* InverseFunction[-(1/2) Cos[2 #1] + #1 &][(11 x)/10] *)
Plot[f[x], {x, x1, x2}]
Plot[Sin[f[x]], {x, x1, x2}]
This kind of problem can be solved with FixedPoint
iteration. I've used 500 iterations max:
c = 1/2.;
b = 1.1;
g[x_, y_] := c Cos[2 y] + b*x
fp[x_] := FixedPoint[g[x, #] &, x, 500]
ListLinePlot[Table[{x, fp[x]}, {x, -10, 10, .25}],
AxesLabel -> {"x", "f[x]"}]
ListLinePlot[Table[{x, Sin@fp[x]}, {x, -10, 10, .25}],
AxesLabel -> {"x", "Sin[f[x]]"}]
You can verify that fp is good by checking the error at a given $x$ for example when $x=5$ we have the error g[5, fp[5]] - fp[5]
which is a very small number: 1.40502*10^-10
. Increase the iterations if you want it smaller.
In case you need to handle the symbolic dependence on $c$ and $b$
Clear[f, x, b, c]
f[x, 0] = x;
f[x_, k_] := f[x, k] = c Cos[2 f[x, k - 1]] + b x
f[x, 3]
n = 500;
c = 1/2;
b = 1.1;
fn = f[x, n];
Plot[fn, {x, -10, 10}]
Plot[Sin[fn], {x, -10, 10}]