MATLAB,IBS Agra
17/09/2021
Introduction:-A neural network is a massively parallel distributed processor made up of simple processing units, which has a natural propensity for storing experiential knowledge and making it available for use. It resembles the brain in two respects:
1. Knowledge is acquired by the network from its environment through a learning process.
2. Interneuron connection strengths, known as synaptic weights, are used to store the acquired knowledge. Neural networks are also referred to in literature as neurocomputers, connectionist networks. Parallel distributed processors, etc.
Benefits of Neural Networks
The use of neural networks offers the following useful properties and capabilities:
1.Nonlinearity. An artificial neuron can be linear or nonlinear. A neural network, made up of an interconnection of nonlinear neurons, is itself nonlinear. The nonlinearity is of a special kind in the sense that it is distributed throughout the network.
2.Input-Output Mapping. The network learns from the examples by constructing an input-output mappingfor the problem at hand. Such an approach brings to mind the study of nonparametricstatistical inference; the term"nonparametric" is used here to signify the fact that no prior assumptions are made ona statistical model for the input data.
3.Adaptivity. Neural networks have a built-in capability to adapt their synapticweights to changes in the surrounding environment. In particular, a neural networktrained to operate in a specific environment can be easily retrained to deal with minorchanges in the operating environmental conditions. Moreover, when it is operating in anonstationary environment, a neural networkcan be designed to change its synaptic weights in real time.
4.Evidential Response. In the context of pattern classification, a neural networkcan be designed to provide information not only about which particular pattern toselect, but also about the confidence in the decision made. This latter information maybe used to reject ambiguous patterns, should they arise, and thereby improve the classificationperformance of the network.
5.Contextual Information. Knowledge is represented by the very structure andactivation state of a neural network. Every neuron in the network is potentiallyaffected by the global activity of all other neurons in the network. Consequently, contextualinformation is dealt with naturally by a neural network.
6.Fault Tolerance. A neural network, implemented in hardware form, has thepotential to be inherently fault tolerant, or capable of robust computation, in thesense that its performance degrades gracefully under adverse operating conditions.
7.VLSI Implement ability.The massively parallel nature of a neural network makes it potentially fast for the computation of certain tasks. This same feature makes a neural network well suited for implementation using very-large-scale-integrated(VLSI) technology. One particular beneficial virtue of VLSI is that it provides a means of capturing truly complex behavior in a highly hierarchical fashion.
8.Uniformity of Analysis and Design. Basically, neural networks enjoy universality as information processors. We say this in the sense that the same notation is used in all domains involving the application of neural networks. This feature manifests itself in different ways:
Neurons, in one form or another, represent an ingredient common to all neural networks.
This commonality makes it possible to share theories and learning algorithms in different applications of neural networks.
Modular networks can be built through a seamless integration of modules.
9.Neurobiological Analogy. The design of a neural network is motivated by analogy with the brain, which is a living proof that fault tolerant parallel processing is not only physically possible but also fast and powerful. Neurobiologists look to (artificial) neural networks as a research tool for the interpretation of neurobiological phenomena.
Er. Ashish Nishad
26/08/2020
for
MATLAB provides the diff command for computing symbolic derivatives. In its simplest form, you pass the function you want to differentiate to diff command as an argument.
For example, let us compute the derivative of the function f(t) = 3t2 + 2t-2
Example
Create a script file and type the following code into it −
syms t
f = 3*t^2 + 2*t^(-2);
diff(f)
When the above code is compiled and executed, it produces the following result −
ans =
6*t - 4/t^3
Following is Octave equivalent of the above calculation −
pkg load symbolic
symbols
t = sym("t");
f = 3*t^2 + 2*t^(-2);
differentiate(f,t)
Octave executes the code and returns the following result −
ans =
-(4.0)*t^(-3.0)+(6.0)*t
Verification of Elementary Rules of Differentiation
Let us briefly state various equations or rules for differentiation of functions and verify these rules. For this purpose, we will write f'(x) for a first order derivative and f"(x) for a second order derivative.
Following are the rules for differentiation −
Rule 1
For any functions f and g and any real numbers a and b are the derivative of the function:
h(x) = af(x) + bg(x) with respect to x is given by −
h'(x) = af'(x) + bg'(x)
Rule 2
The sum and subtraction rules state that if f and g are two functions, f' and g' are their derivatives respectively, then,
(f + g)' = f' + g'
(f - g)' = f' - g'
Rule 3
The product rule states that if f and g are two functions, f' and g' are their derivatives respectively, then,
(f.g)' = f'.g + g'.f
Rule 4
The quotient rule states that if f and g are two functions, f' and g' are their derivatives respectively, then,
(f/g)' = (f'.g - g'.f)/g2
Rule 5
The polynomial or elementary power rule states that, if y = f(x) = xn, then f' = n. x(n-1)
A direct outcome of this rule is that the derivative of any constant is zero, i.e., if y = k, any constant, then
f' = 0
Rule 6
The chain rule states that, derivative of the function of a function h(x) = f(g(x)) with respect to x is,
h'(x)= f'(g(x)).g'(x)
Example
Create a script file and type the following code into it −
syms x
syms t
f = (x + 2)*(x^2 + 3)
der1 = diff(f)
f = (t^2 + 3)*(sqrt(t) + t^3)
der2 = diff(f)
f = (x^2 - 2*x + 1)*(3*x^3 - 5*x^2 + 2)
der3 = diff(f)
f = (2*x^2 + 3*x)/(x^3 + 1)
der4 = diff(f)
f = (x^2 + 1)^17
der5 = diff(f)
f = (t^3 + 3* t^2 + 5*t -9)^(-6)
der6 = diff(f)
When you run the file, MATLAB displays the following result −
f =
(x^2 + 3)*(x + 2)
der1 =
2*x*(x + 2) + x^2 + 3
f =
(t^(1/2) + t^3)*(t^2 + 3)
der2 =
(t^2 + 3)*(3*t^2 + 1/(2*t^(1/2))) + 2*t*(t^(1/2) + t^3)
f =
(x^2 - 2*x + 1)*(3*x^3 - 5*x^2 + 2)
der3 =
(2*x - 2)*(3*x^3 - 5*x^2 + 2) - (- 9*x^2 + 10*x)*(x^2 - 2*x + 1)
f =
(2*x^2 + 3*x)/(x^3 + 1)
der4 =
(4*x + 3)/(x^3 + 1) - (3*x^2*(2*x^2 + 3*x))/(x^3 + 1)^2
f =
(x^2 + 1)^17
der5 =
34*x*(x^2 + 1)^16
f =
1/(t^3 + 3*t^2 + 5*t - 9)^6
der6 =
-(6*(3*t^2 + 6*t + 5))/(t^3 + 3*t^2 + 5*t - 9)^7
Following is Octave equivalent of the above calculation −
pkg load symbolic
symbols
x=sym("x");
t=sym("t");
f = (x + 2)*(x^2 + 3)
der1 = differentiate(f,x)
f = (t^2 + 3)*(t^(1/2) + t^3)
der2 = differentiate(f,t)
f = (x^2 - 2*x + 1)*(3*x^3 - 5*x^2 + 2)
der3 = differentiate(f,x)
f = (2*x^2 + 3*x)/(x^3 + 1)
der4 = differentiate(f,x)
f = (x^2 + 1)^17
der5 = differentiate(f,x)
f = (t^3 + 3* t^2 + 5*t -9)^(-6)
der6 = differentiate(f,t)
Octave executes the code and returns the following result −
f =
(2.0+x)*(3.0+x^(2.0))
der1 =
3.0+x^(2.0)+(2.0)*(2.0+x)*x
f =
(t^(3.0)+sqrt(t))*(3.0+t^(2.0))
der2 =
(2.0)*(t^(3.0)+sqrt(t))*t+((3.0)*t^(2.0)+(0.5)*t^(-0.5))*(3.0+t^(2.0))
f =
(1.0+x^(2.0)-(2.0)*x)*(2.0-(5.0)*x^(2.0)+(3.0)*x^(3.0))
der3 =
(-2.0+(2.0)*x)*(2.0-(5.0)*x^(2.0)+(3.0)*x^(3.0))+((9.0)*x^(2.0)-(10.0)*x)*(1.0+x^(2.0)-(2.0)*x)
f =
(1.0+x^(3.0))^(-1)*((2.0)*x^(2.0)+(3.0)*x)
der4 =
(1.0+x^(3.0))^(-1)*(3.0+(4.0)*x)-(3.0)*(1.0+x^(3.0))^(-2)*x^(2.0)*((2.0)*x^(2.0)+(3.0)*x)
f =
(1.0+x^(2.0))^(17.0)
der5 =
(34.0)*(1.0+x^(2.0))^(16.0)*x
f =
(-9.0+(3.0)*t^(2.0)+t^(3.0)+(5.0)*t)^(-6.0)
der6 =
-(6.0)*(-9.0+(3.0)*t^(2.0)+t^(3.0)+(5.0)*t)^(-7.0)*(5.0+(3.0)*t^(2.0)+(6.0)*t)
Derivatives of Exponential, Logarithmic and Trigonometric Functions
The following table provides the derivatives of commonly used exponential, logarithmic and trigonometric functions −
Function Derivative
ca.x ca.x.ln c.a (ln is natural logarithm)
ex ex
ln x 1/x
lncx 1/x.ln c
xx xx.(1 + ln x)
sin(x) cos(x)
cos(x) -sin(x)
tan(x) sec2(x), or 1/cos2(x), or 1 + tan2(x)
cot(x) -csc2(x), or -1/sin2(x), or -(1 + cot2(x))
sec(x) sec(x).tan(x)
csc(x) -csc(x).cot(x)
Example
Create a script file and type the following code into it −
syms x
y = exp(x)
diff(y)
y = x^9
diff(y)
y = sin(x)
diff(y)
y = tan(x)
diff(y)
y = cos(x)
diff(y)
y = log(x)
diff(y)
y = log10(x)
diff(y)
y = sin(x)^2
diff(y)
y = cos(3*x^2 + 2*x + 1)
diff(y)
y = exp(x)/sin(x)
diff(y)
Prof Sanjeev Kumar
Er Ashish Nishad
When you run the file, MATLAB displays the following result −
25/08/2020
for
MATLAB provides various ways for solving problems of differential and integral calculus, solving differential equations of any degree and calculation of limits. Best of all, you can easily plot the graphs of complex functions and check maxima, minima and other stationery points on a graph by solving the original function, as well as its derivative.
This chapter will deal with problems of calculus. In this chapter, we will discuss pre-calculus concepts i.e., calculating limits of functions and verifying the properties of limits.
In the next chapter Differential, we will compute derivative of an expression and find the local maxima and minima on a graph. We will also discuss solving differential equations.
Finally, in the Integration chapter, we will discuss integral calculus.
Calculating Limits
MATLAB provides the limit function for calculating limits. In its most basic form, the limit function takes expression as an argument and finds the limit of the expression as the independent variable goes to zero.
For example, let us calculate the limit of a function f(x) = (x3 + 5)/(x4 + 7), as x tends to zero.
syms x
limit((x^3 + 5)/(x^4 + 7))
MATLAB will execute the above statement and return the following result −
ans =
5/7
The limit function falls in the realm of symbolic computing; you need to use the syms function to tell MATLAB which symbolic variables you are using. You can also compute limit of a function, as the variable tends to some number other than zero. To calculate lim x->a(f(x)), we use the limit command with arguments. The first being the expression and the second is the number, that x approaches, here it is a.
For example, let us calculate limit of a function f(x) = (x-3)/(x-1), as x tends to 1.
limit((x - 3)/(x-1),1)
MATLAB will execute the above statement and return the following result −
ans =
NaN
Let's take another example,
limit(x^2 + 5, 3)
MATLAB will execute the above statement and return the following result −
ans =
14
Calculating Limits using Octave
Following is Octave version of the above example using symbolic package, try to execute and compare the result −
pkg load symbolic
symbols
x=sym("x");
subs((x^3+5)/(x^4+7),x,0)
Octave will execute the above statement and return the following result −
ans =
0.7142857142857142857
Verification of Basic Properties of Limits
Algebraic Limit Theorem provides some basic properties of limits. These are as follows −
Let us consider two functions −
f(x) = (3x + 5)/(x - 3)
g(x) = x2 + 1.
Let us calculate the limits of the functions as x tends to 5, of both functions and verify the basic properties of limits using these two functions and MATLAB.
Example
Create a script file and type the following code into it −
syms x
f = (3*x + 5)/(x-3);
g = x^2 + 1;
l1 = limit(f, 4)
l2 = limit (g, 4)
lAdd = limit(f + g, 4)
lSub = limit(f - g, 4)
lMult = limit(f*g, 4)
lDiv = limit (f/g, 4)
When you run the file, it displays −
l1 =
17
l2 =
17
lAdd =
34
lSub =
0
lMult =
289
lDiv =
1
Verification of Basic Properties of Limits using Octave
Following is Octave version of the above example using symbolic package, try to execute and compare the result −
pkg load symbolic
symbols
x = sym("x");
f = (3*x + 5)/(x-3);
g = x^2 + 1;
l1=subs(f, x, 4)
l2 = subs (g, x, 4)
lAdd = subs (f+g, x, 4)
lSub = subs (f-g, x, 4)
lMult = subs (f*g, x, 4)
lDiv = subs (f/g, x, 4)
Octave will execute the above statement and return the following result −
l1 =
17.0
l2 =
17.0
lAdd =
34.0
lSub =
0.0
lMult =
289.0
lDiv =
1.0
Left and Right Sided Limits
When a function has a discontinuity for some particular value of the variable, the limit does not exist at that point. In other words, limits of a function f(x) has discontinuity at x = a, when the value of limit, as x approaches x from left side, does not equal the value of the limit as x approaches from right side.
This leads to the concept of left-handed and right-handed limits. A left-handed limit is defined as the limit as x -> a, from the left, i.e., x approaches a, for values of x < a. A right-handed limit is defined as the limit as x -> a, from the right, i.e., x approaches a, for values of x > a. When the left-handed limit and right-handed limit are not equal, the limit does not exist.
Let us consider a function −
f(x) = (x - 3)/|x - 3|
We will show that limx->3 f(x) does not exist. MATLAB helps us to establish this fact in two ways −
By plotting the graph of the function and showing the discontinuity.
By computing the limits and showing that both are different.
The left-handed and right-handed limits are computed by passing the character strings 'left' and 'right' to the limit command as the last argument.
Example
Create a script file and type the following code into it −
f = (x - 3)/abs(x-3);
ezplot(f,[-1,5])
l = limit(f,x,3,'left')
r = limit(f,x,3,'right')
When you run the file, MATLAB draws the following plot
After this following output is displayed −
l =
-1
r =
1
Prof Sanjeev Kumar
Er Ashish Nishad
Click here to claim your Sponsored Listing.
Category
Contact the school
Telephone
Address
Agar