0
$\begingroup$

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!

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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.