# How to Solve a function f[x[y],y] == 0 in Mathematica? i.e. a function of 2 variables, where one is dependent on other

I am new to Mathematica and am trying to solve an equation to calculate amplitude as a function of frequency numerically. The parameters are as follows :-

L = 31.5*10^(-6);
m = 2.6969*10^(-13);
f1 =  551715;
f2 = 3.90463*10^6;
emr1 = 0.46399;
emr2 = 0.44793;
meff1 = emr1*m
meff2 = emr2*m
\[Alpha]1 = 0.044;
\[Alpha]2 = -18.6;
G = 2*10^(-3);
keff1 = meff1*(2*\[Pi]*f1)^2
keff2 = meff2*(2*\[Pi]*f2)^2
Q = 1500;


The equation is :-

f[y_,\[Omega]_] := (((\[Omega] -(2*\[Pi]*f1))/(2*\[Pi]*f1))-(3*\[Alpha]1*((y[\[Omega]])^2)/(8*L^2))^2  + (1/(2*Q))^2)*(y[\[Omega]])^2 -((G/(2*keff1))^2)


Here y is amplitude, omega is frequency in the range :-

{\[Omega]in = 0.85*(2*\[Pi]*f1), \[Omega]end = 1.15*(2*\[Pi]*f1), \[Omega]step = 0.01*(2*\[Pi]*f1)}

• Do you have a value for L? Oct 21 '20 at 11:40
• @SjoerdSmit I've edited the code to include L Oct 21 '20 at 13:12

First try to solve analytically

sol= Solve[x2 == a /(((\[Omega] - \[Omega]R)/\[Omega]R - b x2)^2 + c), x2]


and substitute the parameters.

I recommend solving for the square of x instead of x itself:

L = 31.5*10^(-6);
m = 2.6969*10^(-13);
f1 = 551715;
f2 = 3.90463*10^6;
emr1 = 0.46399;
emr2 = 0.44793;
meff1 = emr1*m;
meff2 = emr2*m;
α1 = 0.044;
α2 = -18.6;
G = 2*10^(-3);
keff1 = meff1*(2*π*f1)^2;
keff2 = meff2*(2*π*f2)^2;
Q = 1500;
eq = (((ω - (2*π*f1))/(2*π* f1)) - (3*α1*(xsquare)/(8*L^2))^2 + (1/(2*Q))^2)* xsquare - ((G/(2*keff1))^2) == 0;
Solve[eq, xsquare]
Solve[eq, xsquare, Reals] (* If you only want real-valued solutions *)


You can also use FindRoot when you need to find a numerical solution for a problem Solve can't handle.