Defuzzification Method in Matlab PDF
Defuzzification Method in Matlab PDF
Deepti Moyi Sahoo · Nisha Rani Mahato
Concepts
of Soft
Computing
Fuzzy and ANN with Programming
Concepts of Soft Computing
Snehashish Chakraverty
•
123
Snehashish Chakraverty Deepti Moyi Sahoo
Department of Mathematics Department of Mathematics,
National Institute of Technology Rourkela School of Science
Rourkela, Odisha, India O.P. Jindal University
Punjipathra, India
Nisha Rani Mahato
Department of Mathematics
National Institute of Technology Rourkela
Rourkela, Odisha, India
This Springer imprint is published by the registered company Springer Nature Singapore Pte Ltd.
The registered company address is: 152 Beach Road, #21-01/04 Gateway East, Singapore 189721,
Singapore
Preface
In the early 1990s, soft computing (SC) gained popularity due to its efficiency in
handling problems with imprecision, approximation, decision making, and uncer-
tainty. Unlike earlier hard computing techniques which dealt with precision, soft
computing techniques consider imprecision to obtain rigorous, computationally
efficient, and robust results. The fascinating ability of soft computing techniques to
deal with human intelligence, reasoning, analysis, learning, imprecision, and mul-
titasking has made it favorable in various scientific and technological disciplines,
viz. computer science, mathematics, control theory, structural engineering, medical,
management, psychology, etc. Generally, the principal constituents of soft com-
puting include techniques focusing on fuzzy system, evolutionary computation,
machine learning, and probabilistic reasoning. In this regard, this book starts with
an introductory chapter for a brief knowledge about soft computing and its various
constituents.
Among the various constituents discussed above, fuzzy systems and machine
learning have acquired much attention in solving real-world problems dealing with
imprecision or approximations. There exist several books that deal with one or more
constituents of soft computing. But, two major concepts, viz. fuzzy set theory and
neural network, form the basic platforms of fuzzy systems and machine learning,
respectively. In this regard, the computational programming paradigm of the fuzzy
set theory concepts and artificial neural network (ANN) models is essential for their
functioning in various science and engineering disciplines. But as per the best of
our knowledge, books covering the basic concepts of fuzzy set theory and ANN in a
detailed as well as systematic manner along with programming are scarce.
Accordingly, the authors realized the need for such a book that contains a concise
and systematic description of various concepts in fuzzy set theory and ANN along
with step-by-step C and/or MATLAB codes addressing simple solved example
problems for a better understanding. Another key feature of this book is that it also
provides partial attention to handle interval uncertainty.
As regards, the book is mainly divided into two parts focusing on major soft
computing techniques, viz. fuzzy set theory and ANN. The fuzzy set theory part
comprises nine chapters, and ANN comprises the rest of the chapters. As a whole,
v
vi Preface
the book consists of 14 chapters giving basic knowledge of fuzzy set theory and
ANN. Before we incorporate the details of the book, the authors assume that the
readers have prerequisite knowledge of calculus, set theory, and linear algebra. In
fuzzy set theory, a fuzzy number may be approximately represented in terms of
closed intervals using a-cut approach. As such, Chap. 1 comprises basic prelimi-
naries related to intervals, interval arithmetic and interval matrices, accompanied
with C and MATLAB programs. Then, Chap. 2 introduces the fundamentals related
to fuzzy sets with respect to the extension of crisp (classical) sets based on its
membership function. Chapter 3 discusses various types of fuzzy numbers, and
particularly, conversions of such fuzzy numbers to intervals have been done using
a-cut approach. Chapter 4 emphasizes other properties of fuzzy sets such as rela-
tions and compositions on fuzzy relations. Chapter 5 elaborates different types of
fuzzy functions along with C or MATLAB codes related to fuzzy functions.
Chapter 6 provides the extension of classical differentiation and integration to fuzzy
differentiation and integration. Chapter 7 includes the methodology of the trans-
formation of fuzzy sets to crisp sets in terms of defuzzification methods. Chapters 8
and 9 discuss special importance of applications using interval computation in the
system of equations and eigenvalue problems, respectively, that may be further
extended to fuzzy number with respect to the parameter a. Chapters 7–10 include
MATLAB programs only for most of the solved problems.
Chapters 10–14 introduce a computing paradigm known as ANN. Chapter 10
emphasizes mainly on the basic foundation of ANN. Chapter 11 contains
McCulloch–Pitts model. Chapters 12 and 13 contain different learning algorithms.
Further, Chap. 14 includes delta learning rule and backpropagation methods.
Chapters 10–14 present MATLAB programming codes for most of the ANN titles
for variety of problems. In order to emphasize the importance of 14 chapters
mentioned above, few unsolved problems have also been included at the end of
some chapters for self-validation of the topics. Moreover, corresponding bibli-
ographies are given at the end of each chapter for ease and better referencing.
This book is mainly written for undergraduate and graduate courses all over the
world. It covers topics related to the basics of soft computing, fuzzy set theory, and
neural networks. This book may also be used by researchers, industry, faculties,
etc., for understanding the two challenging soft computing techniques, viz. fuzzy
set theory and ANN, along with programming techniques. Further, the idea for
solving the uncertain system of equations and eigenvalue problems occurring in
science and engineering disciplines has also been incorporated.
The first author greatly appreciates the support, encouragement, and patience pro-
vided by his family members, in particular his wife Shewli and daughters Shreyati
and Susprihaa. Further, the book may not have been possible without the blessings
of his beloved parents late Sh. Birendra K. Chakraborty and Smt. Parul
Chakraborty.
The second author would like to express her sincere gratitude to her family
members, especially Sh. Daya Nidhi Sahoo, Smt. Tilottama Sahoo, Trupti Moyi
Sahoo, and Deepak Kumar Sahoo, for their love and blessings. Last but not least,
the author also wants to thank her beloved son Nishit, husband Mr. Soumyaranjan
Sahoo, father-in-law Sh. Duryodhan Sahoo, and mother-in-law Smt. Rukmini
Sahoo for showing their faith and giving liberty to do all the things.
Finally, the third author’s warmest gratitude goes to her family members for
their continuous support and motivation, especially Sh. Devendra Mahato,
Smt. Premshila, Tanuja, Devasish, and Satish.
Also second and third authors greatly appreciate the inspiration of the first author
for his support and inspiration which helped a lot to learn new things. This work
would not have been possible without his guidance, support, and encouragement.
Authors sincerely acknowledge the reviewers for their fruitful suggestions and
appreciations of the book proposal. Further, all the authors do appreciate the sup-
port and help of the whole team of Springer. Finally, authors are greatly indebted to
the authors/researchers mentioned in the Bibliography section given at the end of
each chapter.
Snehashish Chakraverty
Deepti Moyi Sahoo
Nisha Rani Mahato
vii
Contents
ix
x Contents
xv
xvi About the Authors
1 Introduction
xvii
xviii Introduction: Soft Computing
2 Fuzzy System
Fuzzy systems deal with systems induced with imprecision. Fuzzy set theory forms
the core in handling fuzzy control systems. In this regard, the next section discusses
briefly the emergence of fuzzy set theory.
The concept of fuzzy set theory was introduced in 1965 by Lotfi A. Zadeh. Fuzzy
set theory emerged as a generalization of the crisp or classical set theory. The crisp
set deals with precision and accuracy, whereas fuzzy set deals with imprecision.
Introduction: Soft Computing xix
There exist several books focusing on fuzzy set theory and its wide range of
applications in various science and engineering problems. Interested readers may
refer the book comprising selected papers of L. A. Zadeh by Zadeh et al. (1996).
Zimmerman (2001) serves as an excellent book comprising detailed discussion of
fuzzy set theory and its applications. Other books, viz. Klir and Yuan (1995), Lee
(2006), Tettamanzi and Tomassini (2013), and the references therein, are encour-
aged for reference.
Chapters 2–7 in the present book have been dedicated to fuzzy set theory along
with C/MATLAB programming with respect to ease understanding and simplified
example problems. Chapter 3 includes discussions related to fuzzy numbers and its
arithmetic. Fuzzy arithmetic has proven itself as an efficient tool in handling
imprecise science and engineering systems. Hanss (2005) studied fuzzy arithmetic
as an extension of interval arithmetic and its applications in mechanical engineer-
ing. Real-world problems dealing with imprecise systems are often governed by
fuzzy differential equations. In this regard, Chakraverty et al. (2016) studied fuzzy
differential equations and its various applications. A detailed discussion on fuzzy
differential equations and inclusions was introduced by Lakshmikantham and
Mohapatra (2004). Readers may refer Chakraverty and Perera (2018) for various
fuzzy application problems, viz. robot localization, invasive alien species, air
quality quantification, radon diffusion, shallow water wave equations, and structural
problems.
Fuzzy set theory led to the emergence of multivalued logic referred as fuzzy logic
that serves as a superset of conventional Boolean logic. Generally, Boolean logic is
a binary-valued logic dealing with either 0 or 1 (No or Yes). It may be easily
associated with the crisp set having characteristic values 0 or 1. But, Boolean logic
fails to accomplish human reasoning, which led to the generalized logic, viz. fuzzy
logic. Readers may refer books, viz. Zadeh et al. (1996), Zimmerman (2001), Klir
and Yuan (1995), etc., to have a better interpretation of fuzzy logic.
In today’s world, fuzzy logic finds its usage in almost various new trending
technologies. Gradually, fuzzy logic-based washing machines, temperature con-
trollers, etc., have also gained popularity.
3 Machine Learning
Neural network is a paradigm that has been inspired from the design and func-
tioning of biological nervous system of human brain, especially neurons. Neurons
provide the ability to think, judge, and recapitulate from past experiences with
respect to every reaction. For instance, if an infant mistakenly touches fire or hot
surface, then the brain stimulates the infant to remember and be aware of the same
situation. Similarly, neural network helps in performing various other tasks by
analyzing with respect to the previous records or experiences. Neural network may
also be referred as an electrochemical pathway for the transmission of information
similar to neurons. Due to this, it is often referred as artificial neural network
(ANN).
As such, ANN may be considered as an information-processing model similar to
human brain which comprises interconnected elements referred as nodes or neu-
rons. Rabuñal (2005) gave applications for music, astronomy, etc., based on ANN.
ANN has been used by Chakraverty and Mall (2017) to obtain solutions of dif-
ferential equations occurring in various fields of science and engineering. Readers
are also encouraged to refer Chaps. 10–14 for a better understanding of ANN.
4 Evolutionary Computation
Computation comprising hybrid techniques inspired from the biological world that
replicates the evolution behavior and genetic inheritance of living species is referred
Introduction: Soft Computing xxi
5 Probabilistic Reasoning
References
T. Bäck, D.B. Fogel, Z. Michalewicz, Handbook of evolutionary computation (CRC Press, 1997)
T. Bäck, D.B. Fogel, Z. Michalewicz, Evolutionary computation 1: Basic algorithms and
operators, 1 (CRC Press, 2000)
S. Chakraverty, S. Mall, Artificial neural networks for engineers and scientists: Solving ordinary
differential equations (CRC Press, 2017)
S. Chakraverty, S. Perera, Recent advances in applications of computational and fuzzy
mathematics (Springer, 2018)
S. Chakraverty, S. Tapaswini, D. Behera, Fuzzy differential equations and applications for
engineers and scientists (CRC Press, 2016)
K.A. De Jong, Evolutionary computation: a unified approach (MIT Press, 2006)
L. Fortuna, G. Rizzotto, M. Lavorgna, G. Nunnari, M.G. Xibilia, R. Caponetto, Soft computing:
New trends and applications (Springer Science and Business Media, 2012)
M. Hanss, Applied fuzzy arithmetic (Springer-Verlag, Berlin Heidelberg, 2005)
V. Kecman, Learning and soft computing: Support vector machines, neural networks, and fuzzy
logic models (MIT Press, 2001)
G.J. Klir, B. Yuan, Fuzzy sets and fuzzy logic, 4 (Prentice Hall, New Jersey, 1995)
V. Lakshmikantham, R.N. Mohapatra, Theory of fuzzy differential equations and inclusions (CRC
Press, 2004)
P. Larrañaga, J.A. Lozano, Estimation of distribution algorithms: A new tool for evolutionary
computation, 2 (Springer Science and Business Media, 2001)
K.H. Lee, First course on fuzzy theory and applications (Springer, New York, 2006)
xxii Introduction: Soft Computing
R.S. Michalski, J.G. Carbonell, T.M. Mitchell, Machine learning: An artificial intelligence
approach (Springer Science and Business Media, 2013)
J.R. Rabuñal, Artificial neural networks in real-life applications (IGI Global, 2005)
S.N. Sivanandam, S.N. Deepa, Principles of soft computing (Wiley India Pvt. Ltd., New Delhi,
2012)
A. Tettamanzi, M. Tomassini, Soft computing: Integrating evolutionary, neural and fuzzy systems
(Springer Science and Business Media, 2013)
L.A. Zadeh, G.J. Klir, B. Yuan, Fuzzy sets, fuzzy logic, and fuzzy systems: Selected papers, 6
(World Scientific, 1996)
H.J. Zimmerman, Fuzzy set theory and its applications (Springer, New York, 2001)
Part I
Fuzzy Set Theory
Chapter 1
Intervals
The basics of Soft Computing (SC) have been discussed in this chapter. Moreover,
this book mainly focuses on the two major SC techniques, viz., fuzzy set theory and
artificial neural network, that are discussed in subsequent chapters. In case of fuzzy
sets, fuzzy number gets converted to interval form using α-cut as given in Chap. 3.
As such, preliminaries related to intervals and interval matrices have been discussed
in this chapter. The chapter also includes arithmetic operations for intervals and
interval matrices. Further, the classical interval arithmetic has also been explained
in this chapter along with corresponding C and MATLAB codes.
a + ā
ac = .
2
Interval width: The interval width is referred as the distance between the lower
and upper bounds of an interval [a] = [a, ā], that is
a w = ā − a.
ā − a
a = .
2
In terms of interval center and radius, an interval [a] may be written as [a] =
[a, ā] = [a c − a , a c + a ]. As such, the pictorial representations of interval center,
radius, and width have been provided in Fig. 1.2.
Similar to the arithmetic operation of addition, subtraction, multiplication, and
division for any two real numbers x, y ∈ , interval arithmetic operations have been
defined in Moore et al. (2009). The classical interval arithmetic operations in terms
of the binary operations, viz., addition, subtraction, multiplication, and division, are
discussed below:
Interval arithmetic: If [a] = [a, ā] and [b] = [b, b̄] be two intervals, then the
classical arithmetic operations for the two intervals are written as
Addition:
Subtraction:
Multiplication:
[a] · [b] = min a · a, a · b̄, ā · b, ā · b̄ , max a · a, a · b̄, ā · b, ā · b̄ , (1.3)
Division:
[a] a ā
, , 0∈
/ [b]
= b̄ b . (1.4)
[b] (−∞, ∞), 0 ∈ [b]
This section is devoted to perform the addition and subtraction operations given
in Eqs. (1.1) and (1.2). In this regard, we have considered an example problem in
Example 1.1.
Example 1.1 Consider two intervals [a] = [−8, 9] and [b] = [−4, 7]. Then,
compute the interval addition and subtraction of the two intervals.
Program 1.1: Write a C program for computing addition and subtraction of two
intervals.
//Addition and subtraction of two intervals
#include<stdio.h>
#include<conio.h>
int main()
{
float al,au,bl,bu,cl,cu,dl,du;
printf("Enter the lower (al) and upper (au) limit of first interval:\n");
scanf("%f%f",&al,&au);
printf("Enter the lower (bl) and upper (bu) limit of second interval:\n");
6 1 Intervals
scanf("%f%f",&bl,&bu);
//Addition of two intervals
cl=al+bl;
cu=au+bu;
printf("The addition of two intervals [%f,%f] + [%f,%f] is:\n[%f,%f]\n",
al,au,bl,bu,cl,cu);
//Subtraction of two intervals
dl=al-bu;
du=au-bl;
printf("The subtraction of two intervals [%f,%f] - [%f,%f] is:\n[%f,%f]\n",
al,au,bl,bu,dl,du);
getch();
return 0;
}
The same results of Example 1.1 have been obtained using Program 1.1 by con-
sidering the interval bounds [a] = [−8, 9] and [b] = [−4, 7].
Input:
Enter the lower (al) and upper (au) limit of first interval:
-8 9
Enter the lower (bl) and upper (bu) limit of second interval:
-4 7
Output:
The addition of two intervals [-8.000000,9.000000] + [4.000000,7.000000] is:
[-4.000000,16.000000]
The subtraction of two intervals [-8.000000,9.000000] - [4.000000,7.000000] is:
[-15.000000,13.000000]
Accordingly, the output window for solving Example 1.1 using Program 1.1 has
been depicted in Fig. 1.3.
Next section presents the binary operation, viz., multiplication of intervals.
[a] · [b] = [min{−32, −56, 36, 63}, max{−32, −56, 36, 63}] = [−56, 63].
Input:
Enter the lower (al) and upper (au) limit of first interval:
-8 9
Enter the lower (bl) and upper (bu) limit of second interval:
-4 7
Output:
The multiplication of two intervals [-8.000000,9.000000] x [4.000000,7.000000] is:
[-56.000000,63.000000]
Further, the output window for solving Example 1.1 using Program 1.1 has been
depicted in Fig. 1.4.
In this section, division of two intervals based on Eq. (1.4) has been considered with
respect to an example problem given in Example 1.3.
[a]
Example 1.3 Compute the value of [b]
for two intervals [a] = [−8, 9] and [b] =
[4, 7].
[a] 8 9
= − , = [−1.142857, 2.25].
[b] 7 4
Then, the program for computation of division of two intervals has been incorpo-
rated in Program 1.3.
1.1 Preliminaries of Intervals 9
Input:
Enter the first interval [al,au]:
-8 9
Enter the second interval [bl,bu] such that zero doesnot belong to [bl,bu]:
47
Output:
The division of two intervals [-8.000000,9.000000] / [4.000000,7.000000] is:
[-1.142857,2.250000]
Then, the associated output window for Program 1.3 with respect to Example 1.3
has been given in Fig. 1.5.
Then, the additive and multiplicative inverse of interval have been defined below.
Inverse: Additive inverse of an interval [a] = [a, ā] may be defined as
10 1 Intervals
and the multiplicative inverse of an interval [a] = [a, ā] may be defined as
1 ,
1 1
, 0∈ / [a]
[a]−1 = = ā a . (1.6)
[a, ā] (−∞, ∞), 0 ∈ [a]
Using Program 1.4, Example 1.3 has been solved using the following input to
obtain the multiplicative inverse of a given interval.
1.1 Preliminaries of Intervals 11
Input:
Enter the first interval [al,au]:
-8 9
Output:
The inverse of an interval [8.000000,9.000000] is:
[0.111111,0.125000]
Then, the corresponding output window for execution of Program 1.4 associated
with Example 1.3 has been illustrated in Fig. 1.6.
Accordingly, the basic interval arithmetic operations discussed in Sects.
1.1.1–1.1.3 are computed with respect to MATLAB codes in Program 1.5.
Using Program 1.5, Example 1.3 has been computed to obtain the addition, sub-
traction, multiplication, and division of given intervals.
Input:
Enter the lower bound of interval a: -8
Enter the upper bound of interval a: 9
Enter the lower bound of interval b: -4
Enter the upper bound of interval b: 7
Enter the lower bound of interval c: 4
Enter the upper bound of interval c: 7
Output:
The addition of two intervals is:
suml = -12
sumu =16
The subtraction of two intervals is:
diffl =-15
diffu = 13
The multiplication of two intervals is:
mul = -56
muu = 63
The division of two intervals a and c is:
divl = 1.1429
divu = 2.25
1.1 Preliminaries of Intervals 13
Next section extends the basic terminologies and arithmetic operations related
with intervals to interval matrices.
Width matrix: Width matrix is the matrix consisting of width with respect to
each element [ai j ] as
14 1 Intervals
⎛ w ⎞
w
a11 w
a12 · · · a1n
⎜ aw aw ⎟
⎜ 21 22 ⎟
Aw = ⎜ . . ⎟. (1.8)
⎝ .. .. ⎠
am1 am2 · · · amn
w w w
Radius matrix: Radius matrix is the matrix consisting of radius of each element
[ai j ] as
⎛ ⎞
a11 a12 · · · a1n
⎜ a a ⎟
⎜ 21 22 ⎟
A = ⎜ . .. ⎟. (1.9)
⎝ .. . ⎠
am1 am2 · · · amn
Similar to intervals, an interval matrix [A] in terms of its center and radius matrices
may be expressed as [A] = [Ac − A , Ac + A ]. Using Eqs. (1.7) to (1.9), an interval
matrix
⎛ ⎞
[−8, −1] [3, 6] [2, 4] [−6, −4]
⎜ [3, 6] [−4, −1] [3, 7] [0, 5] ⎟
[A] = ⎜
⎝ [2, 4]
⎟
[3, 7] [2, 4] [−4, −2] ⎠
[−6, −4] [0, 5] [−4, −2] [−6, −2]
Program 1.6: Write a C program for computing center, width, and radius matrices
of a given interval matrix.
The above program has been then executed to obtain the center, width, and radius
of a given interval matrix as follows.
Input:
Enter the number of rows and columns in interval matrix [A]
33
Enter the lower (Al) bound of the interval matrix [A]:
-10 3 8
-7 0 -8
4 7 -7
Enter the upper (Au) bound of the interval matrix [A]:
-8 5 10
-5 2 -6
6 9 -5
Output:
The center matrix Ac for the interval matrix [A] is:
-9.000000 4.000000 9.000000
-6.000000 1.000000 -7.000000
5.000000 8.000000 -6.000000
The width matrix Aw for the interval matrix [A] is:
2.000000 2.000000 2.000000
2.000000 2.000000 2.000000
2.000000 2.000000 2.000000
The radius matrix Ad for the interval matrix [A] is:
1.000000 1.000000 1.000000
1.000000 1.000000 1.000000
1.000000 1.000000 1.000000
Fig. 1.7 Output of center, width, and radius matrices of an interval matrix
Program 1.7: Write a MATLAB program for computing center, width, and radius
matrices of a given interval matrix.
Using the MATLAB codes given in Program 1.7, the center, width, and radius of
a given interval matrix are obtained.
Input:
Enter the lower bound of interval matrix A:[-10 3 8;-7 0 -8;4 7 -7]
Enter the upper bound of interval matrix A:[-8 5 10;-5 2 -6;6 9 -5]
Output:
The center matrix Ac for the interval matrix A is:
Ac = -9 4 9
-6 1 -7
5 8 -6
18 1 Intervals
Further, the arithmetic operations in case of interval matrices have been discussed
in detail in Sect. 1.2.1.
Interval matrix arithmetic: If [A] = [A, A] and [B] = [B, B] be two intervals,
then the arithmetic operations for intervals may be written as follows:
Addition:
Subtraction:
Based on Eqs. (1.10) and (1.11), corresponding C and MATLAB programs have
been incorporated in Programs 1.8 and 1.9, respectively.
Program 1.8: Compute addition and subtraction of two given interval matrices
using C programming.
scanf("%d%d",&m,&n);
printf("Enter the lower (Al) bound of first interval matrix [A]:\n");
for (i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
scanf("%f",&Al[i][j]);
}
}
printf("Enter the upper (Au) bound of first interval matrix [A]:\n");
for (i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
scanf("%f",&Au[i][j]);
}
}
printf("Enter the lower (Bl) bound of second interval matrix [B]:\n");
for (i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
scanf("%f",&Bl[i][j]);
}
}
printf("Enter the upper (Bu) bound of second interval matrix [B]:\n");
for (i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
scanf("%f",&Bu[i][j]);
}
}
//Addition of interval matrices
printf("The addition of two interval matrices [A] and [B] is
[C]=[A]+[B]:\n");
for (i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
Cl[i][j]=Al[i][j]+Bl[i][j];
Cu[i][j]=Au[i][j]+Bu[i][j];
printf("[%f,%f]\t",Cl[i][j],Cu[i][j]);
}
printf("\n");
}
//Subtraction of interval matrices
printf("The subtraction of the interval matrix [B] from [A] is [D]=[A]-
[B]\n");
20 1 Intervals
for (i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
Dl[i][j]=Al[i][j]-Bu[i][j];
Du[i][j]=Au[i][j]-Bl[i][j];
printf("[%f,%f]\t",Dl[i][j],Du[i][j]);
}
printf("\n");
}
getch();
return 0;
}
Then, the above MATLAB codes have been executed to compute the addition and
subtraction of two interval matrices as given below.
Input:
Enter the number of rows and columns in interval matrices [A] and [B]
22
Enter the lower (Al) bound of first interval matrix [A]:
45
64
Enter the upper (Au) bound of first interval matrix [A]:
68
75
Enter the lower (Bl) bound of second interval matrix [B]:
2 -2
-1 2
Enter the upper (Bu) bound of second interval matrix [B]:
41
14
Output:
The addition of two interval matrices [A] and [B] is [C]=[A]+[B]:
[6.000000,10.000000] [3.000000,9.000000]
[5.000000,9.000000] [6.000000,9.000000]
The subtraction of the interval matrix [B] from [A] is [D]=[A]-[B]
[0.000000,4.000000] [4.000000,10.000000]
[4.000000,8.000000] [0.000000,3.000000]
The corresponding output window for Program 1.8 has been depicted in Fig. 1.8.
1.2 Interval Matrices 21
Fig. 1.8 Output of addition and subtraction for two interval matrices
Program 1.9: Write a MATLAB program for computing addition and subtraction
for given interval matrices.
Then, the addition and subtraction operations for two interval matrices have been
performed using Program 1.9.
22 1 Intervals
Input:
Enter the lower bound of interval matrix [A]: [4 5;6 4]
Enter the upper bound of interval matrix [A]: [6 8;7 5]
Enter the lower bound of interval matrix [B]: [2 -2;-1 2]
Enter the upper bound of interval matrix [B]: [4 1;2 4]
Output:
The addition of two intervals is matrix [C]
The lower bound of Cl and upper bound of Cu are obtained as:
Cl = 6 3
5 6
Cu = 10 9
9 9
The subtraction of two interval matrices [A] and [B] is matrix [D]
The lower bound of Dl and upper bound of Du are obtained as:
Dl = 0 4
4 0
Du = 4 10
8 3
The applications of interval matrices for solving interval system of linear equations
and interval eigenvalue problems are discussed later in Chaps. 8 and 9, respectively.
Moreover, few unsolved problems have been included for self-evaluation of the
readers. Also, readers are encouraged to refer Alefeld and Herzberger (1983), Hansen
(1975), Moore (1962, 1979), Moore and Lodwick (2003), Moore et al. (2009), and
the references mentioned therein for further knowledge of interval computations.
Exercise
1. Write a C or MATLAB program for finding the center, radius, and width of a
given interval [a].
2. Compute the value of ([1, 2] + [3, 8]) × [−4, 7] − ([−1, 10]/[−7, −1]) using C
program.
3. Write a C program to compute additive inverse of interval [−4, 8].
4. Write a C or MATLAB program to compute multiplication of two given interval
matrices [A] and [B] by extending the basic multiplication of intervals.
References
R.E. Moore, Interval arithmetic and automatic error analysis in digital computing, Ph. D. Disserta-
tion, Department of Mathematics, Stanford University, 1962
R.E. Moore, Methods and Applications of Interval Analysis, vol. 2 (SIAM, New Delhi, 1979)
R.E. Moore, W. Lodwick, Interval analysis and fuzzy set theory. Fuzzy Sets Syst. 135(1), 5–9 (2003)
R.E. Moore, R.B. Kearfott, M.J. Cloud, Introduction to Interval Analysis (SIAM, Philadelphia, PA,
2009)
Chapter 2
Fuzzy Sets
In this chapter, the definition and preliminaries related to crisp sets have been
extended to fuzzy sets based on its membership function. As such, preliminaries
related to fuzzy sets, its membership function, and operations of fuzzy sets have
been discussed in Sect. 2.1. Further, C and/or MATLAB programming codes have
been included for computational verification.
Let us discuss the terminology “crisp sets” before the explanation of fuzzy sets. A
crisp set or classical set is a collection of well-defined objects from a universal set X.
Generally for a crisp set, the characteristic function considers the values {0, 1} that
is for any x ∈ X , either x ∈ A (characteristic value is 1) or x ∈ / A (characteristic
value is 0). But if the characteristic or membership function associated with the
elements belongs to a certain extent of its dependency to the respective set, then
the possibility of dependency for the elements may vary over 0–1. In such case, the
membership function for fuzzy set is advantageous over the classical characteristic
function, which is considered as a mapping from universal set X to [0, 1], that is,
μ A : X → [0, 1].
So, the fuzzy sets may be considered as vague or uncertain sets dealing with
imprecision and having membership function lying in [0, 1].
As such, the Venn diagrams of crisp and fuzzy sets have been depicted in Figs. 2.1
and 2.2, respectively.
It may be seen from the above figures that the boundary of fuzzy set is not fixed,
rather it is uncertain. In this regard, a classical definition of fuzzy set has been given.
Fuzzy set: A fuzzy set à is defined in terms of ordered pairs à = {(x, μ à (x))/x ∈
X, μ Ã (x) ∈ [0, 1]}, where μ Ã (x) is the membership function of x ∈ X . Here, X
resembles the universal set.
Other than the ordered pair form à = {(x1 , μ à (x1 )), (x2 , μ à (x2 )), . . .}, where
μ Ã (xi ) are membership functions for xi ∈ X and i = 1, 2, . . ., a fuzzy set may also
be expressed in different forms such as
μ Ã (x1 ) μ Ã (x2 ) μ Ã (xk )
à = + + ··· = ,
x1 x2 xk
in case of discrete fuzzy set. Further, in continuous case, the fuzzy set may be
expressed as
μ Ã (x)
à = d x.
x
2.1 Preliminaries of Fuzzy Sets 27
Solution: The fuzzy set associated with the universal set X = {2, 3, 4, 5, 6, 7, 8}
resembling “suitable vehicle for a family consisting of four members” may be written
in the ordered form as
à = {(2, 0), (3, 0.5), (4, 1), (5, 1), (6, 0.8), (7, 0.1), (8, 0), (9, 0), (10, 0)}.
Example 2.2 Let us consider a universal set X as real number and a continuous
fuzzy set à as “real numbers greater than 5”. Obtain the suitable membership function
and show it graphically.
Example 2.3 Consider a fuzzy set à = “real numbers close to 10”. Obtain the gen-
erating function yielding the membership function associated with Ã.
1
μ Ã (x) = .
1 + (x − 10)2
The corresponding C and MATLAB codes related to Example 2.3 for computation
of the membership values of fuzzy set à are incorporated in Programs 2.1 and 2.2,
respectively.
Using Program 2.1, equivalent membership values are obtained for the member-
ship function of Example 2.3 after execution.
Input:
Enter the number of elements in fuzzy set A={real numbers close to 10}:
10
Enter the elements x in A={(x,muA(x))}
2 4 6 8 10 12 14 16 18 20
Output:
The corresponding membership values for fuzzy set A are:
x muA(x)
2.000000 0.015385
4.000000 0.027027
6.000000 0.058824
8.000000 0.200000
10.000000 1.000000
12.000000 0.200000
14.000000 0.058824
16.000000 0.027027
18.000000 0.015385
20.000000 0.009901
Then, the output window of Program 2.1 has been depicted in Fig. 2.4.
Fig. 2.4 Output of generated membership values for fuzzy set “real numbers close to 10”
30 2 Fuzzy Sets
Using Program 2.2, the membership function of fuzzy set given in Example 2.3
is generated and the corresponding plot is depicted in Fig. 2.5.
The next section discusses the terminologies support, height, core, and boundary
related to fuzzy sets.
Output:
The membership function plot for fuzzy set is: given in Fig. 2.5
Fig. 2.5 MATLAB plot of fuzzy set “real numbers close to 10”
2.3 Support, Height, Core, and Boundary of Fuzzy Set 31
Support: Support of a fuzzy set is defined as the crisp collection of elements with
respect to universal set X having positive membership function, that is,
sup μ Ã (x).
x
If the height of a fuzzy set is 1 as sup μ Ã (x) = 1, then such set is referred as
x
normalized fuzzy set.
Core: Core of a fuzzy set is the crisp collection of the elements having membership
values equal to 1, that is,
The graphical representation of support, core, and boundary for a fuzzy set has
been depicted in Fig. 2.6.
has been considered for the computation of support, height, core, and boundary. The
corresponding C and MATLAB programs associated with fuzzy set à = “close to
0” have been incorporated in Programs 2.3 and 2.4, respectively.
Program 2.3: Write a C program for computing support, height, core, and boundary
of fuzzy set close to 0.
printf("%f ",max);
printf("\nCore={");
for(i=1;i<=n;i++)
{
if(mu[i]==1)
printf("%f ",x[i]);
}
printf("}\nBoundary={");
for(i=1;i<=n;i++)
{
if(mu[i]>=0&&mu[i]<1)
printf("%f ",x[i]);
}
printf("}\n");
getch();
return 0;
}
The support, height, core, and boundary of the fuzzy set à = “close to 0” have
been obtained after executing Program 2.3.
Input:
Enter the number of elements in fuzzy set A={(x,muA(x))}
5
Enter the values of x
-2 -1 0 1 2
The corresponding membership values muA(x) are:
x muA(x)
-2.000000 0.200000
-1.000000 0.500000
0.000000 1.000000
1.000000 0.500000
2.000000 0.200000
Output:
Support={-2.000000 -1.000000 0.000000 1.000000 2.000000 }
Height=1.000000
Core={0.000000 }
Boundary={-2.000000 -1.000000 1.000000 2.000000 }
Further, the output window related to Program 2.3 has been depicted in Fig. 2.7.
34 2 Fuzzy Sets
Fig. 2.7 Output of support, height, core, and boundary of a fuzzy set
Program 2.4: Write a MATLAB program for computing support, height, core, and
boundary of a fuzzy set.
end
disp(c);
%Boundary
disp('Boundary=');
k=1;
for i=1:n
if(mu(i)>=0&&mu(i)<1)
b(i)=x(i);
k=k+1;
end
end
disp(b)
The support, height, core, and boundary of fuzzy set have been obtained using
Program 2.4.
Input:
Enter the x values of A
[-2, -1, 0, 1, 2]
The corresponding membership values are:
0.2000 0.5000 1.0000 0.5000 0.2000
Output:
Support= -2 -1 0 1 2
Height= 1
Core= 0
Boundary= -2 -1 1 2
Similar to the set operations of crisp sets, the basic set operations, viz., union,
intersection, and complement, have been extended to fuzzy sets with respect to the
membership functions in the next section.
The operations of intersection, union, and complement of crisp sets have been
extended to fuzzy sets as:
36 2 Fuzzy Sets
• Intersection: If à and B̃ are two fuzzy sets with membership functions μ à (x) and
μ B̃ (x), respectively, then intersection may be considered as C̃ = Ã ∩ B̃, where
• Union: The union of two fuzzy sets à and B̃ may be considered as C̃ = à ∪ B̃,
where
Then, the computation of intersection and union of given fuzzy sets have been
incorporated in Example 2.4.
and
C̃ = Ã ∪ B̃ = {(1, 0.1), (2, 0.5), (3, 0.8), (4, 1), (5, 1), (6, 0.3), (7, 0.1), (8, 0), (9, 0), (10, 0).
Program 2.5: Write a C program for computing intersection, union, and comple-
ment of two given fuzzy sets.
if(a[i]==b[j])
{
if(mu1[i]>mu2[j])
{
max=mu1[i];
}
else
{
max=mu2[j];
}
printf("(%f,%f) ",a[i],max);
c[i]=a[i];
}
}
if(a[i]!=c[i]&&b[i]!=c[i])
{
printf("(%f,%f) ",a[i],mu1[i]);
printf("(%f,%f) ",b[i],mu2[i]);
}
}
printf("}\n");
printf("\nThe complement of fuzzy set A is:\n");
printf("{");
for(i=1;i<=10;i++)
{
printf("(%f,%f) ",a[i],1-mu1[i]);
}
printf("}\n");
printf("\nThe complement of fuzzy B is:\n");
printf("{");
for(i=1;i<=10;i++)
{
printf("(%f,%f) ",b[i],1-mu2[i]);
}
printf("}\n");
getch();
return 0;
}
Program 2.5 has been executed for Example 2.4 to compute the intersection and
union of the fuzzy sets.
40 2 Fuzzy Sets
Input:
Enter the number of elements in fuzzy sets A and B
10
Enter the x values in A={(x, muA(x))}
1 2 3 4 5 6 7 8 9 10
Enter the corresponding membership values in A
0.1 0.5 0.8 1 0.7 0.3 0.1 0 0 0
Enter the x values in B={(x,muB(x))}
1 2 3 4 5 6 7 8 9 10
Enter the membership values in B
0 0.2 0.8 1 1 0.3 0 0 0 0
Output:
The intersection of fuzzy sets A and B is:
{(1.000000,0.000000) (2.000000,0.200000) (3.000000,0.800000)
(4.000000,1.000000) (5.000000,0.700000) (6.000000,0.300000)
(7.000000,0.000000) (8.000000,0.000000) (9.000000,0.000000)
(10.000000,0.000000) }
Then, the output window for Program 2.5 is depicted in Fig. 2.10.
2.4 Intersection, Union, and Complement 41
Fig. 2.10 Output of intersection, union, and complement of fuzzy sets A and B
Program 2.6: Write a MATLAB program for computing intersection, union, and
complement of two given fuzzy sets.
end
disp('The intersection of A1 and A2 is (x,muI(x)):');
disp(' x muI(x)');
disp([c' muI'])
disp('The union of A1 and A2 is (x,muU(x)):');
disp(' x muU(x)');
disp([c' muU'])
%Complement
disp('The complement of set A1 is:');
disp(' x muA1c(x)');
disp([a' (1-mu1)'])
disp('The complement of set A2 is:');
disp(' x muA2c(x)');
disp([a' (1-mu2)'])
Further, using Program 2.5, Example 2.4 is computed to obtain the intersection
and union of the fuzzy sets.
Input:
Enter the elements x in fuzzy set A1=(x,muA1(x)):
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Enter the corresponding membership values in A1:
[0.1, 0.5, 0.8, 1, 0.7, 0.3, 0.1, 0, 0, 0]
Enter the elements x in fuzzy set A2=(x,muA2(x)):
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Enter the corresponding membership values in A2:
[0, 0.2, 0.8, 1, 1, 0.3, 0, 0, 0, 0]
Output:
The intersection of A1 and A2 is (x,muI(x)):
x muI(x)
1.0000 0
2.0000 0.2000
3.0000 0.8000
4.0000 1.0000
5.0000 0.7000
6.0000 0.3000
7.0000 0
8.0000 0
9.0000 0
10.0000 0
2.4 Intersection, Union, and Complement 43
x muA1c(x)
1.0000 0.9000
2.0000 0.5000
3.0000 0.2000
4.0000 0
5.0000 0.3000
6.0000 0.7000
7.0000 0.9000
8.0000 1.0000
9.0000 1.0000
10.0000 1.0000
The next section discusses other operations, viz., power, algebraic sum, bounded
sum, bounded difference, and algebraic product for fuzzy sets.
44 2 Fuzzy Sets
Apart from the operations discussed in Sect. 2.4, there exist other operations as stated
below:
• mth power of a fuzzy set: The mth power of a fuzzy set à is defined as
Example 2.5 Compute the bounded sum and difference of two fuzzy sets à =
{(3, 0.5), (5, 1), (7, 0.6)} and B̃ = {(3, 1), (5, 0.6)}.
Solution: According to Eqs. (2.3) and (2.4), the bounded sum and difference are
obtained, respectively, as
C̃ = Ã ⊕ B̃ = {(3, 1), (5, 1), (7, 0.6)} and C̃ = Ã − B̃ = {(3, 0.5), (5, 0.6)}.
2.5 Other Operations 45
Program 2.7: Find the bounded sum and bounded difference of given fuzzy sets
using C program.
Then, Program 2.7 has been executed with respect to Example 2.5.
Input:
Enter the number of elements in fuzzy set A and B:
3
Enter the x values in A={(x,muA(x))}
357
Enter the corresponding membership values in A
0.5 1 0.6
Enter the x values in B={(x,muB(x))}
357
Enter the corresponding membership values in B
1 0.6 0
Output:
The bounded sum of given fuzzy sets is:
{(3.000000,1.000000) (5.000000,1.000000) (7.000000,0.600000) }
The bounded difference of given fuzzy sets is:
{ (3.000000,0.500000) (5.000000,0.600000) (7.000000,0.000000) }
2.5 Other Operations 47
Fig. 2.11 Output of bounded sum and difference of two fuzzy sets
The output window for the above Program 2.7 is depicted in Fig. 2.11.
Program 2.8: Write a MATLAB program for finding the bounded sum and bounded
difference of given fuzzy sets.
%Bounded sum and bounded difference of two fuzzy sets
clear all;
clc;
a = input('Enter the elements x in fuzzy set A=(x,muA(x)):\n');
mu1 = input('Enter the corresponding membership values in A:\n');
n = length(a);
b = input('Enter the elements x in fuzzy set B=(x,muB(x)):\n');
mu2 = input('Enter the corresponding membership values in B:\n');
m = length(b);
k=1;
disp('The bounded sum of x having membership values (ms) for the given fuzzy sets
is:');
for i=1:n
if(a(i)==b(i))
ms(i)=min(1,mu1(i)+mu2(i));
end
end
disp(' x ms')
disp([a' ms'])
disp('The bounded difference of x having membership values (md) for the given
fuzzy sets is:');
for i=1:n
if(a(i)==b(i))
md(i)=max(0,(mu1(i)+mu2(i))-1);
end
end
disp(' x md')
disp([a' md'])
Using Program 2.8, the bounded sum and difference for the fuzzy sets given in
Example 2.5 are then obtained.
48 2 Fuzzy Sets
Input:
Enter the elements x in fuzzy set A=(x,muA(x)):
[3, 5, 7]
Enter the corresponding membership values in A:
[0.5, 1, 0.6]
Enter the elements x in fuzzy set B=(x,muB(x)):
[3, 5, 7]
Enter the corresponding membership values in B:
[1, 0.6, 0]
Output:
The bounded sum of x having membership values (ms) for the given fuzzy sets is:
x ms
3.0000 1.0000
5.0000 1.0000
7.0000 0.6000
The bounded difference of x having membership values (md) for the given fuzzy
sets is:
x md
3.0000 0.5000
5.0000 0.6000
7.0000 0
Example 2.6 Find B̃ if à = {(−1, 0.5), (0, 0.8), (1, 1), (2, 0.4)} and f (x) = x 2 .
Example 2.7 Find B̃ if Ã1 = {(−1, 1), (0, 0.4), (1, 0.2)} and Ã2 =
{(−1, 0.5), (0, 0.08), (1, 1)} be two fuzzy sets having mapping f (x1 , x2 ) = x12 + x22 .
μ B̃ (1) = sup {min(1, 0.08), min(0.4, 0.5), min(0.2, 0.5), min(0.2, 1)} = 0.4
(−1,0),(0,−1),(0,1),
(1,0)∈ f −1 (y)
and
μ B̃ (2) = sup {min(1, 0.5), min(1, 1), min(0.2, 0.5), min(0.2, 1)} = 1.
(−1,−1),(−1,1),(1,−1),
(1,1)∈ f −1 (y)
So, B̃ = {(0, 0.2), (1, 0.4), (2, 1)}. Accordingly, the corresponding MATLAB
programs for Example 2.7 have been incorporated in Program 2.9.
Program 2.9: Write a MATLAB program depicting the usage of extension principle
for computation of fuzzy image.
Using Program 2.9, the fuzzy set B̃ given in Example 2.6 is obtained using the
extension principle.
Input:
Enter the elements x in fuzzy set A1=(x,muA1(x)):
[-1, 0, 1]
Enter the corresponding membership values in A1:
[1, 0.4, 0.2]
Enter the elements x in fuzzy set A2=(x,muA2(x)):
[-1, 0, 1]
Enter the corresponding membership values in A2:
[0.5, 0.08, 1]
Output:
The membership values of fuzzy set B using extension principle is:
y muB(y)
0 0.0800
1.0000 0.4000
2.0000 1.0000
Books viz. Zimmerman (2001), Klir and Folger (2006), and Lee (2006) may be
referred by the readers for further knowledge. Finally, few unsolved problems have
been included below for self-evaluation.
2.6 Extension Principle 51
Exercise
1. Write a C program to compute the union and intersection for given number of
fuzzy sets.
2. Write C or MATLAB codes for computing the mth power of a fuzzy set for a
given fuzzy set Ã.
3. Find algebraic sum and product of any two fuzzy sets with the help of C or
MATLAB programming codes.
4. Write MATLAB codes to find a fuzzy set B̃ in Y using the extension principle
for a particular r.
5. Based on the extension principle, compute the fuzzy image of given fuzzy sets
using C programming.
References
G.J. Klir, T.A. Folger, Fuzzy Sets, Uncertainty and Information (Prentice Hall of India Private
Limited, New Delhi, 2006)
K.H. Lee, First Course on Fuzzy Theory and Applications (Springer, New York, 2006)
H.J. Zimmerman, Fuzzy Set Theory and Its Applications (Springer, New York, 2001)
Chapter 3
Fuzzy Numbers
In this chapter, preliminaries related to fuzzy numbers have been discussed. Fuzzy
numbers and fuzzy arithmetic may be considered as an extension of classical real
numbers and its arithmetic. As such, we may understand fuzzy arithmetic as basics
for handling fuzzy eigenvalue problems, nonlinear equations, system of nonlinear
equations (Abbasbandy and Asady 2004), differential equations (Chakraverty et al.
2016), etc. There exist different types of fuzzy numbers as discussed in Hanss (2005),
but for the sake of completeness of the chapter, triangular, trapezoidal, and Gaussian
fuzzy numbers based on the membership functions have only been included here.
Further, the conversions of these fuzzy numbers to fuzzy intervals with respect to the
concept of intervals (Chap. 1) are incorporated. In this regard, the interval arithmetic
mentioned in Chap. 1 has been further extended to fuzzy intervals in Sect. 3.4.
A convex fuzzy set à is a fuzzy set having membership function μ à (x), satisfying
where x1 , x2 ∈ X and λ ∈ [0, 1]. Figure 3.1 depicts convex and non-convex fuzzy
sets.
Convex fuzzy sets defined with respect to universal set (set of all real numbers)
may be interpreted as fuzzy numbers. In this respect, the classical definition of fuzzy
number is given below.
Fuzzy number: A fuzzy set à is referred as a fuzzy number ã if the following
properties are satisfied:
• Ã is convex,
• Ã is normalized, sup μ Ã (x) = 1,
x
• ∃ at least one x ∈ such that μ Ã (x) = 1, and
© Springer Nature Singapore Pte Ltd. 2019 53
S. Chakraverty et al., Concepts of Soft Computing,
https://doi.org/10.1007/978-981-13-7430-2_3
54 3 Fuzzy Numbers
As such, the fuzzy set may not be considered as a fuzzy number. In such cases, the
fuzzy set may be normalized to form a fuzzy number b̃ having membership function
μ (x)
μb̃ (x) = sup à μ (x) (Fig. 3.2b).
Ã
x
Then, the fuzzy numbers may be classified into various categories depending on
the respective membership functions. In this regard, three types of fuzzy numbers
have been incorporated in next section.
In this section, we have discussed three types of fuzzy numbers, viz., Triangular Fuzzy
Number (TFN), Trapezoidal Fuzzy Number (TrFN), and Gaussian Fuzzy Number
(GFN). Further, C and MATLAB codes have been incorporated for computation of
different fuzzy numbers.
3.2 Types of Fuzzy Numbers 55
It may be seen from Fig. 3.3 that a and c form the lower and upper bounds of the
TFN having membership values μã (a) = μã (c) = 0. Further, the membership value
corresponding to the TFN at x = b is μã (b) = 1 which means that the TFN takes
the crisp (exact) value at x = b.
In order to have a better understanding, we have considered a TFN in Example
3.1.
Example 3.1 Compute the membership function associated with TFN ã =
t f n(−1, 1, 2).
Solution: Here, a = −1, b = 1 and c = 2 with respect to TFN ã = t f n(a, b, c).
Accordingly, the membership function associated with the fuzzy number has been
obtained using Eq. (3.2) as
⎧
⎪
⎪ 0, x < −1
⎨ x+1
,x ∈ [−1, 1]
μã (x) = 2 .
⎪
⎪ 2 − x, x ∈ [1, 2]
⎩
0, x >2
int main()
{
float a,b,c,mem,i;
printf("Enter the value of a, b and c for TFN (a,b,c)\n");
scanf("%f %f %f",&a,&b,&c);
printf("\n The generated TFN in the form of fuzzy set (x,mu(x)) is\n");
for(i=a;i<=c;i=i+0.1)
{
mem=tfnm(a,b,c,i);
printf("(%f,%f)\n",i,mem);
}
getch();
return 0;
}
Using Program 3.1, the output with respect to TFN ã = t f n(−2, 1, 2) has been
obtained.
Input:
Enter the value of a, b and c for TFN (a,b,c)
-2 1 2
3.2 Types of Fuzzy Numbers 57
Output:
The generated TFN in the form of fuzzy set (x,mu(x)) is
(-2.000000,0.000000)
(-1.800000,0.066667)
(-1.600000,0.133333)
(-1.400000,0.200000)
(-1.200000,0.266667)
(-1.000000,0.333333)
(-0.800000,0.400000)
(-0.600000,0.466667)
(-0.400000,0.533333)
(-0.200000,0.600000)
(0.000000,0.666667)
(0.200000,0.733333)
(0.400000,0.800000)
(0.600000,0.866667)
(0.800000,0.933333)
(1.000000,1.000000)
(1.200000,0.800000)
(1.400000,0.600000)
(1.600000,0.400000)
(1.800000,0.200000)
return membrsp;
}
int main()
{
float a,b,c,d,mem,i;
printf("Enter the value of a, b, c and d for TrFN (a,b,c,d)\n");
scanf("%f %f %f %f",&a,&b,&c,&d);
printf("\n The generated TFN in the form of fuzzy set (x,mu(x)) is\n");
for(i=a;i<=d;i=i+0.5)
{
mem=trfnm(a,b,c,d,i);
printf("(%f,%f)\n",i,mem);
}
getch();
return 0;
}
Input:
Enter the value of a, b, c and d for TrFN (a,b,c,d)
-1 2 4 6
Output:
The generated TFN in the form of fuzzy set (x,mu(x)) is
(-1.000000,0.000000)
(-0.500000,0.166667)
(0.000000,0.333333)
(0.500000,0.500000)
(1.000000,0.666667)
(1.500000,0.833333)
(2.000000,1.000000)
(2.500000,1.000000)
(3.000000,1.000000)
(3.500000,1.000000)
(4.000000,1.000000)
(4.500000,0.750000)
(5.000000,0.500000)
(5.500000,0.250000)
(6.000000,0.000000)
Example 3.3 Find the membership function associated with GFN ã = g f n(2, 1, 3).
return membrsp;
}
int main()
{
float a,sigma1,sigma2,mem,i;
printf("Enter the value of a, sigma1 and sigma2 for GFN
(a,sigma1,sigma2)\n");
scanf("%f %f %f",&a,&sigma1,&sigma2);
if(sigma1>0 && sigma2>0)
printf("The GFN is (%f,%f,%f)\n",a,sigma1,sigma2);
else
{
printf("Error!\n");
printf("Enter positive values of sigma1 and sigma2\n");
scanf("%f %f",&sigma1,&sigma2);
}
printf("\n The generated GFN in the form of fuzzy set (x,mu(x)) is\n");
for(i=(a-sigma1);i<=(a+sigma2);i=i+0.5)
{
mem=gfnm(a,sigma1,sigma2,i);
printf("(%f,%f)\n",i,mem);
}
getch();
return 0;
}
3.2 Types of Fuzzy Numbers 63
Using Program 3.3, the output associated with GFN ã = g f n(−2, 1, 3) has been
obtained.
Input:
Enter the value of a, sigma1 and sigma2 for GFN (a,sigma1,sigma2)
-2 -1 3
Error!
Enter positive values of sigma1 and sigma2
13
Output:
The generated GFN in the form of fuzzy set (x,mu(x)) is
(-3.000000,0.606531)
(-2.500000,0.882497)
(-2.000000,1.000000)
(-1.500000,1.000000)
(-1.000000,1.000000)
(-0.500000,1.000000)
(0.000000,1.000000)
(0.500000,1.000000)
(1.000000,1.000000)
Further, the window corresponding to the above output is given in Fig. 3.8.
Here, the output obtained using Program 3.3 as given in Fig. 3.8 may be verified
as the GFN depicted in Fig. 3.9.
Let us now incorporate a MATLAB program for construction of the fuzzy num-
bers, viz., TFN, TrFN, and GFN in Program 3.4.
64 3 Fuzzy Numbers
Fig. 3.9 Output of fuzzy numbers ã = t f n(−2, 1, 2), ã = tr f n(−1, 2, 4, 6), and ã =
g f n(−2, 1, 3)
Program 3.4: Write a MATLAB program to generate user-defined TFN, TrFN, and
GFN
Using the MATLAB codes given in Program 3.4, one may generate TFN ã =
t f n(−2, 1, 2), TrFN ã = tr f n(−1, 2, 4, 6) and GFN ã = g f n(−2, 1, 3). Further,
the MATLAB plot obtained using Program 3.4 has been depicted in Fig. 3.9.
3.2 Types of Fuzzy Numbers 65
Input:
Enter the value of a,b and c for TFN (a,b,c)
[-2 1 2]
Enter the value of a, b, c and d for TrFN (a,b,c,d)
[-1 2 4 6]
Enter the value of a, sigma1 and sigma2 for GFN (a,sigma1,sigma2)
[-2 1 3]
Using α-cut form given in Eq. (3.5), the fuzzy numbers may be written in terms of
fuzzy intervals as aα = [a(α), ā(α)]. In this regard, fuzzy intervals corresponding to
the fuzzy numbers discussed in Sects. 3.3.1 to 3.3.3 have been obtained in successive
sections.
A TFN Ã = (a, b, c) may be converted to its fuzzy interval form using α-cut for
α ∈ [0, 1] by substituting
x −a c−x
= α and = α. (3.6)
b−a c−b
⇒ x = α(b − a) + a and x = c − α(c − b). (3.7)
decompositions for TrFN and GFN have been incorporated in Sects. 3.3.2 and 3.3.3,
respectively.
x−a
by substituting b−a = α and d−x
d−c
= α in Eq. (3.3), where α ∈ [0, 1]. Again, it may
be observed from Eq. (3.9) that TrFN takes the interval form [a, d] and crisp interval
[b, c] for α = 0 and α = 1, respectively.
In case of GFN ã = (a, σ1 , σ2 ), the fuzzy interval form using α-cut is obtained as
ã = aα = [a(α), a(α)] = [a − σ1 −2 log r , a + σ1 −2 log r ], (3.10)
2 2
− (x−a) − (x−a)
∀α ∈ [0, 1] by substituting e = α and e = α in Eq. (3.4).
2σ1 2 2
2σ2
Equations (3.8)–(3.10) take the interval form with respect to α parameter. As such,
the classical interval arithmetic discussed in Sects. 1.1.1–1.1.3 (Chap. 1) has been
extended for fuzzy intervals in the next section.
Fuzzy arithmetic comprises arithmetic operations for fuzzy sets defined over univer-
sal set . A detailed introduction of fuzzy arithmetic and its applications in various
engineering problems have been discussed in Hanss (2005). Fuzzy arithmetic and its
application may also be found in books (Klir and Yuan 1995; Lee 2006).
The fuzzy interval arithmetic similar to operations of intervals for two fuzzy numbers
ã = [a(α)] and b̃ = [b(α)] for α ∈ [0, 1] may be written as
3.4 Fuzzy Arithmetic 67
Example 3.4 Compute the addition, subtraction, multiplication, and division of two
fuzzy numbers ã = t f n(1, 2, 3) and b̃ = tr f n(4, 5, 6, 7).
Solution: Using Eqs. (3.8) and (3.9), the fuzzy intervals with respect to α-cut decom-
position are obtained as
%alpha-cut decomposition
i=1;
for alpha=0:0.1:1
%TFN decomposition
ytfi= [tfn(1)+alpha*(tfn(2)-tfn(1)), tfn(3)-alpha*(tfn(3)-tfn(2))];
%TrFN decomposition
ytrfi= [trfn(1)+alpha*(trfn(2)-trfn(1)), trfn(4)-alpha*(trfn(4)-trfn(3))];
%Addition
add(i,:)=[ytfi(1)+ytrfi(1), ytfi(2)+ytrfi(2)];
%Subtraction
sub(i,:)=[ytfi(1)-ytrfi(2), ytfi(2)-ytrfi(1)];
%Multiplication
S=[ytfi(1)*ytrfi(1), ytfi(2)*ytrfi(2),ytfi(1)*ytrfi(2), ytfi(2)*ytrfi(1)];
mul(i,:)=[min(S),max(S)];
%Division
if((trfn(1)+alpha*(trfn(3)-trfn(2))<0) && trfn(4)-alpha*(trfn(4)-
trfn(3))>=0)
disp('(-inf,inf)');
else
div(i,:)=[ytfi(1)/ytrfi(2),ytfi(2)/ytrfi(1)];
end
mu(i)=alpha;
i=i+1;
end
plot(add,mu,'-r*','Linewidth',2);
hold on
plot(sub,mu,'-ko','Linewidth',2);
plot(mul,mu,'-bs','Linewidth',2);
plot(div,mu,'-gd','Linewidth',2);
xlabel('x');
ylabel('\mu(x)');
set(gca, 'Fontsize', 10);
Using Program 3.5, one may obtain the arithmetic operations on two fuzzy num-
bers ã = t f n(2, 3, 4) and ã = tr f n(1, 2, 3, 4).
Input:
Enter the value of a,b and c for TFN (a,b,c)
[2,3,4]
Enter the value of a, b, c and d for TrFN (a,b,c,d)
[1,2,3,4]
The equivalent MATLAB plot corresponding to the input has been depicted in
Fig. 3.10.
3.4 Fuzzy Arithmetic 69
Lastly, for self-evaluation of the readers, few unsolved problems have been
included.
Exercise:
1. Write a C program to compute arithmetic operations on fuzzy numbers ã =
t f n(2, 3, 4) and ã = tr f n(1, 2, 3, 4).
2. Compute the value of t f n(1, 2, 3) + tr f n(3, 6, 8)) × g f n(−4, 2, 1) using
C/MATLAB programs.
References
S. Abbasbandy, B. Asady, Newton’s method for solving fuzzy nonlinear equations. Appl. Math.
Comput. 159(2), 349–356 (2004)
S. Chakraverty, S. Perera (eds.), Recent Advances in Applications of Computational and Fuzzy
Mathematics (Springer, 2018)
S. Chakraverty, S. Tapaswini, D. Behera, Fuzzy Differential Equations and Applications for Engi-
neers and Scientists, (CRC Press, 2016)
M. Hanss, Applied Fuzzy Arithmetic (Springer-Verlag, Berlin Heidelberg, 2005)
G. Klir, B. Yuan, Fuzzy Sets and Fuzzy Logic, vol. 4, (Prentice Hall, London, New Jersey, 1995)
K.H. Lee, First Course on Fuzzy Theory and Applications (Springer Science and Business Media,
New York, 2006)
Chapter 4
Fuzzy Relations
In Chap. 2, definitions and preliminaries related to crisp sets have been extended in
terms of membership function for fuzzy sets. As such, the concept of crisp relations
may also be extended to fuzzy relations. In this chapter, basically we will discuss
the preliminaries related to fuzzy relations, operations, and compositions on fuzzy
relations.
Crisp (classical) relation represents the connection between elements of two or more
sets. The crisp relation states whether the elements of different sets are related or
not with respect to each other. But, sometimes the strength of the relation between
the elements may be necessary for illustrating the dependency of the elements with
other elements. Definition of relation may be generalized to fuzzy relation where the
strength of dependency is expressed in terms of membership function.
Generally, a crisp relation R between two sets A and B is a subset of Cartesian
product. The strength between the elements in case of crisp relation may be defined
as
1, (x, y) ∈ X × Y
χ R (x, y) = .
0, (x, y) ∈
/ X ×Y
As such, a fuzzy relation R̃for two fuzzy sets à and B̃ is considered as an ordered
pair R̃ = (x, y), μ R (x, y) (x, y) ∈ X × Y , which may be referred as a subset
of Cartesian product of the two universal sets X̃ × Ỹ along with a degree of strength
or dependence of elements. In fuzzy relation, the strength of the relation is expressed
using relational membership function μ R̃ . A relational membership function is a map-
ping from μ R̃ : X × Y → [0, 1]. Similarly, the operations discussed in Chap. 2, viz.,
intersection, union, and complement of fuzzy set may be extended for fuzzy relations.
In this section, a numerical example for computing intersection, union, and comple-
ment of fuzzy relations has been illustrated based on Eqs. (4.1)–(4.3). Further, C and
MATLAB programs have been included to validate the results through the program.
Example 4.1 Consider two fuzzy relations R̃ and S̃ as given in Tables 4.1 and 4.2.
Compute the intersection and union of the two fuzzy relations.
Solution: Using Eqs. (4.1) and (4.2), the intersection and union of the two fuzzy
relations are obtained as
R̃ ∩ S̃ = (x, y), μ R̃∩ S̃ (x, y) and R̃ ∪ S̃ = (x, y), μ R̃∪ S̃ (x, y)
Program 4.1: Write a C program for computing intersection, union, and comple-
ment of two given fuzzy relations.
{
for(j=1;j<=n;j++)
{
printf("%10f",Tu[i][j]);
}
printf("\n");
}
//Complement
printf("\nThe complement of fuzzy relational matrix R is:\n");
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
Rc[i][j]=1-R[i][j];
}
}
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
printf("%10f",Rc[i][j]);
}
printf("\n");
}
getch();
return 0;
}
Then, Program 4.1 has been used to compute the intersection, union, and com-
plement of two fuzzy relations given in Example 4.1.
Input:
Enter the number of elements in fuzzy set A:
3
Enter the number of elements in fuzzy set B:
4
Enter the fuzzy relational (3x4) matrix R:
0.8 1 0.1 0.7
0 0.8 0 0
0.9 1 0.7 0.8
Enter the fuzzy relational (3x4) matrix S:
0.4 0 0.9 0.6
0.9 0.4 0.5 0.7
0.3 0 0.8 0.5
76 4 Fuzzy Relations
Output:
The intersection of fuzzy relational matrices R and S is:
0.400000 0.000000 0.100000 0.600000
0.000000 0.400000 0.000000 0.000000
0.300000 0.000000 0.700000 0.500000
Program 4.2: Compute intersection, union, and complement of two given fuzzy
relations using MATLAB.
The intersection, union, and complement of two fuzzy relations given in Example
4.1 have been obtained using the MATLAB codes mentioned in Program 4.2.
Input:
Enter the fuzzy relation matrix R associated with fuzzy sets A and B:
[0.8 1 0.1 0.7;0 0.8 0 0;0.9 1 0.7 0.8]
Enter the fuzzy relation matrix S associated with fuzzy sets A and B:
[0.4 0 0.9 0.6;0.9 0.4 0.5 0.7;0.3 0 0.8 0.5]
Output:
The intersection of fuzzy relation matrices R and S is:
0.4000 0 0.1000 0.6000
0 0.4000 0 0
0.3000 0 0.7000 0.5000
The union of fuzzy relation matrices R and S is:
0.8000 1.0000 0.9000 0.7000
0.9000 0.8000 0.5000 0.7000
0.9000 1.0000 0.8000 0.8000
The next section discusses the projection of fuzzy relation R̃ in terms of first,
second, and total projections.
For a fuzzy relation R̃ ⊂ X̃ × Ỹ of two sets, the projection has been classified in
terms of first, second, and total projections as
First projection:
PR̃ (1) (x, y) = (x, y), μ R̃ (1) (x, y) μ R̃ (1) (x, y) = max μ R̃ (x, y) . (4.5)
y
Second projection:
PR̃ (2) (x, y) = (x, y), μ R̃ (2) (x, y) μ R̃ (2) (x, y) = max μ R̃ (x, y) . (4.6)
x
Total projection:
PR̃ (T ) (x, y) = (x, y), μ R̃ (T ) (x, y) μ R̃ (T ) (x, y) = max max μ R̃ (x, y) .
x y
(4.7)
Now, consider an example for computing the first, second, and total projections
of a given fuzzy relation based on Eqs. (4.5)–(4.7).
Example 4.2 Consider a relation R̃ = (x, y), μ R̄ (x, y) (x, y) ∈ X × Y of two
fuzzy sets à and B̃ having relational membership function as given in Table 4.6.
Solution: The membership functions for first μ R̃ (1) (x, y), second μ R̃ (2) (x, y) and
total μ R̃ (T ) (x, y) projections have been obtained and incorporated in Table 4.7.
Example 4.2 is implemented using C and MATLAB codes in Programs 4.3 and
4.4, respectively.
Program 4.3: Compute the first, second, and total projections for a given relation
of two fuzzy sets using C program.
mx3=u[i][n+1];
}
for(j=1;j<=n;j++)
{
mx2=u[1][j];
for(i=2;i<=m;i++)
{
if(u[i][j]>mx2)
mx2=u[i][j];
}
u[m+1][j]=mx2;
}
mx4=u[m+1][1];
for(j=2;j<=n;j++)
{
if(u[m+1][j]>mx4)
mx4=u[m+1][j];
}
if(mx3>mx4)
u[m+1][n+1]=mx3;
else
u[m+1][n+1]=mx4;
printf("\nThe first (mu(1)), second (mu(2)) and total (mu(T)) projections of
fuzzy relational matrix R are:\n");
for(j=1;j<=(n+1);j++)
{
if(j==(n+1))
printf("mu(1)");
else
printf("y%d",j);
}
for(i=1;i<=m+1;i++)
{
if(i==(m+1))
printf("\nmu(2)");
else
printf("\nx%d",i);
for(j=1;j<=(n+1);j++)
printf("\t%f",u[i][j]);
}
printf("\n");
getch();
return 0;
}
Using Program 4.3, the projection of fuzzy relation given in Example 4.2 is
obtained.
4.3 First, Second, and Total Projection 81
Input:
Enter the number of elements in fuzzy set A:
3
Enter the number of elements in fuzzy set B:
6
Enter the entries in fuzzy relational (3x6) matrix R:
0.1 0.2 0.4 0.8 1 0.8
0.2 0.4 0.8 0.9 0.8 0.6
0.4 0.8 0.4 0.8 0.4 0.2
Output:
The first (mu(1)), second (mu(2)) and total (mu(T)) projections of fuzzy relational
matrix R are:
y1 y2 y3 y4 y5 y6 mu(1)
x1 0.100000 0.200000 0.400000 0.800000 1.000000 0.800000 1.000000
x2 0.200000 0.400000 0.800000 0.900000 0.800000 0.600000 0.900000
x3 0.400000 0.800000 0.400000 0.800000 0.400000 0.200000 0.800000
mu(2) 0.400000 0.800000 0.800000 0.900000 1.000000 0.800000 1.000000
Then, the output window obtained after executing Program 4.3 is depicted in
Fig. 4.2.
Program 4.4: Write a MATLAB program for computing first, second, and total
projections of two fuzzy sets.
disp(P1);
temp1 = max(P(:,n+1));
for j=1:n
P(m+1,j) = max(R(:,j));
end
disp('The second projection P2 of fuzzy relation is:');
P2 = P(m+1,:);
disp(P2);
temp2 = max(P(m+1,:));
disp('The total projection PT of fuzzy relation is:');
PT = max(temp1,temp2);
disp(PT);
P(m+1,n+1) = PT;
disp('The projection matrix P of fuzzy relation R is:');
disp(P);
The first, second, and total projections of the fuzzy sets given in Example 4.2 are
computed using MATLAB codes of Program 4.4.
Input:
Enter the entries in fuzzy relational matrix R:
[0.1 0.2 0.4 0.8 1 0.8;0.2 0.4 0.8 0.9 0.8 0.6;0.4 0.8 0.4 0.8 0.4 0.2]
Output:
The first projection P1 of fuzzy relation is:
1.0000
0.9000
0.8000
The next section presents the fuzzy composition techniques for fuzzy relations.
Example 4.3 Consider fuzzy relations R̃ and S̃ of three fuzzy sets Ã, B̃ and C̃ as
depicted in Fig. 4.3 having relational membership functions μ R̃ and μ S̃ given in
Tables 4.8 and 4.9.
Compute the max-min composition of the fuzzy relations.
Solution: The max-min composition of the fuzzy relations given in Tables 4.8
and 4.9 has been obtained using Eq. (4.8) and incorporated in Table 4.10.
4.4 Composition of Fuzzy Relations 85
For Example 4.3, C and MATLAB programming codes have been then incorpo-
rated in Programs 4.5 and 4.6, respectively.
Program 4.5: Write a C program for computing max-min composition of two given
fuzzy relations.
//Max-min composition
#include<stdio.h>
#include<conio.h>
int main()
{
int m,n,p,i,j,k;
float u1[5][5],u2[5][5],u3[5][5],c[10],max;
printf("Enter the number of elements in fuzzy set A:\n");
scanf("%d",&m);
printf("Enter the number of elements in fuzzy set B:\n");
scanf("%d",&n);
printf("Enter the number of elements in fuzzy set C:\n");
scanf("%d",&p);
printf("Enter the entries in fuzzy relational matrix R associated with fuzzy
sets A and B:\n");
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
scanf("%f",&u1[i][j]);
}
}
printf("Enter the entries in fuzzy relational matrix S associated with fuzzy
sets B and C:\n");
for(i=1;i<=n;i++)
{
for(j=1;j<=p;j++)
{
scanf("%f",&u2[i][j]);
}
}
//Performing max-min composition
for(i=1;i<=m;i++)
86 4 Fuzzy Relations
{
for(j=1;j<=p;j++)
{
for(k=1;k<=n;k++)
{
if(u1[i][k]<u2[k][j])
c[k]=u1[i][k];
else
c[k]=u2[k][j];
}
max=c[1];
for(k=2;k<=n;k++)
{
if(c[k]>max)
max=c[k];
}
u3[i][j]=max;
}
}
printf("\nThe max-min composition of fuzzy relational matrices R and S
is:\n");
for(i=1;i<=m;i++)
{
for(j=1;j<=p;j++)
{
printf("%10f",u3[i][j]);
}
printf("\n");
}
getch();
return 0;
}
Example 4.3 is then verified using Program 4.5 to obtain the max-min composition
of given fuzzy relations.
Input:
Enter the number of elements in fuzzy set A:
3
Enter the number of elements in fuzzy set B:
5
Enter the number of elements in fuzzy set C:
4
4.4 Composition of Fuzzy Relations 87
Enter the entries in fuzzy relational matrix R associated with fuzzy sets A and B:
0.1 0.2 0 1 0.7
0.3 0.5 0 0.2 1
0.8 0 1 0.4 0.3
Enter the entries in fuzzy relational matrix S associated with fuzzy sets B and C:
0.9 0 0.3 0.4
0.2 1 0.8 0
0.8 0 0.7 1
0.4 0.2 0.3 0
0 1 0 0.8
Output:
The max-min composition of fuzzy relational matrices R and S is:
0.400000 0.700000 0.300000 0.700000
0.300000 1.000000 0.500000 0.800000
0.800000 0.300000 0.700000 1.000000
The output window for Program 4.5 is further included in Fig. 4.4.
Program 4.6: Compute the max-min composition of two fuzzy relations using
MATLAB.
%Max-min composition
function maxmincomp
m = input('Enter the number of entries in fuzzy set A:\n');
n = input('Enter the number of entries in fuzzy set B:\n');
p = input('Enter the number of entries in fuzzy set C:\n');
% Enter the matrices R and S in matrix form
R = input('Enter the entries in fuzzy relational matrix R associated with fuzzy sets A
and B:\n');
S = input('Enter the entries in fuzzy relational matrix S associated with fuzzy sets B
and C:\n');
%Performing max-min composition
RoS=zeros(m,p);
for i=1:m
for k=1:p
for j=1:n
T(j)=min(R(i,j),S(j,k));
end
RoS(i,k)=max(T);
end
end
disp('The max-min composition of fuzzy relations R and S is:');
disp(RoS);
end
Further, using Program 4.6, the max-min composition of fuzzy relations given in
Example 4.3 is computed.
Input:
>> maxmincomp
Enter the number of entries in fuzzy set A:
3
Enter the number of entries in fuzzy set B:
5
Enter the number of entries in fuzzy set C:
4
Enter the entries in fuzzy relational matrix R associated with fuzzy sets A and B:
[0.1 0.2 0 1 0.7;0.3 0.5 0 0.2 1;0.8 0 1 0.4 0.3]
Enter the entries in fuzzy relational matrix S associated with fuzzy sets B and C:
[0.9 0 0.3 0.4;0.2 1 0.8 0;0.8 0 0.7 1;0.4 0.2 0.3 0;0 1 0 0.8]
Output:
The max-min composition of fuzzy relations R and S is:
0.4000 0.7000 0.3000 0.7000
0.3000 1.0000 0.5000 0.8000
0.8000 0.3000 0.7000 1.0000
4.4 Composition of Fuzzy Relations 89
Program 4.7: Verify whether the given relation is a fuzzy equivalence relation or
not using C program.
if(b<mn)
mn=b;
else
mn=a;
return mn;
}
int main()
{
int i,j,k,n,count,count1,count2;
count=0;
count1=0;
count2=0;
float R[10][10];
printf("Enter the number of elements in fuzzy set A:\n");
scanf("%d",&n);
printf("Enter the relational (%dx%d) matrix R associated with fuzzy set
A:\n",n,n);
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
{
scanf("%f",&R[i][j]);
}
for(i=1;i<=n;i++)
{
if(R[i][i]!=1)
{
count=1;
}
for(j=1;j<=n;j++)
{
if(R[i][j]!=R[j][i])
{
count1=1;
}
for(k=1;k<=n;k++)
{
4.5 Fuzzy Equivalence Relation 91
if(min(R[i][j],R[j][k])>R[i][k])
count2=1;
}
}
}
if(count==0)
printf("\nThe relation is a reflexive relation\n");
else
printf("\nThe relation is not a reflexive relation\n");
if (count1==0)
printf("\nThe relation is a symmetric relation\n");
else
printf("\nThe relation is not a symmetric relation\n");
if (count2==0)
printf("\nThe relation is a transitive relation\n");
else
printf("\nThe relation is not a transitive relation\n");
//Checking tolerance or equivalence relation
if(count==0&&count1==0&&count2==0)
printf("\nThe relation is tolerance and equivalence relation\n");
if(count==0&&count1==0&&count2!=0)
printf("\nThe relation is a tolerance relation but not an equivalence
relation\n");
getch();
return 0;
}
Using Program 4.7, Example 4.4 is then verified for fuzzy equivalence relation.
Input:
Enter the number of elements in fuzzy set A:
5
Enter the relational (5x5) matrix R associated with fuzzy set A:
1 0.8 0 0.1 0.2
0.8 1 0.4 0 0.9
0 0.4 1 0 0
0.1 0 0 1 0.5
0.2 0.9 0 0.5 1
Output:
The relation is a reflexive relation
The relation is a symmetric relation
The relation is not a transitive relation
The relation is a tolerance relation but not an equivalence relation
Program 4.8: Write a MATLAB function for verifying fuzzy equivalence relation.
else
disp('The relation is not a symmetric relation');
end
if (count2==0)
disp('The relation is a transitive relation');
else
disp('The relation is not a transitive relation');
end
%Checking tolerance or equivalence relation
if(count==0&&count1==0&&count2==0)
disp('The relation is a tolerance and equivalence relation');
end
if(count==0&&count1==0&&count2~=0)
disp('The relation is a tolerance relation but not an equivalence relation');
end
end
Program 4.8 is then executed to verify whether the fuzzy relation given in Example
4.4 is a fuzzy equivalence relation.
Input:
>> equivalence
Enter the number of entries in fuzzy set A:
5
Enter the relational matrix R for the entries of A:
[1 0.8 0 0.1 0.2;0.8 1 0.4 0 0.9;0 0.4 1 0 0;0.1 0 0 1 0.5;0.2 0.9 0 0.5 1]
Output:
The relation is a reflexive relation
The relation is a symmetric relation
The relation is not a transitive relation
The relation is a tolerance relation but not an equivalence relation
Few unsolved questions have also been provided next for self-evaluation. More-
over, readers are encouraged to refer the books viz. Dubois and Prade (1980), Zim-
merman (2001), Lee (2006) and, Klir and Yuan (2008) for further knowledge of
fuzzy relations.
Exercise
1. Generate two relations for given fuzzy sets and compute the union, intersection,
and complement of the fuzzy relations using programming.
2. Write a C/MATLAB program for finding the containment of two relations R̃ and
S̃ as given in Example 4.1.
3. Write a MATLAB program to compute different projections (viz., first, second,
third, and total projections) for three fuzzy relations.
94 4 Fuzzy Relations
References
D.J. Dubois, H. Prade, Fuzzy Sets and Systems: Theory and Applications, vol. 144 (Academic Press,
New York, 1980), pp. 68–94
G.J. Klir, B. Yuan, Fuzzy Sets and Fuzzy Logic, Theory and Applications (Prentice Hall, London,
2008)
K.H. Lee, First course on fuzzy theory and applications (Springer, New York, 2006)
H.J. Zimmerman, Fuzzy Set Theory and Its Applications (Springer, New York, 2001)
Chapter 5
Fuzzy Functions
In Chap. 4, the concept of crisp relation was extended to fuzzy relations, and here, the
notion of crisp function has been extended to fuzzy functions. Further, based on the
fuzzy parameters, different types of fuzzy functions are illustrated. In particular, this
chapter discusses the concept of fuzzy functions based on crisp relations along with
the concepts of single and fuzzy bunch of crisp functions. Moreover, C or MATLAB
codes related to fuzzy functions have also been included in this chapter.
Before proceeding with the notion of fuzzy function, we briefly recapitulate the
concept of crisp function in the next section.
f:X → Y
x → f (x) = y
such that ∃ a unique image of dependent variable y ∈ Y for each independent variable
x ∈ X.
As regards, the propagation of uncertainty in function or in the domain and co-
domain associated with the functions yield the existence of fuzzy functions that have
been discussed in detail in the next section.
f˜ : X̃ → Ỹ
x̃ → f˜(x̃) = ỹ
such that ∃ a unique fuzzified image ỹ ∈ Ỹ for each independent fuzzy variable
x̃ ∈ X̃ . Based on the fuzziness induced in the crisp functions, either in terms of
fuzzy function f˜ or domain X̃ or co-domain Ỹ , the fuzzy functions may be classified
into three types depending on following three cases (Lee 2006):
• Case I: The associated function f is crisp with fuzzy constraint (induced due to
fuzzy domain X̃ and co-domain Ỹ ).
• Case II: The function f is crisp with fuzzy domain X̃ .
• Case III: The function f˜ exhibit fuzziness over a crisp domain X .
The next section illustrates the three different kinds of fuzzy functions based on
the above cases.
Fuzzy function is classified into three types according to the propagation of fuzziness:
• Type I fuzzy function,
• Type II fuzzy function, and
• Type III fuzzy function.
Let us consider two crisp sets X , Y and two fuzzy sets Ã, B̃ with respect to the
universal sets X , Y , respectively, such that
and
Then, a crisp function f : X → Y that takes the fuzzy set à to B̃ having mem-
bership values μ Ã (x) and μ B̃ (y) is referred as type I fuzzy function or crisp function
with fuzzy constraint, if it satisfies the membership relation,
Here, type I fuzzy function propagates the fuzziness of crisp function associated
with a fuzzy constraint from domain X to co-domain Y . Next, we illustrate the
concept of crisp function with fuzzy constraint using an example problem.
Solution: With respect to the fuzzy set à = {(1, 0.2), (2, 0.5), (3, 0.7), (4, 0.3)},
x ∈ X takes the corresponding values from the set A = {1, 2, 3, 4} ⊂ X . Then,
using function f (x) = 2x − 1, the corresponding values in range set are obtained
as B = {1, 3, 5, 7} ⊂ Y . Using Eq. (5.1), we verify that μ Ã (x) ≤ μ B̃ (y) ∀x ∈
{1, 2, 3, 4} and ∀y ∈ {1, 3, 5, 7}. As such, the function f (x) = 2x − 1 is a type I
fuzzy function.
In this regard, a C program has been presented to illustrate the computational
verification of type I fuzzy function in Program 5.1.
Program 5.1: Write a C program for verification of type I fuzzy function.
scanf("%d",&n);
printf("Enter the set B for the fuzzy domain Bf=(y,mu(y)) where y is
contained in B\n");
for(i=1;i<=n;i++)
scanf("%f",&b[i]);
printf("Enter the membership values mu(y) for the fuzzy domain
Bf=(y,mu(y))\n");
for(i=1;i<=n;i++)
scanf("%f",&mub[i]);
for(i=1;i<n;i++)
{
for(j=1;j<n;j++)
{
if((b[i]/2)==a[j])
{
if(mua[i]>mub[i])
{
c++;
}
}
}
}
if(c>0)
printf("The given function is not a type-I fuzzy function\n");
else
printf("The given function is a type-I fuzzy function\n");
getch();
return 0;
}
Using Program 5.1, the output with respect to Example 5.1 is obtained.
Input:
Enter the number of elements in the fuzzy domain Af
4
Enter the set A for the fuzzy domain Af=(x,mu(x)) where x is contained in A
1234
Enter the membership values mu(x) for the fuzzy domain Af=(x,mu(x))
0.2 0.5 0.7 0.3
Enter the number of elements in the fuzzy co-domain Bf
4
Enter the set B for the fuzzy domain Bf=(y,mu(y)) where y is contained in B
1357
Enter the membership values mu(y) for the fuzzy domain Bf=(y,mu(y))
0.5 0.7 0.9 1
Output:
The given function is a type-I fuzzy function
5.3 Types of Fuzzy Function 99
Further, the output window corresponding to the abovementioned output has been
depicted in Fig. 5.1.
Then, we have discussed the type II fuzzy function in the next section.
Crisp function that propagates independent fuzzy variables to dependent fuzzy vari-
ables are referred as type II fuzzy function.
Let X , Y be two crisp sets and f : X → Y be the crisp function. Then, the fuzziness
of independent variables x̃ ∈ Ã is propagated to dependent variables y ∈ B using the
extension principle (discussed in Chap. 2) for the membership function as follows:
⎧
⎨ sup μx̃ (x), f −1 (y) = φ
μ B̃ (y) = x∈ f −1 (y) (5.2)
⎩ 0, f −1 (y) = φ.
Now, for the better understanding of type II fuzzy set, Example 5.2 has been
considered.
A = {−1, 0, 1, 2, 3}
and the crisp range set B ⊂ Y with respect to crisp constraint f (x) = 5x 2 − 1 is
Using Eq. (5.2), the propagated fuzzy set with respect to fuzzy domain à =
{(−1, 0.3), (0, 0.8), (1, 0.5), (2, 0.9), (3, 0.4)} is obtained as illustrated below.
So, the fuzzy range set B̃ is obtained as {(−1, 0.8), (4, 0.5), (19, 0.9), (44, 0.4)}.
We have included MATLAB program to illustrate the computational usage of type
II fuzzy sets to obtain the propagated fuzzy set with respect to crisp function and
fuzzy domain in Programs 5.2.
Program 5.2: Write MATLAB function “type II” that computes fuzzy set B̃ due to
the propagation of fuzzy set à using a user input crisp function.
Then, the output corresponding to Example 5.2 is obtained using Program 5.2 as
mentioned in the command window.
5.3 Types of Fuzzy Function 101
Input:
>> typeII
Enter the number of elements in fuzzy set Af
5
Enter n elements in A
[–1, 0, 1, 2, 3]
Enter n membership values of x
[0.3, 0.8, 0.5, 0.9, 0.4]
Output:
Enter the number of elements in fuzzy set Af
5
Enter n elements in A
[–1 0 1 2 3]
Enter n membership values of x
[0.3 0.8 0.5 0.9 0.4]
The fuzzy set Bf using extension principle is:
–1.0000 0.8000
4.0000 0.5000
19.0000 0.9000
44.0000 0.4000
The next section illustrates the third type of fuzzy function that consists of a fuzzy
function defined over a crisp domain.
The type III fuzzy function comprises a fuzzy function from crisp domain to co-
domain. As such, the fuzziness of the fuzzy function is propagated resulting in fuzzy
range set. Depending on the fuzzy function, there exist two classifications of type III
fuzzy function:
1. Single fuzzy function and
2. Fuzzy bunch of functions.
102 5 Fuzzy Functions
Here, f˜ is the fuzzifying function over crisp domain X that propagates the fuzzi-
ness to the co-domain resulting in fuzzy co-domain P̃(Y ). To illustrate the fuzzy
propagation in Type III fuzzy function, we have considered an example problem in
Example 5.3.
where B1 = {2, 4, 6}, B2 = {3, 5, 7}, B3 = {3, 6, 9, 12} and B4 = {4, 8, 12, 16}.
So, the associated fuzzifying function f˜ maps the crisp elements in A ⊂ X to the
power set P̃(B) ⊂ P̃(Y ). Accordingly, we may interpret,
f˜ = {( f i , μ f˜ ( f i ))| f i : X → Y } (5.4)
fi : X → Y
5.3 Types of Fuzzy Function 103
Solution: The fuzzy functions f˜i corresponding to crisp functions f i are obtained
for:
• f1 : f˜1 = {(−1, 0.2), (1, 0.2), (2, 0.2), (4, 0.2), (5, 0.2)},
• f2 : f˜2 = {(6, 0.1), (2, 0.1), (3, 0.1), (11, 0.1), (18, 0.1)},
• f3 : f˜3 = {(−16, 0.4), (0, 0.4), (2, 0.4), (54, 0.4), (128, 0.4)}, and
• f4 : f˜4 = {(−3, 1), (1, 1), (0, 1), (2, 1), (3, 1)}.
As such, the fuzzy images of the set {−2, 0, 1, 3, 4} corresponding to fuzzy func-
tions are
f˜(−2) = {(−1, 0.2), (6, 0.1), (−16, 0.4), (−3, 1)} = {(−16, 0.4), (−3, 1), (−1, 0.2), (6, 0.1)},
f˜(0) = {(1, 0.2), (2, 0.1), (0, 0.4), (1, 1)} = {(0, 0.4), (2, 0.1), (1, 1)},
f˜(1) = {(2, 0.2), (3, 0.1), (2, 0.4), (0, 1)} = {(0, 1), (2, 0.4), (3, 0.1)},
f˜(3) = {(4, 0.2), (11, 0.1), (54, 0.4), (2, 1)} = {(2, 1), (4, 0.2), (11, 0.1), (54, 0.4)}
and f˜(4) = {(5, 0.2), (18, 0.1), (128, 0.4), (3, 1)} = {(3, 1), (5, 0.2), (18, 0.1), (128, 0.4)}.
A similar approach may be applied for fuzzy bunch of continuous functions. Inter-
ested readers may refer Lee (2006) in this regard. Further, the readers are encouraged
to refer the books viz. Dubois and Prade (1980), Zimmerman (2001), and George
and Yuan (2008). Lastly, we have considered few problems for self-validation of the
readers.
Exercise:
1. Write a MATLAB program for the verification of type I fuzzy function.
2. Compute fuzzy set due to propagation of fuzzy set à =
{(−1, 0.3), (0, 0.8), (1, 0.5), (2, 0.9), (3, 0.4)} and crisp function
y = f (x) = 5x 2 − 1
using C programming.
3. Compute the fuzzy bunch of functions,
References
D.J. Dubois, H. Prade, Fuzzy Sets and Systems: Theory and Applications, vol. 144 (Academic Press,
New York, 1980), pp. 68–94
J.K. George, Y. Bo, Fuzzy Sets and Fuzzy Logic, Theory and Applications (Prentice Hall, London,
2008)
K.H. Lee, First Course on Fuzzy Theory and Applications (Springer, New York, 2006)
H.J. Zimmerman, Fuzzy Set Theory and its Applications (Springer, New York, 2001)
Chapter 6
Fuzzy Differentiation and Integration
b
f (x) d x. (6.1)
a
The crisp differentiation has been extended to fuzzy differentiation in this section.
Similar to integration, the fuzzy differentiation
˜ d ˜
f (ã) = f (x) (6.2)
dx x∈ã
In this regard, we discuss the fuzzy differentiation in Sects. 6.1.1 and 6.1.2, respec-
tively.
and the corresponding membership values (Lee 2006) may be obtained using
In this regard, an example problem has been incorporated for the fuzzy differentiation
in Example 6.1.
Further, the fuzzy differentiation in case of fuzzifying function at crisp point has
been implemented using a MATLAB program in Program 6.1.
Input:
>> fuzfuncdiff(2)
Enter the number of elements in fuzzy bunch of functions
3
Enter the associated fuzzy bunch of functions f(x)
[2*x, x^2+1, 3*x-1]
Enter the corresponding membership values
[0.1, 0.4, 0.9]
Output:
The fuzzy differentiation results to fuzzy function (f,mu(f))
[ 2, 0.1000]
[ 3, 0.9000]
[ 4, 0.4000]
108 6 Fuzzy Differentiation and Integration
The differentiation of crisp function at a given fuzzy point has been taken into con-
sideration. Using extension principle, the differentiation f (x) at fuzzy point ã is
defined as
d
f (ã) = f (x) (6.6)
dx x∈ã
f (ã) = {(48, 0.2), (12, 0.6), (0, 1), (12, 0.8), (48, 0.4)}.
Program 6.2: Compute differentiation of a crisp function at fuzzy point using MAT-
LAB program.
for k=1:p
mx = 0;
for i=1:n
if (funcdiff(i) == fk(k))
mx = max(muf(i),mx);
end
end
mufy(k)=mx;
end
disp(double([fk' mufy']));
end
The fuzzy differentiation using Program 6.2 has been computed for Example 6.2.
Input:
>> cfuncdiff
Enter the crisp function
4*x^3
Enter the elements of fuzzy point a
[-2, -1, 0, 1, 2]
Enter the respective membership values
[0.2, 0.6, 1, 0.8, 0.4]
Output:
The fuzzy differentiation results to fuzzy function (f,mu(f))
[ 0, 1.0000]
[ 12, 0.8000]
[ 48, 0.4000]
In the next section, the other fundamental concept of fuzzy calculus has been
discussed, viz., fuzzy integration.
The crisp integration given in Eq. (6.1) comprises mainly two basic constituents,
viz., integrand f (x) and the integration domain [a, b] with limits a and b. Based on
these constituents, the fuzzy integration is classified into two categories:
i. Integration of fuzzifying function f˜(x) over crisp limits a and b, and
ii. Integration of crisp function f (x) over fuzzy limits ã and b̃,
and discussed in Sects. 6.1.1 and 6.1.2, respectively.
110 6 Fuzzy Differentiation and Integration
Then, integration of the fuzzifying function over crisp domain [a, b] is defined as
b
I˜(a, b) = f˜(x) d x. (6.7)
a
b
Ii (a, b) = f i (x) d x. (6.8)
a
4
f 1 (x) d x = 42, (6.11a)
1
6.2 Fuzzy Integration 111
4
f 2 (x) d x = 12, (6.11b)
1
4
f 3 (x) d x = 0.75, (6.11c)
1
and
4
f 4 (x) d x = −17.25. (6.11d)
1
Then, using Program 6.3, the fuzzy integration of fuzzifying function given in
Example 6.3 is computed over crisp domain [1, 4].
Input:
>> fuzfuncint(1,4)
Enter the number of elements in fuzzy bunch of functions
4
Enter the associated crisp function
2*x^2
Enter the corresponding membership value
0.7
Enter the associated crisp function
2*x-1
Enter the corresponding membership value
0.2
Enter the associated crisp function
x^(-2)
Enter the corresponding membership value
0.9
Enter the associated crisp function
x^3-4*x^2+1
Enter the corresponding membership value
1
Output:
The fuzzy integration results to fuzzy function (f,mu(f)):
{(42.000000, 0.700000) (12.000000, 0.200000) (0.750000, 0.900000)
(-17.250000,1.000000)}
The other case of fuzzy integration with respect to integration of crisp function
over fuzzy domain has been considered in next section.
Here, the integrand is a crisp function f (x). Accordingly, the integration of the
function over fuzzy limits is defined as
b̃
I˜(ã, b̃) = f (x) d x (6.12)
ã
6.2 Fuzzy Integration 113
and the corresponding membership values are obtained using (Lee 2006)
b
where z = ai j f (t) dt . The principle of fuzzy integration corresponding to
Eq. (6.12) is illustrated in Example 6.4.
Example 6.4 Consider a crisp function f (x) = 3x − 4 and compute the inte-
gration of f (x) over fuzzy domain with respect to given fuzzy limits ã =
{(2, 0.8), (4, 0.4), (5, 0.6)} and b̃ = {(6, 0.1), (7, 0.5), (8.5, 0.9), (9, 0.4)}.
Solution: Integrate each function f i (x) for i = 1, 2, . . . , 4 over the crisp domain
[1, 4] as given in Table 6.1.
Accordingly, using Eq. (6.13) and Table 6.1, the fuzzy integration is then obtained
as
b̃
f (x) d x = {(12.5, 0.1), (22, 0.1), (28, 0.5), (32, 0.1), (37.5, 0.4),
ã
(47.5, 0.5), (56.875, 0.6), (76.375, 0.8), (87.5)}.
In Example 6.4, if the crisp function is replaced with function f (x) = 3, then we
obtain
b̃
f (x) d x = {(3, 0.1), (6, 0.5), (6, 0.1), (9, 0.4), (10.5, 0.6), (12, 0.4), (12.5, 0.1),
ã
(13.5, 0.4), (15, 0.4), (15, 0.5), (19.5, 0.8), (21, 0.4)}. (6.14)
6 7 6 9
From Eq. (6.14), 4 f (x) d x = 5 f (x) d x = 6, 2 f (x) d x = 5 f (x) d x =
7 9
12, and 2 f (x) d x = 4 f (x) d x = 15. In such cases, where the integral values are
equivalent then, using Eq. (6.13), the corresponding membership value is obtained
as the maximum membership value. Accordingly, Eq. (6.14) results to
b̃
f (x) d x = {(3, 0.1), (6, 0.5), (9, 0.4), (10.5, 0.6), (12, 0.4), (13.5, 0.4),
ã
(15, 0.5), (19.5, 0.8), (21, 0.4)}.
A MATLAB program has been incorporated in Program 6.4 to illustrate the imple-
mentation of fuzzy integration with crisp function over fuzzy limits.
Program 6.4: Write a MATLAB function to compute the fuzzy integration with
crisp function over fuzzy limits.
for j=1:m
if (z(i,j) == zk(k))
mx = max(mu(i,j),mx);
end
end
end
muz(k)=mx;
end
disp('The integral values (z) and the respective membership values (mu(z)) are:');
disp(double([zk, muz']));
end
Using Program 6.4, the integration of crisp function over fuzzy domain has
been obtained for the crisp function f (x) = 3 over fuzzy domain with limits
ã = {(2, 0.8), (4, 0.4), (5, 0.6)} and b̃ = {(6, 0.1), (7, 0.5), (8.5, 0.9), (9, 0.4)}.
Input:
>> cfuncint
Enter the elements of lower fuzzy limit a
[2, 4, 5]
Enter the respective membership values of the elements in lower fuzzy limit
[0.8, 0.4, 0.6]
Enter the elements of upper fuzzy limit b
[6, 7, 8.5, 9]
Enter the respective membership values of the elements in upper fuzzy limit
[0.1, 0.5, 0.9, 0.4]
Enter the crisp function f(x)
3
Output:
The integral values (z) and the respective membership values (mu(z)) are:
3.0000 0.1000
6.0000 0.5000
9.0000 0.4000
10.5000 0.6000
12.0000 0.4000
13.5000 0.4000
15.0000 0.5000
19.5000 0.8000
21.0000 0.4000
Finally, few unsolved problems are included below for self-validation of the read-
ers.
116 6 Fuzzy Differentiation and Integration
Exercise
References
D.J. Dubois, H. Prade, Fuzzy Sets and Systems: Theory and Applications, vol. 144 (Academic Press,
New York, 1980), pp. 68–94
K.H. Lee, First Course on Fuzzy Theory and Applications (Springer, New York, 2006)
H.J. Zimmerman, Fuzzy Set Theory and Its Applications (Springer, New York, 2001)
Chapter 7
Defuzzification
T : X × [0, 1] → X,
where A = (x, µ A(x))µ A(x) ∈ [0, 1], x ∈ X is the fuzzy set and the transformed
crisp set is A. In case of defuzzification of a fuzzy number to corresponding crisp
value, the transformation is considered as
T : × [0, 1] →
ã → T (ã) = x ∗
But there exists no specific approach for the choice of defuzzified crisp value;
instead, the defuzzification method needs to be selected with respect to the system
of the practical problem. Various defuzzification methods exist and may be found in
Zimmermann (2001), Lee (2006) and Sivanandam and Deepa (2012). In this chapter,
we have mainly discussed four types of defuzzification, viz., max-membership, cen-
troid methods, weighted-average, and mean–max methods. Further, MATLAB pro-
grams with respect to the defuzzification methods have also been included in the
present context.
In this regard, the defuzzification methods have been discussed in the next section.
7.1.1 Aggregation
Using Program 7.1, the aggregated fuzzy set with respect to four fuzzy sets is
obtained and the corresponding MATLAB plot is depicted in Fig. 7.3.
Input:
>> aggregate(4)
Enter the fuzzy set 1
Select 1 for triangular or 2 for trapezoidal or 3 for Gaussian fuzzy sets
1
Enter a TFN (a,b,c)
[-7, -5, 1]
Enter membership scaling factor between 0 to 1 for triangular type fuzzy set
0.5
Enter the fuzzy set 2
Select 1 for triangular or 2 for trapezoidal or 3 for Gaussian fuzzy sets
2
Enter a TrFN (a,b,c,d)
[-3, 1, 5, 6]
Enter membership scaling factor between 0 to 1 for trapezoial type fuzzy set
0.9
Enter the fuzzy set 3
Select 1 for triangular or 2 for trapezoidal or 3 for Gaussian fuzzy sets
2
Enter a TrFN (a,b,c,d)
[5, 6, 8, 9]
Enter membership scaling factor between 0 to 1 for trapezoial type fuzzy set
1
Enter the fuzzy set 4
Select 1 for triangular or 2 for trapezoidal or 3 for Gaussian fuzzy sets
3
Enter a GFN (a,b,c)
[-2, 3, 4]
Enter membership scaling factor between 0 to 1 for Gaussian type fuzzy set
0.7
Output:
7.1 Defuzzification Methods 121
The max-membership method gives the defuzzified point as the crisp value x ∗ ∈ X
having maximum membership value ∀x ∈ X . In this regard, the membership or
characteristic value corresponding to defuzzified point x ∗ ∈ X satisfies
Using Eq. (7.2), the GFN attends its maximum membership value 1 at x = 2.
Accordingly, the defuzzified crisp value x ∗ is 2.
In order to make max-membership method effective, we have written a MATLAB
code for computation of defuzzified crisp value in Program 7.2.
%Max-membership defuzzification
function maxmem(n)
%n is the number of fuzzy sets
%mf is the membership function of aggregated fuzzy set
[x,mf] = aggregate(n);
maxm = max(mf);
p = length(mf);
z = 0;
for i = 1:p
if(mf(i) == maxm)
z = x(i);
end
end
disp('The defuzzified crisp value is:');
disp(z);
end
Input:
>> maxmem(2)
Enter the fuzzy set 1
Select 1 for triangular or 2 for trapezoidal or 3 for Gaussian fuzzy sets
3
Enter a GFN (a,b,c)
[-5, 2, 3]
Enter membership scaling factor in interval [0,1] for Gaussian type fuzzy set
0.8
Enter the fuzzy set 2
Select 1 for triangular or 2 for trapezoidal or 3 for Gaussian fuzzy sets
1
Enter a TFN (a,b,c)
[-2, 2, 7]
Enter membership scaling factor in interval [0,1] for triangular type fuzzy set
1
Output:
The defuzzified crisp value is:
2
It may be noted that the integration is the usual algebraic integration. Accordingly,
based on Eq. (7.3), MATLAB code for performing defuzzification using centroid
method has been given in Program 7.3.
%Centroid defuzzification
function fcentroid(n)
%n is the number of fuzzy sets
%mf is the membership function of aggregated fuzzy set
z = 0;
[x,mf] = aggregate(n);
nx = length(x);
z = (sum(mf(1:nx).*x(1:nx))/(sum(mf(1:nx))));
disp('The defuzzified crisp value is:');
disp(z);
end
Input:
>> fcentroid(3)
Enter the fuzzy set 1
Select 1 for triangular or 2 for trapezoidal or 3 for Gaussian fuzzy sets
1
Enter a TFN (a,b,c)
[4, 5, 6]
Enter membership scaling factor in interval [0,1] for triangular type fuzzy set
0.2
Enter the fuzzy set 2
Select 1 for triangular or 2 for trapezoidal or 3 for Gaussian fuzzy sets
2
7.1 Defuzzification Methods 125
Output:
The defuzzified crisp value is:
-2.9882
Here, we have x ∗ ∈ X as
n
i=1 µC ( x̄ i ) · x̄ i
x∗ = n , (7.5)
i=1 µC ( x̄ i )
where x̄i is the centroid of maximum for each ith membership function of the aggre-
gated fuzzy set.
n
Further, i=1 represents the algebraic sum with respect to membership functions
of n fuzzy sets. The method seems appealing but has a limitation that it may be
applicable only in case of fuzzy sets having symmetric membership functions.
a+b
x∗ = . (7.5)
2
MATLAB command to obtain the defuzzification point using mean–max method
is “z = defuzz(x,mf,‘mom’)”, where “mf” is the aggregated membership function
corresponding to “x”.
There exist various other defuzzification methods. Readers may refer defuzzi-
fication commands in MATLAB for the other defuzzification techniques based on
bisector, middle, smallest, and largest of maximum methods.
Exercise
1. Define MATLAB function “wedavg” to compute defuzzification of fuzzy set
using weighted-average method.
References
H. Hellendoorn, C. Thomas, Defuzzification in fuzzy controllers. J. Intell. Fuzzy Syst. 1(2), 109–123
(1993)
G.J. Klir, B. Yuan, Fuzzy Sets and Fuzzy Logic, Theory and Applications (Prentice Hall, London,
2008)
K.H. Lee, First Course on Fuzzy Theory and Applications (Springer, New York, 2006)
S.N. Sivanandam, S.N. Deepa, Principles of Soft Computing (Wiley India Pvt. Ltd., New Delhi,
2012)
H.J. Zimmermann, Fuzzy control, in Fuzzy Set Theory—And Its Applications (Springer, Dordrecht,
1996), pp. 203–240
H.J. Zimmermann, Fuzzy Set Theory and Its Applications (Springer, New York, 2001)
Chapter 8
Interval System of Linear Equations
Ax = b, (8.1)
where A is the linear relation coefficient matrix having dimension m × n, b is the right-
hand side vector having m elements, and x is the solution vector having n variables.
But due to insufficiency and incompleteness of data, the parameters in such system
of equations may be uncertain which leads to uncertain system of linear equations.
According to Chaps. 1 and 3, the uncertainty may be handled using interval analysis
and fuzzy set approaches.
Note: Any fuzzy system of linear equations may be converted into appropriate ISLEs
since a fuzzy number is approximately represented by a set of closed intervals using
α-cut.
where [A] is the linear interval coefficient matrix having dimension m × n, [b] is the
interval vector of size m, and [x] is the corresponding solution vector consisting of n
variables. Further, Eq. (8.2) may be written as
n
[ai j ] = [bi ].
j=1
8.2.1.1 Method I
If the elements of coefficient interval matrix [A] in Eq. (8.5) are positive, that is,
∀a i j , āi j ∈ + for i, j = 1, 2, . . . , n, and then Eq. (8.5) may be further written as
a 11 x 1 + a 12 x 2 + . . . + a 1n x n = b1
a 21 x 1 + a 22 x 2 + . . . + a 2n x n = b2
.. , (8.6a)
.
a n1 x 1 + a n2 x 11 + . . . + a nn x 11 = bn
ā11 x̄ 1 + ā12 x̄ 2 + . . . + ā1n x̄ n = b̄1
ā21 x̄ 1 + ā22 x̄ 2 + . . . + ā2n x̄ n = b̄2
.. . (8.6b)
.
ān1 x̄ 1 + ān2 x̄ 2 + . . . + ānn x̄ n = b̄n
Accordingly, it may be noted that the ISLE in Eq. (8.3) gets converted to crisp
system of linear equations having double dimension. For instance, in case of a 2 ×
2 ISLE, Eq. (8.7) gets reduced to 4 × 4 crisp system of linear equation as
⎛ ⎞⎧ ⎫ ⎧ ⎫
a 11 a 12 0 0 ⎪ ⎪ x ⎪ ⎪ b ⎪
⎜a ⎨ 1⎪ ⎬ ⎪⎨ 1⎪ ⎬
⎜ 21 a 22 0 0 ⎟⎟ x b
⎝ 0
2 = 2 . (8.8)
0 ā11 ā12 ⎠⎪
⎪ x̄ ⎪ ⎪ b̄ ⎪
⎩ 1⎪ ⎭ ⎪⎩ 1⎪ ⎭
0 0 ā21 ā22 x̄2 b̄2
a 22 b1 − a 12 b2
x1 = , (8.9a)
a 11 a 22 − a 12 a 21
ā22 b̄1 − ā12 b̄2
x̄1 = , (8.9b)
ā11 ā22 − ā12 ā21
a b − a 21 b1
x 2 = 11 2 , (8.9c)
a 11 a 22 − a 12 a 21
ā11 b̄2 − a 21 b̄1
x2 = . (8.9d)
ā11 ā22 − ā12 ā21
Solution: Using Eqs. (8.8), (8.10) gets converted to crisp system of linear equations.
8.2 Interval System of Equations 133
⎛ ⎞⎧ ⎫ ⎧ ⎫
4 5 0 0 ⎪ ⎪ x ⎪ ⎪ 40 ⎪
⎜6 ⎨ 1⎪ ⎬ ⎪⎨ ⎪ ⎬
⎜ 4 0 0⎟⎟ x 43
⎝0
2 = .
0 6 8 ⎠⎪⎪ x̄ ⎪ ⎪ 67 ⎪
⎩ 1⎪ ⎭ ⎪⎩ ⎪ ⎭
0 0 7 5 x̄2 55
Accordingly, using Eqs. (8.9a, 8.9b, 8.9c, and 8.9d), the bounds of solution vector
are obtained as [x1 ] = [3.9286, 4.0385] and [x2 ] = [4.8571, 5.3462].
Program 8.1: MATLAB program for solving interval system of linear equations
using Eq. (8.8).
Input:
Enter the dimension of coefficient matrix A
2
Enter the lower bound of each element of interval aij:
[4 5; 6 4]
Enter the upper bound of each element of interval aij:
[6 8;7 5]
Enter the lower bounds of interval vector b:
[40;43]
Enter the upper bounds of interval vector b:
[67;55]
134 8 Interval System of Linear Equations
Output:
The crisp coefficient matrix is
A= 4 5 0 0
6 4 0 0
0 0 6 8
0 0 7 5
The crisp right-hand side vector is
b = 40
43
67
55
x= 3.9286
4.8571
4.0385
5.3462
8.2.1.2 Method II
Equation (8.8) may further be written in terms of lower and upper bounds, systems
of linear equations as given below:
a 11 a 12 x1 b1
,= (8.11a)
a 21 a 22 x2 b2
ā11 ā12 x̄1 b̄1
= . (8.11b)
ā21 ā22 x̄2 b̄2
a 22 b1 − a 12 b2
x1 = ,
a 11 a 22 − a 12 a 21
ā22 b̄1 − ā12 b̄2
x̄1 = ,
ā11 ā22 − ā12 ā21
a b − a 21 b1
x 2 = 11 2 ,
a 11 a 22 − a 12 a 21
ā11 b̄2 − ā21 b̄1
x̄2 = ,
ā11 ā22 − ā12 ā21
Program 8.2: A MATLAB program for solving interval system of linear equations
using Eqs. (8.11a, 8.11b).
Input:
Enter the dimension of coefficient matrix A
2
Enter the lower bound of each element of interval aij:
[4 5; 6 4]
Enter the lower bound of each element of interval aij:
[6 8;7 5]
Enter the upper bounds of interval vector b:
[40;43]
Enter the upper bounds of interval vector b:
[67;55]
Output:
The lower and upper bounds of solution vector x
xl = 3.9286
4.8571
xu = 4.0385
5.3462
If the elements of coefficient interval matrix [A] are either positive or negative, that
is, ∀a i j , āi j ∈ + or a i j , āi j ∈ − for i, j = 1, 2, . . . , n.
136 8 Interval System of Linear Equations
Fig. 8.1 A three-stepped bar with force applied at the free end
8.2 Interval System of Equations 137
Solution: Using finite element method for the three-stepped bar under static con-
dition yields the interval system of equation as given in (Behera and Chakraverty
2013)
⎛ ⎞
[1.2492, 1.4071] −[0.5544, 0.6262] 0
⎝ −[0.5544, 0.6262] [1.0126, 1.1524] −[0.4582, 0.5262] ⎠
0 −[0.4582, 0.5262] [0.4582, 0.5262]
⎧ ⎫ ⎧ ⎫ .
⎨ [u 2 , ū 2 ] ⎬ ⎨ 0 ⎬
× 107 [u 3 , ū 3 ] = 0 .
⎩ ⎭ ⎩ ⎭
[u 4 , ū 4 ] [7500, 12500]
Program 8.3: A MATLAB program for solving interval system of linear equations
using Method III.
138 8 Interval System of Linear Equations
Input:
Enter the dimension of coefficient matrix A
3
Enter the lower bound of each element of interval aij:
[1.2492 -0.6262 0;-0.6262 1.0126,-0.5262;0 -0.5262 0.4582]
Enter the upper bound of each element of interval aij:
[1.4071 -0.5544 0;-0.5544 1.1524 -0.4582; 0 -0.4582 0.5262]
Enter the lower bounds of interval vector b:
[0;0;7500]
Enter the upper bounds of interval vector b:
[0;0;12500]
Output:
The crisp coefficient matrix is
A = 1.2492 -0.5544 0 0 0 0
8.2 Interval System of Equations 139
The methods considered may not yield tighter interval bounds. Readers interested
in having more detail usage of various methods for solving interval system of linear
equations are encouraged to see the references Rohn (1989), Neumaier (1990) and
Chakraverty et al. (2017)
Similar procedures involving interval computations may be applied to solve fuzzy
system of linear equations using α-cut approach. As such, literature viz. (Abbasbandy
et al. 2006), (Behera and Chakraverty 2015), and the references mentioned therein
may be referred for solving fuzzy system of equations.
Exercise
1. Solve the ISLE [A][x] = [b], where the coefficient matrix and vector is given
by
[9, 11] −[3.9, 4.1] [26, 30]
[A] = and [b] = .
−[3.9, 4.1] [15, 16] [35, 39]
References
S. Abbasbandy, E. Reza, J. Ahmad, LU decomposition method for solving fuzzy system of linear
equations. Appl. Math. Comput. 172, 633–643 (2006)
D. Behera, S. Chakraverty, Fuzzy finite element analysis of imprecisely defined structures with
fuzzy nodal force. Eng. Appl. Artif. Intell. 26(10), 2458–2466 (2013)
D. Behera, S. Chakraverty, New approach to solve fully fuzzy system of linear equations using
single and double parametric form of fuzzy numbers. Sadhana 40, 35–49 (2015)
S. Chakraverty, M. Hladík, N.R. Mahato, A sign function approach to solve algebraically interval
system of linear equations for nonnegative solutions. Fundam. Inform. 152, 13–31 (2017)
S. Das, S. Chakraverty, Numerical solution of interval and fuzzy system of linear equations. Appl.
Appl. Math. 7, 334–356 (2012)
E. Hansen, On the solution of linear algebraic equations with interval coefficients. Linear Algebra
Appl. 2, 153–165 (1969)
P.T. Kahl, Solving narrow-interval linear equation systems is NP-hard. MS thesis. University of
Texas at El Paso, 1996
V. Kreinovich, A.V. Lakeyev, J. Rohn, P.T. Kahl, Computational Complexity and Feasibility of Data
Processing and Interval Computations, vol. 10 (Springer, 2013)
A. Neumaier, Interval Methods for Systems of Equations, vol. 37 (Cambridge University Press,
1990)
J. Rohn, Systems of linear interval equations. Linear Algebr. Appl. 126, 39–78 (1989)
S.P. Shary, A new technique in systems analysis under interval uncertainty and ambiguity. Reliable
Comput. 8, 321–418 (2002)
Chapter 9
Interval Eigenvalue Problems
E(λ)x = 0
may be categorized into linear and nonlinear eigenvalue problems depending on the
linearity and nonlinearity of the eigenfunction E(λ), where λ is the eigenvalue and x
is the corresponding eigenvector. Linear eigenvalue problems are further categorized
into standard and generalized eigenvalue problems as discussed in Sects. 9.1.1 and
9.1.2. There exist variety of methods for solving standard (Gerald and Wheatley
2004; Bhat and Chakraverty 2004) and generalized eigenvalue problems (Humar
2012).
Eigenvalue problems play important role in solving many practical problems of
various science and engineering. For instance, in linear time-invariant systems, the
eigenvalues resemble respective poles of the transfer function. On the other hand, in
structural dynamics, eigenvalue problems help in identification of natural frequency
of a structural system. The governing eigenvalue problem in structural systems is
considered as
(Mλ2 + Cλ + K )x = 0, (9.1)
where M, C, and K are the mass, damping, and stiffness matrices, respectively.
But, due to the presence of impreciseness in material properties of structural system,
Eq. (9.1) reduces to uncertain eigenvalue problems as
Here, M̃, C̃, and K̃ are the uncertain mass, damping, and stiffness matrices,
respectively. As such, the standard and generalized eigenvalue problems have been
recapitulated in Sects. 9.1.1 and 9.1.2, respectively, whereas the uncertainty handling
in terms of interval eigenvalue problems has been considered in Sect. 9.2.
E(λ)x = (A − λI )x = 0, (9.3)
Solution: Comparing Eq. (9.4) with (9.3), we have the coefficient matrix
⎡ ⎤
2 −3 4 5
⎢ −3 5 8 5⎥
A=⎢
⎣ 1
⎥.
6 9 8⎦
3 −3 12 6
The eigenvalues for Eq. (9.4) are obtained by solving the characteristic equation
as
det(A − λI ) = 0. (9.5)
9.1 Eigenvalue Problems 143
There exist variety of numerical methods viz. power method, subspace iteration,
Jacobi method, etc. (Gerald and Wheatley 2004; Bhat and Chakraverty 2004) that
may be used by the readers to solve (9.5) depending upon the problems. Accord-
ingly, the characteristic Eq. (9.5) for Example 9.1 reduces to λ4 − 22λ3 + 12λ2 +
524λ + 1365 = 0 resulting to eigenvalues 19.9007, 7.3872, −2.6439
√ + 1.5148i, and
−2.6439 − 1.5148i, where “i” is the imaginary number i = −1.
Solution: Comparing Eq. (9.7) with (9.6), we have the coefficient matrices as
⎡ ⎤ ⎡ ⎤
2 −3 4 5 1 3 4 5
⎢ −3 5 8 5⎥ ⎢3 1 0 2 ⎥
A=⎢
⎣ 1
⎥ and B = ⎢ ⎥.
6 9 8⎦ ⎣4 2 1 −1 ⎦
3 −3 12 6 5 −1 −2 1
In this regard, MATLAB codes have been given in Program 9.1 that computes the
eigenvalues and corresponding vectors for given characteristic equation (standard or
generalized eigenvalue problems).
Program 9.1: Compute the eigenvalue and eigenvectors for a user input characteristic
equation, (A − λI )x = 0 or (A − λB)x = 0 using MATLAB programming.
%Characteristic equation
A = input('Enter the elements of square matrix A corresponding eigen function (A-
lambda I)\n');
B = input('Enter the elements of square matrix B corresponding eigen function (A-
lambda B)\n');
I=eye(size(A));
disp('The eigenvalues and eigenvectors of (A-lambda I)x=0 are:')
%Eigenvalue and eigenvectors of (A-lambda I)x=0
%Ds is a diagonal matrix containing the eigenvalues
%Vs gives the column vector as respective eigenvectors
[Vs,Ds] = eig(A);
%eigvs is the vector containing all eigenvalues
eigvs = diag(Ds)
Vs
disp('The eigenvalues and eigenvectors of (A-lambda B)x=0 are:')
%Eigenvalue and eigenvectors of (A-lambda B)x=0
%Dg is a diagonal matrix containing the eigenvalues
%Vg gives the column vector as respective eigenvectors
[Vg,Dg] = eig(A,B);
%eigvg is the vector containing all eigenvalues
eigvg = diag(Dg)
Vg
Using Program 9.1, the standard and generalized eigenvalue problems considered
in Examples 9.1 and 9.2 are solved.
Input:
Enter the elements of square matrix A corresponding eigen function (A-lambda I)
[2, 3, –4, 5;–3, 5, 8, 5;1, 6, 9, 8;3, –3, 12, 6]
Enter the elements of square matrix B corresponding eigen function (A-lambda B)
[1, 3, 4, 5;3, 1, 0, 2;4, 2, 1, –1;5, –1, –2, 1]
9.1 Eigenvalue Problems 145
Output:
The eigenvalues and eigenvectors of (A-lambda I)x=0 are:
eigvs = 19.6358 + 0.0000i
6.1233 + 0.0000i
–1.8796 + 3.3262i
–1.8796 – 3.3262i
Vs = –0.0771 + 0.0000i –0.4346 + 0.0000i –0.6738 + 0.0000i –0.6738 + 0.0000i
–0.5279 + 0.0000i 0.6664 + 0.0000i –0.3071 – 0.2525i –0.3071 + 0.2525i
–0.6817 + 0.0000i 0.2697 + 0.0000i –0.2170 + 0.1833i –0.2170 – 0.1833i
–0.5007 + 0.0000i –0.5425 + 0.0000i 0.5335 – 0.1501i 0.5335 + 0.1501i
The eigenvalues and eigenvectors of (A-lambda B)x=0 are:
eigvg = 8.1182 + 0.0000i
–3.6383 + 0.0000i
0.6614 + 0.5869i
0.6614 – 0.5869i
Vg = –0.3114 + 0.0000i –0.3568 + 0.0000i 0.8074 + 0.1926i 0.8074 – 0.1926i
1.0000 + 0.0000i –0.5143 + 0.0000i 0.6465 + 0.2031i 0.6465 – 0.2031i
–0.5913 + 0.0000i 1.0000 + 0.0000i 0.3157 + 0.0316i 0.3157 – 0.0316i
0.0595 + 0.0000i –0.0597 + 0.0000i –0.5638 + 0.2625i –0.5638 – 0.2625i
The standard and generalized interval eigenvalue problems have been discussed in
this section. The standard interval eigenvalue problem compared to Eq. (9.3) is given
by
where [A] is the n × n interval square matrix (each entry resembles an interval),
[λ] is the interval eigenvalue and [x] is the corresponding interval eigenvectors. The
generalized interval eigenvalue problem associated with Eq. (9.6) is given by
where [A], [B] are the n × n interval square matrices, [λ] is the interval eigenvalue,
and [x] is the corresponding interval bound of eigenvectors. Based on the classical
interval arithmetic discussed in Chap. 1, we may find variety of methods (Deif 1991;
Mahato and Chakraverty 2016a; Qiu et al. 2001) for solving Eqs. (9.9) and (9.10).
In this regard, vertex method has been discussed in detail in Sect. 9.2.1.
The vertex method (Moore 1979) is referred to the computation of interval bounds
[ f , f¯] based on interval arithmetic with respect to constraint f (a, b) = 0, where
a ∈ [a], b ∈ [b] using all possible combinations of the vertex or end points
S f = { f (a, b) = 0 , f (a, b̄) = 0, f (ā, b) = 0, f (ā, b̄) = 0} , where
(A − λa I )x a = 0 and ( Ā − λb I )x b = 0. (9.12)
Here, (9.12) has been obtained with respect to the two vertex matrices (lower
A = (a i j ) and upper Ā = (āi j ) matrices for i, j = 1, 2, . . . , n) of [A].
Now, consider an interval eigenvalue problem in Example 9.3.
Example 9.3 Compute the bounds of eigenvalues using vertex method for the stan-
dard interval eigenvalue problem ([A] − [λ]I )[x] = 0, where interval coefficient
matrix is
⎡ ⎤
[1.05, 2.1] −[2.9, 3.2] [3.8, 4.2] [4.5, 5.2]
⎢ −[2.9, 3.2] [4.9, 5.2] [7.8, 8.2] [4.8, 5.3] ⎥
[A] = ⎢
⎣ [3.8, 4.2]
⎥.
[7.8, 8.2] [8.7, 9.2] [7.8, 8.1] ⎦
[4.5, 5.2] [4.8, 5.3] [7.8, 8.1] [5.8, 6.6]
⎛⎡ ⎤ ⎡ ⎤⎞
1.05 −3.2 3.8 4.5 1 0 0 0
⎜⎢ −3.2 4.9 7.8 4.8 ⎥ ⎢0 1 0 0⎥ ⎟
⎜⎢ ⎥ − λa ⎢ ⎥⎟ x a = 0 (9.15a)
⎝⎣ 3.8 7.8 8.7 7.8 ⎦ ⎣0 0 1 0 ⎠
⎦
4.5 4.8 7.8 5.8 0 0 0 1
and
⎛⎡ ⎤ ⎡ ⎤⎞
2.1 −2.9 4.2 5.2 1 0 0 0
⎜⎢ −2.9 5.2 8.2 ⎥
5.3 ⎥ ⎢ 0 1 0 0⎥ ⎟
⎜⎢ − λb ⎢ ⎥⎟x b = 0. (9.15b)
⎝⎣ 4.2 8.2 9.2 8.1 ⎦ ⎣0 0 1 0 ⎠
⎦
5.2 5.3 8.1 6.6 0 0 0 1
Further, using (9.13) the bounds of eigenvalues are obtained as −[5.4006, 5.5938],
−[0.7554, 1.0734], [6.0211, 6.5653], and [21.0961, 22.6907].
In this regard, a MATLAB program has been written to compute real eigenvalue
bounds of standard interval eigenvalue problems.
Program 9.3: Compute the eigenvalue and eigenvectors for characteristic equation,
([A] − [λ]I )[x] = 0 using MATLAB programming.
%Characteristic equation
Al = input('Enter the elements of lower square matrix ‘A’ corresponding eigen
function (Al-lambda I)\n');
Au = input('Enter the elements of upper square matrix ‘A’ corresponding eigen
function (Au-lambda I)\n');
I=eye(size(Al));
disp('The eigenvalues of ([Al,Au]-lambda I)x=0 are:')
l=eig(Al);
u=eig(Au);
el=min(l,u);
eu=max(l,u);
disp('The lower bounds of eigenvalues for ([Al,Au]-lambda I)x=0 are:')
el'
disp('The upper bounds of eigenvalues for ([Al,Au]-lambda I)x=0 are:')
eu'
Using Program 9.3, the standard interval eigenvalue problem considered in Exam-
ple 9.3 is solved.
Input:
Enter the elements of square matrix ‘A’ corresponding eigen function (Al-lambda I)
[1.05 –3.2 3.8 4.5; –3.2 4.9 7.8 4.8; 3.8 7.8 8.7 7.8; 4.5 4.8 7.8 5.8]
Enter the elements of square matrix ‘B’ corresponding eigen function (Au-lambda
B)
[2.1 –2.9 4.2 5.2;–2.9 5.2 8.2 5.3; 4.2 8.2 9.2 8.1;5.2 5.3 8.1 6.6]
148 9 Interval Eigenvalue Problems
Output:
The lower bounds of eigenvalues for ([Al,Au]-lambda I)x=0 are:
–5.5938 –1.0734 6.0211 21.0961
(A − λa B)x a = 0, (9.16a)
(A − λb B̄)x b = 0, (9.16b)
( Ā − λc B)x c = 0, (9.16c)
and
( Ā − λd B̄)x d = 0. (9.16d)
References
R.B. Bhat, S. Chakraverty, Numerical Analysis in Engineering (Narosa, Alpha Science International
Limited, Pangbourne, 2004)
S. Chakraverty, N.R. Mahato, Nonlinear interval eigenvalue problems for damped spring-mass
system. Eng. Comput. 35(6), 2272–2286 (2018)
A. Deif, The interval eigenvalue problem. Z. Angew. Math. Mech. 71, 61–64 (1991)
C.F. Gerald, P.O. Wheatley, Applied Numerical Analysis, 7th edn. (Pearson Education, New Delhi,
2004)
J. Humar, Dynamics of Structures (CRC Press, 2012)
R.E. Moore, Methods and applications of interval analysis. SIAM Stud. Appl. Math. (1979)
N.R. Mahato, S. Chakraverty, Filtering algorithm for real eigenvalue bounds of interval and fuzzy
generalized eigenvalue problems. ASCE-ASME J. Risk Uncertain. Eng. Syst. Part B Mech. Eng.
2(4), 044502 (2016a)
N.R. Mahato, S. Chakraverty, Filtering algorithm for eigenvalue bounds of fuzzy symmetric matri-
ces. Eng. Comput. 33(3), 855–875 (2016b)
Z. Qiu, C.M. Peter, F. Andreas, An approximate method for the standard interval eigenvalue problem
of real non-symmetric interval matrices. Int. J. Numer. Methods Biomed. Eng. 17(4), 239–251
(2001)
Part II
Artificial Neural Network
Chapter 10
Artificial Neural Network Terminologies
X1
w1
w2 Y
X2
w3
X3
The arrangement of neurons into layers and the connection patterns within and
between layers are generally called as the network architecture. Neural network can
be classified as single layer, multilayer, and competitive network. The single layer
and multilayer networks are examples of feedforward network, in which the signal
flow from the input units to the output units and competitive network is an example
of recurrent network, (Sivanandam et al. 2006) in which there are closed-loop signal
paths from a unit back to itself.
A single layer neural network has one layer of connection weights. The input units
are fully connected to output units but are not connected to other input units and the
output units are not connected to other output units. The typical single layer neural
network figure is shown in Fig. 10.2.
A multilayer neural network is a network with one or more layers of nodes between
input and output units. The layer between the input and output units is called the
hidden units. Multilayer neural networks are used to solve more complicated prob-
lems that single layer neural network cannot be trained to perform correctly. The
multilayer neural network is shown in Fig. 10.3.
10.2 Network Architecture 155
X1
w1
X2 Y
w2
w3
X3
Output Layer
Input Layer
X1 w1 w10
Z1 Y1
w2
w11
w3 w12
w4 w13
X2 Z2
w5 w14 Y2
w6 w15
w7 w8 w16
w17
w9 Z3
X3 Y3
w18
A competitive layer forms a part of a large number of neural networks. The com-
petitive neural network is similar to a single layer neural network except that there
are connections, usually negative between the output nodes. Because of these con-
nections, the output nodes tend to compete to represent the current input pattern. An
example of the architecture for a competitive layer is shown in Fig. 10.4.
156 10 Artificial Neural Network Terminologies
The method of setting up of the weights value is known as learning (Zurada 1994). The
process of achieving the expected output by modifying the weights in the connections
between network layers is called training. In general, there are two types of training,
supervised and unsupervised trainings.
Supervised training means training with the help of a teacher. The process of pro-
viding the network with a series of sample inputs and then comparing the output
with the expected responses is supervised training. The training continues until the
network is able to provide the expected response.
Unsupervised training means training without the help of a teacher. In a neural net, if
the target output is not known for training the input vectors, then the training method
adopted is called as unsupervised training. The net may modify the weight so that the
most similar input vector is assigned to the same output unit. Unsupervised training
is more complex and difficult to implement.
10.4 Activation Function 157
Let the weighted sum of input into a neuron is denoted by yin . The activation or
neuron y is then given by applying the activation function f to yin as
output of the
y = f yin . Figure 10.5 shows some activation functions that are generally used.
Some common activation functions are defined below.
f (x) f (x)
Identity x x
Binary step
f (x) f (x)
Bipolar step x
Binary sigmoid x
f (x)
Binary sigmoid x
The threshold value is specified by θ . The output has bipolar values (1 or −1)
only.
(iv) Binary Sigmoid function:
Sigmoid functions are usually s-shaped curves. These functions are used in
multilayer neural network. The binary sigmoid function is also called logistic
function. The binary sigmoid function is given as
1
y = f (yin ) = ,
1+ e−σ (yin −θ)
10.4.2 Weights
10.4.3 Bias
10.4.4 Threshold
The threshold θ is a factor which is used in calculating the activations of the given
net. Based on the value of threshold, the output may be calculated, i.e., the activation
function is based on the value of θ . If thresholds are included then the activation
function is obtained as
160 10 Artificial Neural Network Terminologies
1 b
Y
w2
X1
w3
X2
1 if Net ≥ θ,
f(Net) =
−1 if Net < θ,
where net input is calculated as Net = xi wi .
i
If the weights are given as W = (wij ) in a matrix form, the net input to output unit
Yj is given as the dot product of the input vectors x = (x1 , … xi … xn ) and wj (jth
column of the weight vector matrix). The net input to unit Yj is given by
yin j = xi · w j ,
n
yin j = xi wi j ,
i=1
n
yin j = b j + xi wi j if bias is included.
i=1
bj
X1 Yj
w1j
wij
Xi
wnj
Xn
Output Layer
Input Layer
Program:
162 10 Artificial Neural Network Terminologies
% Activation Functions
clear all
clc
x1=rand(1,50);
x2=-rand(1,50);
% Identity Function
x=[x1 x2];
y=x;
x=sort(x,'ascend');
figure
plot(x,y,'*')
title('Identity Function');
% Sigmoid Function
m=50*x;
for i=1:l
f1(i)=1/(1+exp(-m(i)));
end
for i=1:l
f2(i)=(2/(1+exp(-m(i))))-1;
end
figure
plot(x,f1)
title('Binary Sigmoid Function');
figure
plot(x,f2)
title ('Bipolar Sigmoid Function');
10.6 Matlab Programs 163
Output:
The output response is given as
Identity Function
1
0.5
Y=f(x)
-0.5
-1
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
X
Identity Function
0.8
0.6
Y=f(x)
0.4
0.2
0
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
X
0.5
Y=f(x)
-0.5
-1
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
X
164 10 Artificial Neural Network Terminologies
0.8
0.6
Y=f(x)
0.4
0.2
0
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
X
0.5
Y=f(x)
-0.5
-1
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
X
Program:
Output:
Enter the value of net: 0.38
The value of activation function in case of Binary Sigmoid is
f1 = 0.5939
The value of activation function in case of Bipolar Sigmoid is
f2 = 0.1877
References
The McCulloch–Pitt neural network is considered to be the first neural network. The
neurons are connected by directed weighted paths Nakamoto (2017). McCulloch–Pitt
neuron (Sivanandam 2006) allows binary activation (1 ON or 0 OFF), i.e., it either
fires with an activation 1 or does not fire with an activation of 0. If w > 0, then
the connected path is said to be excitatory else it is known as inhibitory. Excitatory
connections have positive weights and inhibitory connections have negative weights.
Each neuron has a fixed threshold for firing. That is, if the net input to the neuron is
greater than the threshold, it fires.
where θ is the threshold and yin is the total net input signal received by neuron Y.
The inhibition should be absolute. Hence, the threshold satisfies θ > nw − p.
The output neuron will fire if it receives k or more excitatory inputs with no
inhibitory inputs, where kw ≥ θ > (k − 1) w.
Xn w Y
-p
Xn+1
-p
Xn+m
X1
1
Y
1
X2
11.3 Matlab Programs for McCulloch–Pitts Neuron Model 169
Program:
clear all
clc
x1=[1 1 0 0];
x2=[1 0 1 0];
w1=input('enter the value of weight w1: ');
w2=input('enter the value of weight w2: ');
t=input('enter the value of threshold value: ');
for i=1:4
n=(x1(i)*w1)+(x2(i)*w2);
if(n>=t)
Y(i)=1;
else
Y(i)=0;
end
end
disp ( ' x1 x2 Y ')
[x1' x2' Y']
Output:
enter the value of weight w1: 1
enter the value of weight w2: 1
enter the value of threshold value: 2
X1 X2 Y
1 1 1
1 0 0
0 1 0
0 0 0
Program:
clear all
clc
x1=[1 1 0 0];
x2=[1 0 1 0];
w1=input('enter the value of weight w1: ');
w2=input('enter the value of weight w2: ');
t=input('enter the value of threshold value: ');
for i=1:4
n=(x1(i)*w1)+(x2(i)*w2);
if(n>=t)
Y(i)=1;
else
Y(i)=0;
end
end
[x1' x2' Y']
Output:
enter the value of weight w1: 1
enter the value of weight w2: 1
enter the value of threshold value: 1
X1 X2 Y
1 1 1
1 0 1
0 1 1
0 0 0
Program:
clear all
clc
x1=[1 1 0 0];
x2=[1 0 1 0];
y1=input('enter the value of weight y1: ');
y2=input('enter the value of weight y2: ');
v1=input('enter the value of weight v1: ');
v2=input('enter the value of weight v2: ');
w1=input('enter the value of weight w1: ');
w2=input('enter the value of weight w2: ');
t=input('enter the value of threshold value: ');
for i=1:4
n=(x1(i)*y1)+(x2(i)*y2);
if(n>=t)
z1(i)=1;
else
z1(i)=0;
end
end
for i=1:4
n=(x1(i)*v1)+(x2(i)*v2);
if(n>=t)
z2(i)=1;
else
z2(i)=0;
end
end
for i=1:4
n=(z1(i)*w1)+(z2(i)*w2);
if(n>=t)
Y(i)=1;
else
Y(i)=0;
end
end
[x1' x2' Y']
Output:
enter the value of weight y1: 1
enter the value of weight y2: −1
enter the value of weight v1: −1
enter the value of weight v2: 1
172 11 McCulloch–Pitts Neural Network Model
Program:
clear all
clc
x1=[1 1 0 0];
x2=[1 0 1 0];
w1=input('enter the value of weight w1: ');
w2=input('enter the value of weight w2: ');
t=input('enter the value of threshold value: ');
for i=1:4
n=(x1(i)*w1)+(x2(i)*w2);
if(n>=t)
Y(i)=1;
else
Y(i)=0;
end
end
[x1' x2' Y']
Output:
enter the value of weight w1: 1
enter the value of weight w2: −1
References 173
References
Hebbian learning rule is one of the earliest and the simplest learning rules for the
neural networks Laurene (1994). It was proposed by Donald Hebb. Hebb proposed
that if two interconnected neurons are both “on” at the same time, then the weight
between them should be increased. Hebbian network is a single layer neural network
which consists of one input layer with many input units and one output layer with one
output unit. This architecture is usually used for pattern classification (Bosse et al.
2010), (Brito and Gerstner 2016) and Born et al. (2017). The bias which increases
the net input has value 1. The architecture of Hebbian network is shown in Fig. 12.1.
X1
w1
Y
wi
Xi
wn
Xn
If the bias is considered to be an input signal that is always 1, the weight change
can be written as
Program:
% Hebbian Algorithm
% XOR Gate
clear all
clc
x1=[1 1 -1 -1];
x2=[1 -1 1 -1];
b=[1 1 1 1];
y=[-1 1 1 -1];
w1=0;
w2=0;
h=0;
for i=1:4
12.3 Matlab Programs Using Hebbian Learning Rule 177
d1(i)=x1(i)*y(i);
d2(i)=x2(i)*y(i);
db(i)=b(i)*y(i);
w1_n(i)=w1+d1(i);
w2_n(i)=w2+d2(i);
b_n(i)=h+db(i);
w1=w1_n(i);
w2=w2_n(i);
h=b_n(i);
end
disp(' Input Target Weight Change Weights');
disp(' x1 x2 b Y dw1 dw2 db w1 w2 B');
H=[x1' x2' b' y' d1' d2' db' w1_n' w2_n' b_n'];
disp(H)
Output:
x1 x2 b Y dw1 dw2 db w1 w2 B
1 1 1 -1 -1 -1 -1 -1 -1 -1
1 -1 1 1 1 -1 1 0 -2 0
-1 1 1 1 -1 1 1 -1 -1 1
-1 -1 1 -1 1 1 -1 0 0 0
Program:
% Hebbian Algorithm
clear all
clc
% a part
x1=[1 -1 1 1];
x2=[1 1 1 -1];
x3=[1 -1 1 -1];
x4=[1 -1 -1 1];
b=[1 1 1 1];
y=[1 1 -1 -1];
w1=0;
w2=0;
w3=0;
w4=0;
h=0;
for i=1:4
d1(i)=x1(i)*y(i);
d2(i)=x2(i)*y(i);
d3(i)=x3(i)*y(i);
d4(i)=x4(i)*y(i);
db(i)=b(i)*y(i);
w1_n(i)=w1+d1(i);
w2_n(i)=w2+d2(i);
w3_n(i)=w3+d3(i);
w4_n(i)=w4+d4(i);
b_n(i)=h+db(i);
w1=w1_n(i);
w2=w2_n(i);
w3=w3_n(i);
w4=w4_n(i);
h=b_n(i);
end
disp(' Input Target Weight Change Weights');
disp(' x1 x2 x3 x4 b Y dw1 dw2 dw3 dw4 db
w1 w2 w3 w4 B');
H=[x1' x2' x3' x4' b' y' d1' d2' d3' d4' db' w1_n' w2_n' w3_n' w4_n'
b_n'];
disp(H)
12.3 Matlab Programs Using Hebbian Learning Rule 179
Output:
Inputs Target Weight Change
x1 x2 x3 x4 b Y dw1 dw2 dw3 dw4 db
1 1 1 1 1 1 1 1 1 1 1
-1 1 -1 -1 1 1 -1 1 -1 -1 1
1 1 1 -1 1 -1 -1 -1 -1 1 -1
1 -1 -1 1 1 -1 -1 1 1 -1 -1
Weights
w1 w2 w3 w4 B
1 1 1 1 1
0 2 0 0 2
-1 1 -1 1 1
-2 2 0 0 0
Program:
% b part
yin(i)=(x1(i)*w1_n(i))+(x2(i)*w2_n(i))+(x3(i)*w3_n(i))+(x4(i)*w4_
n(i))+b_n(i);
if yin(i)>=t
Y(i)=1;
else
Y(i)=-1;
end
end
y
Y
if y==Y
disp('correct');
else
disp('not correct');
end
180 12 Hebbian Learning Rule
Output:
enter the value of theta: 0
y=
1 1 -1 -1
Y=
1 1 -1 -1
correct
(a)
+ + +
+
+ + +
Program:
Output:
w1 w2 w3 w4 w5 w6 w7 w8 w9 w10
1 1 1 -1 1 -1 1 1 1 1
0 0 0 0 0 0 0 0 2 0
(b)
+ + +
+
+ +
Program:
for i=1:2
db(i)=y(i);
b_n(i)=h+db(i);
h=b_n(i);
for j=1:n
dw(i,j)=x(i,j)*y(i);
w_n(j)=w(j)+dw(i,j);
w(j)=w_n(j);
end
e(i,:)=w;
end
[e b_n']
182 12 Hebbian Learning Rule
Output:
1 1 1 1 1 -1 -1 -1 1 1 1 1 1 -1 -1 -1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 1 1
0 2 2 2 0
References
A single layer perceptron is a simplest form of neural network. This type of neural
network is used for pattern classifications that are linearly separable. Single layer
perceptron consists of one input layer with one or many input units and one output
layer with one or many output units. The neurons are connected to each other by
weights and bias (Gkanogiannis and Kalamboukis (2009, 2010)).
b
X1
w1
Y
wi
Xi
wn
Xn
n
Step 4: Compute the output unit as yin = b + i=1 xi wi .
The activation function is used as
⎧
⎨ 1, if yin > θ
Y = f yin = 0, if −θ ≤ yin ≤ θ .
⎩
−1 if yin < θ
Step5: The weights and bias are updated if the target is not equal to the output
response.
If t = y and the value of xi = 0
then wi (new) = wi (old) + αtxi for i = 1, …, n
b(new) = b(old) + αt
b(new) = b(old)
Program:
% Perceptron 1
clear all
clc
x1=[1 -1 1 -1];
x2=[1 1 -1 -1];
t=[1 -1 -1 -1];
v=[1 1 1 1];
th=input('enter the value of theta: ');
a=input('enter the value of alpha: ');
w1=0;
w2=0;
b=0;
dw1=a.*x1.*t;
dw2=a.*x2.*t;
db=a.*t;
for i=1:4
yin=w1*x1(i)+w2*x2(i)+b;
if yin>th
y=1;
elseif -th<=yin&&yin<=th
y=0;
else
y=-1;
end
if y~=t(i)
w1=w1+dw1(i);
w2=w2+dw2(i);
b=b+db(i);
end
w1_n(i)=w1;
w2_n(i)=w2;
b_n(i)=b;
end
186 13 Perceptron Learning Rule
x1 x2 b Y dw1 dw2 db w1 w2 B
1 1 1 1 1 1 1 1 1 1
–1 1 1 –1 1 –1 –1 2 0 0
1 –1 1 –1 –1 1 –1 1 1 –1
–1 –1 1 –1 1 1 –1 1 1 –1
% Perceptron 2
clear all
clc
x1=[1 1 0 0];
x2=[1 0 1 0];
t=[1 -1 -1 -1];
th=input('enter the value of theta: ');
a=input('enter the value of alpha: ');
dw1=a.*x1.*t;
dw2=a.*x2.*t;
for l=4:-1:3
w1=0;
w2=0;
for j=1:2
13.4 Matlab Programs Using Perceptron Learning Rule 187
for i=1:l
yin=x1(i)*w1+x2(i)*w2;
if yin>th
y=1;
elseif -th<=yin&&yin<=th
y=0;
else
y=-1;
end
if y~=t(i)
w1=w1+dw1(i);
w2=w2+dw2(i);
end
w1_n(i)=w1;
w2_n(i)=w2;
end
end
disp(' Weights');
disp(' w1 w2');
H=[w1_n' w2_n'];
disp(H)
clear w1_n;
clear w2_n;
end
Output:
enter the value of theta: 0
enter the value of alpha: 1
x1 x2 Y w1 w2
1 1 1 1 1
0 1 –1 0 1
1 0 –1 0 0
0 0 –1 0 0
188 13 Perceptron Learning Rule
x1 x2 Y w1 w2
1 1 1 1 1
0 1 –1 0 1
1 0 –1 0 0
References
J. Macek Zurada, Introduction to Artificial Neural Systems (Jaico Publishing House, 1994)
S.N. Sivanandam, S. Sumathi, S.N. Deepa, Introduction to Neural Networks using Matlab 6.0
(McGraw Hill Education (India) Private Ltd., 2006)
A. Gkanogiannis, T. Kalamboukis, A modified and fast Perceptron learning rule and its use for Tag
Recommendations in Social Bookmarking Systems. ECML PKDD Discovery Challenge 2009
(DC09). 497(71), 1–13 (2009)
A. Gkanogiannis, T. Kalamboukis, A Perceptron-Like Linear Supervised Algorithm for Text Clas-
sification. In: L. Cao, Y. Feng, J. Zhong (eds) Advanced Data Mining and Applications. ADMA
2010. Lect. Notes Comp. Sci. 6440. Springer, Berlin, Heidelberg (2010)
Chapter 14
Delta Learning Rule
and Backpropagation Rule
for Multilayer Perceptron
In a network, if the output values cannot be traced back to the input values and if
for every input vector, an output vector is calculated, then there is a forward flow of
information and no feedback between the layers. Such type of network is known as
feedforward networks (Laurene 1994), Zurada(1994).
The training depends upon which type of activation function is used (Chakraverty
and Sahoo (2014, 2015)). Here, algorithm is given for unipolar sigmoid function.
The step-by-step algorithm is given below Shivanandam (2006):
Step 1: Initialize weights to some small random values. Let us take η as the learn-
ing rate.
Step 2: For each training pair do steps 3–10.
n
zin = θi + xi vij ,
i=1
θi is the bias from input to hidden unit and vij are the weights from input
to hidden units.
The activation function defined as f(x) = 1+exp(−x)
1
and its derivative is
defined as
p
yin = θj + zj wjk ,
j=1
θj is the bias from hidden to output unit and wjk are the weights from hidden
to output units. Applying the activation function to calculate output unit
yk = f yin .
1 2
E= tk − y k .
2
Step 7: Error signal between the output and hidden layer δk is given as
δk = tk − yk 1 − yk yk for k = 1, . . . , m.
Step 8: Error signal between the hidden and input layer δj is given as
14.3 Training Algorithm with Unipolar Sigmoid Function 191
m
δj = zj 1 − zj δk wjk for j = 1, . . . , p.
k=1
Step 9: The weights and bias of the output layer are updated as
Step 10: The weights and bias of the hidden layer are updated as
Here, algorithm is given for bipolar sigmoid function (Chakraverty et al. 2010). The
step-by-step algorithm is given below:
Step 1: Initialize weights to some small random values. Let us take η as the learn-
ing rate.
Step 2: For each training pair do steps 3–10.
Step 3: Here, each input unit is considered as xi for i = 1, …, n which transfers
its data to the hidden layer.
Step 4: Each hidden unit is considered here as zj for j = 1, …, p which are the
weighted sum of the input vector,
n
zin = θi + xi vij ,
i=1
θi is the bias from input to hidden unit and vij are the weights from input
to hidden units.
The activation function is defined as f(x) = 1+exp(−x)
2
−1 and its derivative
is defined as
1
f (x) = [1 + f(x)][1 − f(x)].
2
192 14 Delta Learning Rule and Backpropagation …
p
yin = θj + zj wjk ,
j=1
θj is the bias from hidden to output unit and wjk are the weights from hidden
to output units. Applying the activation function to calculate output unit
yk = f yin .
1 2
E= tk − y k .
2
Step 7: Error signal between the output and hidden layer δk is given as
1
δk = tk − yk 1 − y2k for k = 1, . . . , m.
2
Step 8: Error signal between the hidden and input layer δj is given as
1 m
δj = 1 − z2j δk wjk for j = 1, . . . , p.
2 k=1
Step 9: The weights and bias of the output layer are updated as
Step 10: The weights and bias of the hidden layer are updated as
-1
y
2 1
-1
1
Z1
Z2 Z3
0 3
-1
1
2 1 2
0 2 1
1
X1 X2
X3
Program:
% Multilayer Perceptron
clear all
clc
% Step-1: Initialization
x=[0.6 0.8 0];
t=0.9;
a=0.3;
v=[2 1 0;1 2 2;0 3 1];
vo=[0 0 -1];
w=[-1 1 2];
wo=-1;
194 14 Delta Learning Rule and Backpropagation …
% Feed Forward
% Step-2
for j=1:3
zin(j)=vo(j)+dot(v(:,j),x);
z(j)=1/(1+exp(-zin(j)));
end
% Step-3
yin=wo+dot(z,w);
y=1/(1+exp(-yin));
% Step-4
E=0.5*((t-y)^2);
% Back Propagation
% Step-5
delk=(t-y)*y*(1-y);
% Step-6
for j=1:3
delin(j)=delk*w(j);
del(j)=delin(j)*z(j)*(1-z(j));
end
% Step-7
delwok=a*delk;
wo=wo+delwok;
for j=1:3
delwjk(j)=a*delk*z(j);
w(j)=w(j)+delwjk(j);
end
% Step-8
for i=1:3
delvo(i)=a*del(j);
vo(i)=vo(i)+delvo(i);
for j=1:3
delv(i,j)=a*del(j)*x(i);
v(i,j)=v(i,j)+delv(i,j);
end
end
w
v
14.5 Matlab Programs for Multilayer Neural Network … 195
Output:
w=
v=
0 3.0000 1.0000
References