Can Calculus be Applied in C/C++, PERL, and PYTHON for Real-Time Programming?

In summary, this conversation is discussing how to differentiate and integrate equations in different languages. Different languages have different functions that can be used for these tasks, but often these functions need to be written or special libraries are needed. Monte Carlo methods are an option if you want to avoid writing the code, but are more complicated to use than integration by table. When it comes to differentiation, the book "Numerical Recipes in C" is a good resource. When it comes to integration, Maple is a good option as it is user-friendly and has many functions available.
  • #1
karthik3k
149
0
Calculus in Programming ??

How can i differentiate / Integrate in C/C++, PERL, PYTHON ?
 
Physics news on Phys.org
  • #2
Generally speaking, programming languages like C++,PERL, and PYTHON have basic functions built in but for more complex operations like diffentiation and integration, you have to either write or get algoriths.

Especially if you want symbolic "algebra" results!
 
  • #3
I don't think those kinds of languages can handle that kind of mathematics. But maybe there's some kind of package out there to let them.

And the stereotypical answer, just for good measure: you write a program to do it!

cookiemonster
 
  • #4
You will definitely have to look for special math libraries to find algebraic solutions. Most programming uses approximations because, as yu probably know, many integrals are not exactly solvable. Runge-Kutta is the most efficient in general, but Monte Carlo methods are sometimes used. I like the simplicity of Monte Carlo methods- screw math, just get drunk and throw darts at pictures of your equations, and you'll have the answer.
 
  • #5
Hi:
I thinkit is not possible to do diff/Int directly but u can always develope the code to fit to u r needs..There are plenty of codes available on line else u can use "Numerical Recieps in C", i t is an excellent book for these type of codes..
Surendra
 
  • #6
Originally posted by rick1138
You will definitely have to look for special math libraries to find algebraic solutions. Most programming uses approximations because, as yu probably know, many integrals are not exactly solvable. Runge-Kutta is the most efficient in general, but Monte Carlo methods are sometimes used. I like the simplicity of Monte Carlo methods- screw math, just get drunk and throw darts at pictures of your equations, and you'll have the answer.

And the drunkenness is a requirement of the system! The answers are likely to be wrong if the dart thrower is sober. :smile:
 
  • #7
therez definitely no built-in integ or deriv function that u can call in c/c++/perl etc...
wut some c/c++ programs do is basically load a database of integral tables and then call the appropriate function and search the function's tables to find the appropriate integral form...in short, it uses integration by table.I think softwarez like maple and deriv, which do these, were written in C...making them user friendly...

if u want to do the integration and stuff using C then ull need to download functions and then include them like " include <bhahbhah.h> " and then pass appropriate parameters.
much easier to use software like maple...

be warned that ur answer can look different from the answer u get by hand because the answerz can be expressed in different forms esp forms involving trig functions.

- Mr. Kamadolli
 
  • #8
If you're talking about doing numerical differentiation and integration, look no further than the book "Numerical Recipes in C." It's a classic book, a must-own for any scientific programmer, and is available in its entirety, for free, at www.nr.com.

Enjoy!

- Warren
 
  • #9
I'm at work so I can't give you an exact title of the book. I'll edit it the first chance I get.

The book is called Math Tookit For Realtime Programming by Jack Krenshaw. The author is an engineer who programmed embedded systems at NASA. The CAS(Computer Algerbra Systems) are great but programming the code is better. If you go that I highly recommend MATHCAD. :biggrin:
 

1. What is calculus and how is it used in programming?

Calculus is a branch of mathematics that deals with the study of rates of change and accumulation. In programming, calculus is used to solve problems involving optimization, motion, and growth.

2. What are the main concepts of calculus that are relevant to programming?

The main concepts of calculus that are relevant to programming include derivatives, integrals, limits, and optimization.

3. How does calculus help in developing algorithms?

Calculus helps in developing algorithms by providing a framework for solving problems involving continuous change. It allows programmers to model and analyze complex systems and make predictions about their behavior.

4. Can you give an example of how calculus is used in programming?

One example of how calculus is used in programming is in machine learning algorithms. Calculus is used to optimize the parameters of the model by minimizing the error or cost function.

5. Is knowledge of calculus necessary for programming?

No, knowledge of calculus is not necessary for programming, but it can be very helpful in solving certain types of problems and developing more advanced algorithms. However, basic understanding of calculus concepts such as derivatives and integrals can greatly benefit a programmer's problem-solving skills.

Similar threads

  • New Member Introductions
Replies
2
Views
58
  • New Member Introductions
Replies
1
Views
34
Replies
46
Views
1K
Replies
9
Views
1K
Replies
1
Views
933
  • Calculus
Replies
0
Views
2K
Replies
5
Views
1K
  • STEM Career Guidance
Replies
23
Views
816
Replies
8
Views
490
Back
Top