0
$\begingroup$

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]
$\endgroup$
6
  • $\begingroup$ You are right a = 1; b = 0.24; f = 0.68; k = 0.002; but still is not working!! $\endgroup$ Commented Apr 1, 2022 at 14:45
  • $\begingroup$ First of all, eqns is not a differential equation! $\endgroup$
    – Artes
    Commented Apr 1, 2022 at 14:46
  • $\begingroup$ First one no but the second one yes $\endgroup$ Commented Apr 1, 2022 at 14:51
  • $\begingroup$ You should not use DSolve on eqns. $\endgroup$
    – Artes
    Commented Apr 1, 2022 at 14:53
  • 1
    $\begingroup$ See mathematica.stackexchange.com/questions/18393/…, 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.... $\endgroup$
    – Michael E2
    Commented Apr 1, 2022 at 15:17

1 Answer 1

4
$\begingroup$

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.

$\endgroup$

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