MathOverflow will be down for maintenance for approximately 3 hours, starting Monday evening (06/24/2013) at approximately 9:00 PM Eastern time (UTC-4).
0

I programmed a Nystrom Algorithm specifically for my problem:

This is the exact equation i want to solve:

$y''=(w^2-e*cos(t))*sin(t)-b*y'$

And this is my algorithm

function [T U] = Nystrom(a,b,u0,h,w,v,e)
    % a is the initial value
    % b is the final value
    % u0 is a vector with the initial conditions y(0) and y'(0)
    % h is the size of every step
    % w, v and e are constants.

    M=(b-a)/h+2; %Steps
    T=zeros(1,M+2); %Time vectors
    U=zeros(2,M+2); %y and y' vector
    T=a:h:b; % i use uniform steps of size h
    U(:,1)=u0; %i stablish the initial conditions

    U(1,2)=U(1,1)+h*U(2,1)+(h^2)/2 * (w^2-e*cos(T(1))*sin(U(1,1))-v*U(2,1));

    for i=3:M
        U(1,i)=(-2*U(1,i-1)+U(1,i-2)-h^2*(w^2-e*cos(T(i-1)))*sin(U(1,i-1))-h*v*(U(1,i-2))/2)/(1-h*v/2);
    end

    for i=1:M
        U(2,i+1)=(U(1,i+2)-U(1,i))/(2*h);
    end

    U=U';
    T=T';

The problem is, it doesn't work and i don't know why. It's throwing values bigger and bigger in every step, but solving the same problem with other methods gives different, quite smaller values.

Any idea could help. Thank you!

flag
1 
Dear Federico, try scicomp.stackexchange.com Yo may get an answer there more quickly. – András Bátkai Dec 3 at 7:46
First of all: Why is it $\sin(U(\dots))$ when the equation reads $\sin t$? Which one is a typo? – fedja Dec 4 at 2:44

Your Answer

Get an OpenID
or

Browse other questions tagged or ask your own question.