Thilina's Blog

I might be wrong, but…

Symbolic Integration and Differentiation using MATLAB

While messing with MATLAB during free time I have found the method (thanks to MATLAB documentation) of performing symbolic integration and differentiation using MATLAB. And also the proper way to display a function in MATLAB command line. In this small article I am going to share my experience on symbolic integration and differentiation using MATLAB.

Representing a function as reader friendly format

Take an example function f(x) as,

aa

We can input our function to MATLAB as follows.

image

You can clearly see that ‘x’ is a symbolic object and f(x) is a symbolic function. Say If you need to evaluate f(x) at x = 10; that is f(10) then it’s simply;

clip_image005

However this equation and answer representation is bit annoying. Therefore by using the command ‘pretty’ we can display this in more readable format in MATLAB command line.

clip_image006

Now let’s have a look how the symbolic differentiation is performed.

Symbolic Differentiation

The MATLAB function ‘diff’ is used for performing symbolic differentiation and the function format is as follows.

g(x) = diff(f(x),variable in interest, order of derivative);

Consider the following example.

clip_image007

Now say you need to evaluate first derivative of f(x) at x = 5; then It can be calculated as follows.

clip_image008

Symbolic Integration

Command format we use is ‘int’ and the format is as follows.

g(x) = int(f(x),integrate on); %gives you symbolic result
g(x) = int(f(x),integrate on, from, to); % gives you the integral

Consider the following example.

clip_image009

There is another function named ‘integral’ to perform the numerical integration using MATLAB. And it has two variations named ‘integral2’ and ‘integral3’ for 2D and 3D integration as well. You can use MATLAB documentation to obtain clear idea how does it work.

At this point I conclude my short article on ‘Symbolic Integration and Differentiation using MATLAB’. Hope you got some basic idea about it from this article. Thank you very much for reading.

2013 December 15 - Posted by | MATLAB | , , , , , , ,

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: