Results 1 to 1 of 1

Exact solutions of a differential equation of the form dy / dx + xy = xy ^ 3

Threaded View

  1. #1
    Registered User
    Join Date
    04-08-2019
    Location
    England
    MS-Off Ver
    the latest
    Posts
    1

    Exclamation Exact solutions of a differential equation of the form dy / dx + xy = xy ^ 3

    Hello I have this question to perform it on VBA the question is :
    Develop a VBA programme that can derive the exact solutions of a differential equation of the form:
    dy / dx + xy = xy ^ 3

    The user should be able to input the values for y_boundary, x_boundary (initial condition) as well as an input value x in order for your programme to calculate y.

    My code is below
    
    Sub Button1_Click()
       Dim x As Double, y As Double, h As Double 'declare variables x, y and h
        x = InputBox("Input initial condition x=") 'ask user for initial conditinn value of x
       y = InputBox("Input initial condition y=") 'ask user for initial condition value of y
       h = InputBox("Input the change in x; h=") 'ask user for the value of change in x; h
    Range("A5").Value = x 'set the cell A5 to  x
    Range("B5").Value = y 'set the cell B5 to y
    Range("B2").Value = h 'set the cell B2 to h
    End Sub
    Function cons1(h As Double, Xn As Double, Yn As Double) As Double
    cons1 = h * ((Xn * Yn ^ 3) - (Xn * Yn)) 'calculates K1
    End Function
    Function cons2(h As Double, Xn As Double, Yn As Double, cons1 As Double) As Double
    cons2 = h * ((Xn + h / 2) * (Yn + cons1 / 2) ^ 3 - (Xn + h / 2) * (Yn + cons1 / 2)) 'calculates K2
    End Function
    Function cons3(h As Double, Xn As Double, Yn As Double, cons2 As Double) As Double
    cons3 = h * ((Xn + h / 2) * (Yn + cons2 / 2) ^ 3 - (Xn + h / 2) * (Yn + cons2 / 2)) 'calculates K3
    End Function
    Function cons4(h As Double, Xn As Double, Yn As Double, cons3 As Double) As Double
    cons4 = h * ((Xn + h) * (Yn + cons3) ^ 3 - (Xn + h) * (Yn + cons3)) 'calculates K4
    End Function
    Function YRK(cons1 As Double, cons2 As Double, cons3 As Double, cons4 As Double, Yn As Double) As Double
    YRK = Yn + 1 / 6 * (cons1 + (2 * cons2) + (2 * cons3) + cons4) 'calculates Yn+1 for Runge-Kutta method
    End Function
    Function f(Xn As Double, Yn As Double) As Double
    f = ((Xn * Yn ^ 3) - (Xn * Yn)) 'calculates f(Xn,Yn)
    End Function
    Function Yeuller(h As Double, Yn As Double, f As Double) As Double
    Yeuller = Yn + (h * f) 'calculates Yn+1 for Euller method
    End Function
    Function Yeuller_cauchy(h As Double, Yn As Double, Xn As Double) As Double
    Yeuller_cauchy = Yn + (h * ((Xn * Yn ^ 3) - (Xn * Yn))) 'calculates Yn+1 for Euller-Cauchy Method
    End Function
    Screenshot (153).pngScreenshot (154).png

    PLEASE I REALLY NEED HELP WITH THIS ASAP. TELL ME WHAT I AM DOING WRONG, I APPRECIATE ANY KIND OF HELP.
    THANK YOU IN ADVANCE

    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #1 requires good titles. "Programming using VBA" didn't tell us anything about your specific question. I have updated it for you this time because you are a new member.--6StringJazzer
    Last edited by 6StringJazzer; 04-08-2019 at 05:27 PM. Reason: Moderator updated title

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Need help about vba programming
    By natararaj in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-06-2015, 01:07 AM
  2. New to VBA programming
    By Blackhawks in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-07-2014, 09:09 PM
  3. Help with programming
    By martiel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-20-2014, 02:46 PM
  4. VBA Row Programming
    By aegliveinterns in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-03-2010, 04:07 PM
  5. VBA programming
    By DKalache in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-22-2007, 08:12 AM
  6. VBA programming
    By kush28 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-09-2006, 04:05 AM
  7. programming
    By Daren in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-10-2005, 06:00 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1