Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need a Javascript program for ODE soultions . Consider a first order ordinary di

ID: 3740527 • Letter: N

Question

Need a Javascript program for ODE soultions .

Consider a first order ordinary differential equation given by: y ' = f (x,y) = y*x^2 -1.2y with a starting value of y (0) = 1 on the interval x = 0 to 2 with n = 8 (step size will be h = 0.25 ) determine the value of y (2) using: (a) Euler's method on each interval the next y value = previous y value + slope times step size. or yn = y + f(x,y) * h (b) Heun's method k1 = f ( x, y ) k2 = f ( x+h, y+k1*h ) and yn = y + (k1 + k2) * h / 2 (c) RK-3 method k1 = f ( x, y ) k2 = f ( x+h/2, y+k1*h/2 ) k3 = f ( x+h, y -k1*h + 2*k2*h) and yn = y + (k1 + 4*k2 + k3) * h/6 (d) RK-4 method k1 = f ( x, y ) k2 = f ( x+h/2, y+k1*h/2 ) k3 = f ( x+h/2, y+k2*h/2 ) k4 = f ( x+h, y + k3*h) and yn = y + (k1 + 2*k2 + 2*k3 + k4) * h / 6 at the start of the program I need you to define: function f (x,y) initial values: x = 0 and y = 1 final value: b = 2 number of steps: n = 8 you will need to display the four ending values for y: (a) Euler's method (b) Heun's method (c) RK-3 method (d) RK-4 method .

Explanation / Answer

   f = x+y;

    return f;

    var a,b,x,y,h,t,k;

    x=a;

    y=b;

   while(x<=t)

    {

        k=h*fun(x,y);

        y=y+k;

        x=x+h;

        document.write(x,y);

    }

}

2.Heun's method

   f = x+y;

    return f;

    var a,b,x,y,h,t,k;

    x=a;

    y=b;

   while(x<=t)

    {

        k1=fun(x,y);

        k2 = f(x+h,y+k1*h);

        yn = y+(k1+k2)*h2;

        y=y+k;

        x=x+h;

        document.write(x,y);

    }

}

3.RK-3 method

  

   f = x+y;

    return f;

    var a,b,x,y,h,t,k;

    x=a;

    y=b;

   while(x<=t)

    {

        k1=fun(x,y);

       k2=fun(x+h/2,y+k1*h/2);

       k3=fun(x+h/2,y-(k1*h+2*k2*h));

      yn=y+(k1+4*k2+k3)*(h/6);

        y=y+k;

        x=x+h;

        document.write(x,y);

    }

}

4.RK-4 method

   f = x+y;

    return f;

    var a,b,x,y,h,t,k;

    x=a;

    y=b;

   while(x<=t)

    {

        k1=fun(x,y);

       k2=fun(x+h/2,y+k1*h/2);

       k3=fun(x+h/2,y+(k2*h/2));

       k4=fun(x+h,y+k3*h);

      yn=y+(k1+2*k2+2*k2+2*k3+k4)*(h/6);

        y=y+k;

        x=x+h;

        document.write(x,y);

    }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote