Recursive functions, MATLAB in Mathematics

Recursive Functions:

The Recursion occurs whenever something is defined in terms of itself. In the programming, a recursive function is a function which calls itself. The Recursion is very commonly used in the programming, however many simple illustrations are really not very efficient and can be substituted by the iterative techniques (loops, or vectorized code in MATLAB). Nontrivial illustrations go beyond the scope; therefore the concept of recursion is easily introduced here.

The illustration used will be of a factorial. Generally, the factorial of an integer n is defined iteratively:

n! = 1 * 2 * 3 *  ...  * n

For illustration, 4! = 1 * 2 * 3 * 4, or 24.

The other, recursive, definition is:

n! = n * (n - 1)!  general case

1! = 1  base case

 

Posted Date: 10/22/2012 1:28:20 AM | Location : United States







Related Discussions:- Recursive functions, Assignment Help, Ask Question on Recursive functions, Get Answer, Expert's Help, Recursive functions Discussions

Write discussion on Recursive functions
Your posts are moderated
Related Questions
Fliplr function: The fliplr function "flips" the matrix from left to right (in another words the left-most column, the first column, become the last column and so on), and the

Illustration of a recursive function: illustration is of a recursive function which does not return anything, but simply prints. The below function prtwords receives a sentenc

Functions to create special matrices: The MATLAB also has various functions which create special matrices. For illustration, the zeros function generates a matrix of all zeros

Example of Minimum and Maximum Value For matrices, the functions min and max operate column wise by the default: >> mat = randint(2,4,[1 20]) mat =    9   10   1

Polar Form: Any complex number z = a + bi can be thought of as a point (a,b) or vector in the complex plane in which the horizontal axis is the real part of z, and the vertica

Concatenation: The String concatenation means to join the strings altogether. Of course, as strings are merely vectors of the characters, the technique of concatenating vector

Animation: In this part we will observe a couple of ways to animate a plot. These are visuals, therefore the outcomes can't really be shown here; it is essential to type these

Minimum and Maximum Value The MATLAB has built-in functions for numerous statistics. For illustration, min and max to find the minimum or maximum value in a data set. >> x

Use of logical vector: Determine how many elements in the vector vec were greater than 5, the sum function can be used on the resulting vector isg: >> sum(isg) ans =

Sorting The Sorting is a process of putting a list in order; either in descending (maximum to minimum), or ascending (minimum to maximum) order. For illustration, here is a li