Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8682027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:39:41+00:00 2026-06-12T21:39:41+00:00

Is it possible to find derivative of a function using c program. I am

  • 0

Is it possible to find derivative of a function using c program. I am using matlab in that it has an inbuilt function diff() which can be used for finding derivative of a function.

f(x)=x^2

Is it possible to find the derivative of above function using c. What is the algorithm for that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T21:39:43+00:00Added an answer on June 12, 2026 at 9:39 pm

    Yes, it is quite possible. However, the solution depends on your needs. If you need a simple numerical solution, the following will do (to a certain extent, with some constraints – naive implementation):

    double derive(double (*f)(double), double x0)
    {
        const double delta = 1.0e-6; // or similar
        double x1 = x0 - delta;
        double x2 = x0 + delta;
        double y1 = f(x1);
        double y2 = f(x2);
        return (y2 - y1) / (x2 - x1);
    }
    
    // call it as follows:
    #include <math.h>
    
    double der = derive(sin, 0.0);
    printf("%lf\n", der); // should be around 1.0
    

    For more advanced numerical calculations, you can use the GNU Scientific Library.

    However, if you need to analitically find the formula of the derivative of a given function, then you have to:

    1. Parse the input formula to some abstract data type, for example an AST;
    2. Derivate it using the identities and rules of derivation (there’s only a few of them, this part should be the easiest),
    3. Serialize the abstract data type you got as the result of the derivation process to a string and output that as the result.

    However, you won’t need to do all this; there are great C mathematical libraries that provide such functionality.

    Edit: after some Googling, I couldn’t find one. The closest solution for getting you started I can think of is having a look at GeoGebra’s source code – although it’s written in Java, it’s fairly easy to read for anybody fluent enough in a C-like language. If not, just go ahead and implement that algorithm yourself 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Find text string using jQuery? How do you find a text string
Is it possible to find which method was called on an object without having
Is it possible to find the database technology using for a website. eg. www.example.com/
Is it possible to find out which page the user was previously browsing from
Possible Duplicate: Find and Replace in Notepad++ using Regular Expression how to use regular
Is there possible to find internet enable using intent in broadcast receiver in android
Possible Duplicate: Find location of current m-file in Matlab I would like to write
Is it possible to find out the full path to the script that is
Is it possible to find out the service packs that are installed on a
How is it possible find Even/Odd number without using mathematical/bitwise operator?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.