0

I am try to solve the next equation more than one week:

enter image description here

I have to use Newton-Raphson Method for getting the approximate solution of u. I have the script to do that, but I need to "linearize" this non linear ODE. The k1-k4 are not constants. On each grid point (x=1-100) they get a different value which is calculated. The initial condition is u(0)=0.

Hooked
  • 84,485
  • 43
  • 192
  • 261
user1640255
  • 1,224
  • 3
  • 19
  • 25

1 Answers1

2

Is this a homework assignment?

Also, is it a boundary value problem or an ODE? From what you write, it sounds like BVP. Also, your boundary condition at u(0) is not enough.

If BVP, you can just use scikits.bvp_solver or scikits.bvp1lg which do the difficult parts for you.

If ODE, write the problem as a first order system, and use scipy.integrate.odeint or scipy.integrate.ode.

Regarding linearization (assuming this is a BVP): in practice it is usually enough to compute the partial derivative required for the Newton method via numerical differentiation.

pv.
  • 33,875
  • 8
  • 55
  • 49
  • Firstly, thank you for your reply! I really appreciate it. It's "work" assignment, and I am new on this, so I don't have the knowledge and the experience to solve it. Secondly, I didn't know about BVP, which this problem probably is. Yes, there is another one B.C. at the end of the grid points (x=100), the du/dx has a specific value, so totaly 2 B.C, at x=0 and x=100 ( the last gridpoint). So, I will check the scikits.bvp_solver... just what you mean to "compute the partial derivative required for the Newton method via numerical differentiation." ? Is any example BVP solved somewhere to see? – user1640255 Mar 21 '13 at 16:21
  • 1
    I meant that you don't necessarily need to write down partial derivatives for the newton method to work --- numerical differentiation works as well usually. However, the bvp_solver/bvp1lg packages should do the numerical differentiation for you --- you just need to give them the equations and the B.Cs. There are a few scikits.bvp_solver examples [here](http://pythonhosted.org/scikits.bvp_solver/examples/examples.html) – pv. Mar 21 '13 at 22:07
  • ... I cant use scikits.bvp_solver , as my Diff equation have non constant parameters (arrays) ... – user1640255 Mar 27 '13 at 18:17
  • @user1640255: non-constant parameters are not a problem, you just need to interpolate them. – pv. Mar 28 '13 at 20:55
  • Yes I can interpolate them, but I cant use them inside a function. The calculation is for a specific equation. I have vector arguments! so for each of them I will calculate the velocity on all gridpoints...is wrong... – user1640255 Apr 22 '13 at 01:21
  • I don't understand what you are saying. I think you should spend some time working out how to solve a simpler problem with the tools linked above: for instance, unknown function u(x), u(0)=u(pi)=0, d^2u(x)/dx^2 = cos(x) - u(x); after that d^2u(x)/dx^2 = f(x) - u(x) where f(x) is a linear interpolant of some data points. After that, you should be able to see how to solve your actual problem. – pv. Apr 22 '13 at 16:47
  • Firstly, I wrote a code with a main script and a newton solver that include Jacobian, for solving my system of nonlinear equations. Thanks for your advise about scikits.bvp_solver and scikits.bvp1lg, but it is not working for my problem! Working only for specific problems!!! Seconldy, Even I manage to solve my second degree nonlinear equation system with 2 boundary condition, I cant solve it when it has A(i) parameters: e.a. OK for this: y''(i)+ 5y'(i)y(i) + y'(i)=0 but my equation is y''(i)+A(i)y'(i)y(i)+y'(i)=0 A(i) is being calculated! (i=1,N) has N values,but I cant import it! – user1640255 Apr 23 '13 at 14:11
  • example: i=1: y''(1) + A(1)y'(1)(y(1)**3/4)+(y'(1)**1/4)=0 i=2: y''(2) + A(2)y'(2)(y(2)**3/4)+(y'(2)**1/4)=0 .... i=N: y''(N) + A(N)y'(N)(y(N)**3/4)+(y'(N)**1/4)=0 The above is my nonlinear system of N equation... do you see the power? Only with central differencing method you can solve it! and I did! but having A(N) constant! I cant import the calculated A(N) to the newton solver second script, and even I do that I am not sure if It will work. TO suggest check the website, or interpolated them means nothing! I interpolated them, but I cant imported inside the newton solver and Jacobian. – user1640255 Apr 23 '13 at 14:20