2
$\begingroup$

I am trying to find approximate solution for nonlinear ODE(I know there are are ways to do it in mathematica) but I really want why is not working(I modified the code base on some codes suggest by expert here for system):

 ClearAll["Global`*"] eq = {u'[t] == u[t]^2 + 1, u[0] == 0} // Simplify u[t_] = Sum[ t^s, {s, 0, 6}] + O[t]^7; le = LogicalExpand[#] & /@ eq; sol1 = NSolve[And @@ le, Flatten[Table[s, {s, 0, 6}], 1]]; uu1[t_] = Normal[{u[t]} /. First@sol1] // Simplify; uu1[t] // TableForm pl = Plot[Evaluate[{uu1[t]}, {t, 0, 6}], PlotStyle -> {Blue}]; 
$\endgroup$
4
  • 1
    $\begingroup$ NDSolve is used to solve ODEs, not NSolve. You might want to study some examples in its documentation, because I'm not sure how to fix your code. $\endgroup$ Commented Apr 14, 2020 at 21:01
  • $\begingroup$ Dear MichaelE2, the above code I modified it, it was suggested by Akku14 for system, I am new here I do not know how to contact the expert directly....thanks $\endgroup$ Commented Apr 14, 2020 at 21:05
  • 1
    $\begingroup$ Maybe if you gave the mathematical formulation of the problem -- but maybe Nasser has guessed correctly what you wanted in his answer, in which case I guess there's no further need for explanation. $\endgroup$ Commented Apr 14, 2020 at 21:50
  • $\begingroup$ Thank you Michael E2. $\endgroup$ Commented Apr 15, 2020 at 10:42

2 Answers 2

2
$\begingroup$

If you want to use the method i showed in other example, do it exactly the way. (Don't leave things or change arbitrarilly.)

 ClearAll["Global`*"] eq = u'[t] == u[t]^2 + 1; ic = u[0] == 0; u[t_] = Sum[a[s]*t^s, {s, 0, 6}] + O[t]^7 le = LogicalExpand[eq] sol1 = Solve[le, Table[a[s], {s, 1, 6}]] sol2 = Solve[ic /. sol1[[1]], a[0]] uu1[t_] = u[t] /. First@sol1 /. First@sol2 // Normal // Simplify pl = Plot[uu1[t], {t, 0, 6}, PlotStyle -> {Blue}] 
$\endgroup$
3
  • $\begingroup$ Dear Akku14, many thanks for the correct answer, can we do the same for x y''(x)+2y'(x)+a x^(m+1) y(x)^n=0, y(0)=1, y'(0)=0 $\endgroup$ Commented Apr 15, 2020 at 10:48
  • $\begingroup$ You can only do it, if you insert integer numbers for m and n. e.g. m -> 1, n -> 2. Try it. Solve only for y(0)=1 The y'(0)=0 is satisfied with the given a. $\endgroup$ Commented Apr 15, 2020 at 11:22
  • $\begingroup$ So it can not done for any m, n, a? right? $\endgroup$ Commented Apr 15, 2020 at 13:14
2
$\begingroup$
ClearAll["Global`*"] ode = u'[t] - u[t]^2 - 1; ic = u[0] == 0; sol = u[t] /. First@DSolve[{ode == 0, ic}, u[t], t] 

Mathematica graphics

Series[sol, {t, 0, 10}] 

Mathematica graphics

 AsymptoticDSolveValue[{ode == 0, ic}, u[t], {t, 0, 10}] 

Mathematica graphics

If you want to do the above yourself, then you would need to plug in Taylor series for $u(t)$ using rules given below on Wikpedia and this gives you a recursive relation to solve for the coefficients. the $c_0$ is found from initial conditions, which then leads to all the other coefficients being known due to recusive relation.

See https://en.wikipedia.org/wiki/Power_series_solution_of_differential_equations under the section A simpler way using Taylor series and follow the example given:


Mathematica graphics

$\endgroup$
1
  • $\begingroup$ Thank you Naser, I highly appreciate your help. $\endgroup$ Commented Apr 15, 2020 at 10:39

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.