+ Reply to Thread
Results 1 to 7 of 7

Creating Second Derivative Givin a built in function

  1. #1
    Registered User
    Join Date
    10-04-2010
    Location
    Blacksburg, Virginia
    MS-Off Ver
    Excel 2003
    Posts
    34

    Question Creating Second Derivative Givin a built in function

    I’m having a problem writing the macro for the question statement below:

    Write a function named SecondDerivative that returns the second derivative of the function at a specified x based on a central approximation. The function should take 2 arguements: the value of x where the derivative is to be evaluated and the value of DeltaX to be used for the central difference. Assume that the function is available in a VBA function termed myf(). myf() takes 1 arguement: the x value where the function is to be evaluated. For example, if the function is 3x^2+2x-1, then assume that the following code is already available:

    Option Explicit
    Function myf(x as double) as double
    myf = 3*x^2+2*x-1
    End Function
    Currently this is what I have:

    Function SecondDerivative (x, Dx) As Double
    Second Derivative = [myf(x+Dx)-myf(x-Dx)]/(2*Dx)
    End Function
    Thanks for any help,
    Brandon

  2. #2
    Registered User
    Join Date
    10-04-2010
    Location
    Blacksburg, Virginia
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Creating Second Derivative Givin a built in function

    bumppppppppp

  3. #3
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Creating Second Derivative Givin a built in function

    loose the square brackets and replace with () brackets, square brackets are not valid BASIC syntax, and loose the space in Second Derivitive!

    Seems like you want us to do your homework for you!
    Regards
    Darren

    Update 12-Nov-2010 Still job hunting!

    If you are happy with the results, please add to our reputation by clicking the blue scales icon in the blue bar of the post.

    Learn something new each day, Embrace change do not fear it, evolve and do not become extinct!


  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Creating Second Derivative Givin a built in function

    That looks a whole lot like homework. But..

    If you have a generic first deritive function, you could use it recursivly for the second derivative.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  5. #5
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Creating Second Derivative Givin a built in function

    Generally people wont do your homework for you, and if they do the chances of you tutors picking up on your answers are great, since this board is open to google search!

    So far all your separate questions are very similar, and it seems you arn't learning from the answers, only copying!

  6. #6
    Registered User
    Join Date
    10-04-2010
    Location
    Blacksburg, Virginia
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Creating Second Derivative Givin a built in function

    Not HW, appreciate the help though

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Creating Second Derivative Givin a built in function

    By the way, the code in the OP looks like it calculates the first derivative.
    You can use that to create a mydf_dx function and then get the first derivative of mydf_dx.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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