0

I'm working on this code to modify it but I can't plot it and solve the second part?!!

Clear["Global`*"]
eqns = {y[x]^2 - Sqrt[3] (a/b) y[x]*Sqrt[y[x]^2 - k x^-2 - f] - k (1 - 2/(3 b))x^-2 -f == 0}; 
sol =FullSimplify[Solve[eqns, y[x]], Assumptions -> {a > 0, b > 0, k > 0, f > 0}]
a = 1; b = 0.24; f = 0.68; k = 0.002;
Plot[sol[[1]], {a, 0, 10}]
y1[x_] = y[x] /. sol
DSolve[{y1[x[t]] == x'[t]/x[t]}, x[t], t]
Felipe Dura
  • 447
  • 2
  • 8
  • You are right a = 1; b = 0.24; f = 0.68; k = 0.002; but still is not working!! – Felipe Dura Apr 01 '22 at 14:45
  • First of all, eqns is not a differential equation! – Artes Apr 01 '22 at 14:46
  • First one no but the second one yes – Felipe Dura Apr 01 '22 at 14:51
  • You should not use DSolve on eqns. – Artes Apr 01 '22 at 14:53
  • I fixed that part, now next part isn't working – Felipe Dura Apr 01 '22 at 14:55
  • 1
    See https://mathematica.stackexchange.com/questions/18393/what-are-the-most-common-pitfalls-awaiting-new-users/18706#18706, and look carefully at how solutions are used in the documentation for DSolve, Solve, NDSolve.... They return sets of Rule[] objects, and usually users want to deal with scalar numeric expressions -- certainly for Plot. You need to convert your solutions to such expressions or use DSolveValue, SolveValues [sic], NDSolveValue.... – Michael E2 Apr 01 '22 at 15:17

1 Answers1

4

now next part isn't working

If you go step by step, it will become more clear. I assume this is what you wanted. This is for one solution from Solve for illustration, as there are 4 solutions. You can do the same for the other 3 solutions. You also need to change x to x[t] to make an ode. Also it is better to use exact numbers with DSolve. Also the first plot should be w.r.t. x and not a since a is a number.

Clear["Global`*"]
eqns = {y[x]^2 - Sqrt[3] (a/b) y[x]*Sqrt[y[x]^2 - k x^-2 - f] - 
     k (1 - 2/(3 b)) x^-2 - f == 0};
a = 1; b = 24/100; f = 68/100; k = 2/1000;
(*use first solution for now *)
sol = y[x] /. First@FullSimplify[Solve[eqns, y[x]]] 

Mathematica graphics

 Plot[Abs@sol, {x, 1, 10}]

Mathematica graphics

y1 = sol /. x -> x[t]
ode = y1 == x'[t]/x[t]

Mathematica graphics

But this ode can't be solved exactly (it is non linear) and the solution has an integral that can not be solved

DSolve[ode, x[t], t]

Mathematica graphics

You might want to use NDSolve instead.

Nasser
  • 143,286
  • 11
  • 154
  • 359