0
$\begingroup$

How can ı solve the differential equation this gives error, please help

c = 1.0;
b = 0.1;
σ = 0.01;
n = 1.0;

w1 = -(1/3) - (2 Sqrt[g[x]])/(3*c)*Cos[y]
w2 = -((b*b)/(g[x])^(n - 1))*(1 + σ)^n/(1 - g[x] + σ)

DSolve[g'[x] == -2*g[x]*(1 - g[x] + σ)*(w1 - w2) + σ*g[x]*(1 + 3*w1), g[x], x]
$\endgroup$

1 Answer 1

1
$\begingroup$

I do not know what your y there supposed to be (if it is a parameter, this is not a good name). If you use exact values, the errors go away. Since you are calling DSolve always try to avoid non-exact parameters in your ode.

ClearAll[x, y, g]
c = 1;
b = 1/10;
sigma = 1/100;
n = 1;
w1 = -(1/3) - (2 Sqrt[g[x]])/(3*c)*Cos[y]
w2 = -((b*b)/(g[x])^(n - 1))*(1 + sigma)^n/(1 - g[x] + sigma)
ode = g'[x] == -2*g[x]*(1 - g[x] + sigma)*(w1 - w2) + sigma*g[x]*(1 + 3*w1);
DSolve[ode, g[x], x]

Mathematica graphics

The solution is implicit.

Update:

If initial conditions for g(x) is known, try NDSolve. For example:

ClearAll[x, y, g]
y = 20  Degree;
c = 1;
b = 1/10;
sigma = 1/100;
n = 1;
w1 = -(1/3) - (2 Sqrt[g[x]])/(3*c)*Cos[y]
w2 = -((b*b)/(g[x])^(n - 1))*(1 + sigma)^n/(1 - g[x] + sigma)
ode = g'[x] == -2*g[x]*(1 - g[x] + sigma)*(w1 - w2) + sigma*g[x]*(1 + 3*w1)
sol = NDSolve[{ode, g[0] == 1}, g, {x, 0, 1}]

Mathematica graphics

To plot:

Plot[Evaluate[g[x] /. sol], {x, 0, 1}, PlotRange -> All]

Mathematica graphics

$\endgroup$
6
  • $\begingroup$ thank you, actually y can be any number for example 20. ı want to solve g(x) and plot g versus x, x can be any values. Please help me how can ı solve. $\endgroup$
    – merve
    Commented Jan 5, 2017 at 8:40
  • $\begingroup$ @merve Ok, it will work with number. Just do not use 20.0 and only use 20 to keep things exact. You can use the command Rationalize if needed. DSolve works better with exact numbers. (ofcourse, this also depends on what the ODE is, in your case, exact values removed those errors you were seeing). $\endgroup$
    – Nasser
    Commented Jan 5, 2017 at 8:41
  • $\begingroup$ ı set y is 20 and the result gives Solve[...] what is the meaning, can ı have g[x]=...., and then ı want to plot g versus x.:( $\endgroup$
    – merve
    Commented Jan 5, 2017 at 8:50
  • $\begingroup$ @merve, first I assumed you meant 20 Degree, since your y is argument to Cos[] and I think you mean degrees. Second, the result is implicit. Which means, the solution g[x] is found by solving the resulting equation, which Mathematica could not solve exactly. i.e. This is the best M can do analytically. You could always try NDSolve ? Your ODE is non-linear in g(x) and so it is hard to solve these analytically. $\endgroup$
    – Nasser
    Commented Jan 5, 2017 at 8:53
  • $\begingroup$ thank you for your help, how can ı plot the interpolatingFunction result g versus x :( $\endgroup$
    – merve
    Commented Jan 5, 2017 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.