Thread: Defining three functions that implement, forward, backward, and centered difference.

  1. #1
    Registered User
    Join Date
    Sep 2018
    Posts
    1

    Defining three functions that implement, forward, backward, and centered difference.

    Hello! I need to define three functions in C that implement the forward, backward, and centered difference. They are defined as followed:

    Forward Difference:
    u(x+h)-u(x)
    --------------
    h

    Backward Difference:
    u(x)-u(x-h)
    -------------
    h

    Centered Difference:
    u(x+h)-u(x-h)
    ---------------
    2h

    How could I write these in C to implement them into my program? Thank you in advance!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Like
    Code:
    int forwardDifference( int x, int h ) {
        return u(x+h)-u(x) / h ;
    }
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 02-19-2012, 11:30 PM
  2. defining functions
    By Joeg1484 in forum Linux Programming
    Replies: 10
    Last Post: 12-18-2009, 10:26 AM
  3. Replies: 10
    Last Post: 12-16-2008, 10:28 AM
  4. Splash Screen not centered
    By BianConiglio in forum Windows Programming
    Replies: 5
    Last Post: 04-11-2004, 01:41 PM
  5. Defining Functions.
    By civilwarsearch in forum C++ Programming
    Replies: 7
    Last Post: 12-14-2003, 05:24 PM

Tags for this Thread