SlideShare a Scribd company logo
1 of 9
Download to read offline
First Finite Divided Difference Calculator Using MIT
App Inventor 2
Gomez, Camille Bianca C.
Gokongwei College of Engineering
BS Electronics and Communications Engineering
Biñan, Laguna, Philippines
camille_gomez@dlsu.edu.ph
Abstract—This project is a user-friendly mobile application
of solving the first derivative of a polynomial equation using the
three methods of solving the first derivative of a polynomial
equation: Forward Differentiation, Backward Differentiation,
and Centered Differentiation. The software that was used for
this mobile application is MIT App Inventor 2. The concept of
Algorithm on Discrete Mathematics was applied in this project.
This paper includes the pseudocodes for getting the true value
of a given polynomial equation, true value derivative of a given
polynomial equation and the first finite divided difference.
Keywords—derivative; first finite divided difference; forward
differentiation; backward differentiation; centered
differentiation; MIT App Inventor; mobile application; algorithm;
pseudocode
I. INTRODUCTION
MIT App inventor is a tool created to help aspiring app
developers to build their own application right in the web
browser. It is the beginner’s introduction to programming and
making a mobile app that consists of a drag-and-drop building
blocks [1]. All things needed to understand how the software
works is included in their resources.
The concept of algorithm from discrete mathematics and
numerical differentiation from numerical methods will be
implemented using the app inventor tool.
Algorithm is a finite set of clear instruction or methods for
performing a computation or to solve a problem. It can be
implemented using a programming software (e.g. MATLAB,
DevC) however the coding scheme for a certain programming
software needs a correct command for it to be implemented
and for this reason, a Pseudocode is used [2]. Pseudocode is
considered to be the convention of any programming language
that can be understood easily by humans to aid them on
generating a program or code. The steps or instructions used
to implement an algorithm are well described operations or
statements in a pseudocode for it to be a non-specific
programming language [2].
Finite Divided Difference is the approximation derived
from Taylor series and is used to approximate certain
problems numerically. Finite divided difference is commonly
used in a problem with boundaries [3].
II. THEORETICAL CONSIDERATION
A. Forward, Backward, and Centered Difference
Finite difference is a topic from numerical method and is
used to solve differential equation by using approximation
and represented as:
𝑓′(𝑥𝑖) =
𝑓(𝑥 𝑖+1)−𝑓(𝑥 𝑖)
𝑥 𝑖+1−𝑥 𝑖
+ 𝑂(𝑥𝑖+1 − 𝑥𝑖) (1)
or
𝑓(𝑥𝑖) =
∆𝑓𝑖
ℎ
+ 𝑂(ℎ) (2)
Where ∆𝑓𝑖 is the first forward difference and ℎ is the stepz
size. The term ∆𝑓/ℎ is known as the first finite divided
difference. The forward divided difference is derived from
Taylor series, also backward difference approximation for the
first derivative Eq. (3) and the centered difference
approximation for the first derivative can also be derived Eq.
(4) [3].
𝑓′(𝑥𝑖) ≅
𝑓( 𝑥𝑖)−𝑓( 𝑥𝑖−1)
ℎ
=
∇𝑓
ℎ
(3)
𝑓′(𝑥𝑖) ≅
𝑓( 𝑥𝑖+1)−𝑓( 𝑥𝑖−1)
2ℎ
− 𝑂(ℎ2
) (4)
For a better understanding of the equations for forward,
backward and centered difference, a graphical representation
was shown in Fig. 1.
Fig.1 A graphical depiction of forward (a), backward (b) and centered (c)
finite-divided difference approximations of the first derivative [3]
For the forward difference, we compute for the slope
nearby the secant line (Approximation), the points (𝑥𝑖, 𝑓(𝑥𝑖))
and (𝑥𝑖+1, 𝑓(𝑥𝑖+1)). We choose a small number of ℎ which
represents as the small change in 𝑥 and can be either positive
or negative. Thus, it will give us the formula for forward
difference [4]:
𝑓′(𝑥) =
𝑓(𝑥+ℎ)−𝑓(𝑥)
ℎ
(5)
This is the same with backward difference, only differs
with the position of the two points (𝑥𝑖−1, 𝑓(𝑥𝑖−1)) and
(𝑥𝑖, 𝑓(𝑥𝑖)), giving us the formula for backward difference
[4]:
𝑓′(𝑥) =
𝑓(𝑥)−𝑓(𝑥−ℎ)
ℎ
(6)
Another formula to compute the slope nearby the secant
line through the points (𝑥𝑖−1, 𝑓(𝑥𝑖−1)) and (𝑥𝑖+1, 𝑓(𝑥𝑖+1)),
giving us the formula for centered difference [4]:
𝑓′(𝑥) =
𝑓(𝑥+ℎ)−𝑓(𝑥−ℎ)
2ℎ
(7)
It is more accurate to the true derivative value, if the
given ℎ is much closer to 0 because as ℎ approaches to 0,
the slope of the secant line will approaches the tangent line
which is the true derivative line shown in Fig. 1.
B. Approximation and Round-off Errors
Numerical methods are the approximations for analytical
solutions. Solutions that are derived manually will have some
deviation thus producing errors [3].
Round-off error is the most known error when using
numerical method. It happens when only a certain amount of
significant digits are required to be presented. Learning how
to determine or quantify error is a must in using numerical
methods [3].
The following equations governs the quantification of an
error:
𝑇𝑟𝑢𝑒 𝑉𝑎𝑙𝑢𝑒 = 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛 + 𝑒𝑟𝑟𝑜𝑟 (8)
𝐸𝑡 = 𝑇𝑟𝑢𝑒 𝑉𝑎𝑙𝑢𝑒 − 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛 (9)
Where Et, true error, is the difference between the true
value and the approximated value. Resulting for a relative
true error:
Ɛ 𝑡 =
𝐸 𝑡
𝑇𝑟𝑢𝑒 𝑉𝑎𝑙𝑢𝑒
𝑥 100% (10)
Where Ɛt is the ratio between the true error with respect
to the true value.
III. DESIGN CONSIDERATIONS
The design of this project is to calculate for the first
derivative of a given polynomial equation in any order. It will
also determine the percentage error of the forward, backward,
and centered difference approximations of the first derivative
to the true value of the first derivative using the concept of
absolute and relative error.
This mobile app is user friendly in a way that it tells the
user how the calculator works where it is defined what the
calculator is use for. It is show in Fig. 2 what the home screen
looks like.
Fig.2 Home Screen
It has three buttons where it will lead the user to its
preference, whether the details about the app, how to use the
app, and the main objective of the app. On the “Definition”
section shown in Fig. 3, it gives the description about
Numerical Differentiation including the formulas that were
used for the calculator. There is also a detail about the mobile
app itself.
Fig. 3 Definition Screen
The “How to Use” button gives a specific example of a
problem from the book [3] where it will tell the user how to
use the calculator by telling what should be the input on the
textboxes. It is shown in Fig. 4 what the screen looks like.
Fig. 4 Tips Screen
The last button “Calculator” will lead the user to the main
objective of the mobile app shown in Fig. 5. It will ask the
user for the polynomial, value of x, and the step size (ℎ). It is
already shown in Fig. 4 how to do that. Then the user will
click the “Solve” button and it will give the output below.
Fig. 5 First Finite Divided Difference Calculator Screen
Fig. 6 First Finite Divided Difference Calculator Process in mobile app
Fig. 6 shows the process on how the calculator works. It’s
only similar to what calculator really do, it only differs that
in just one click it will solve for the true first derivative value,
given the approximations and the relative error of each.
In MIT App Inventor, it is important to know first how the
program will work, and it is by making an algorithm. This
design consists of four algorithms: First, determining how to
get the polynomial evaluation of an equation, second,
determining the numerical value of the first derivative
polynomial, third, is by combining the two and the three
approximations of the first derivative, and lastly, is the
overall algorithm of the calculator.
Alg. 1: Getting the polynomial evaluation
PRE-CONDITION: polynomialeval (m1,m2,m3,...mn:
polynomial coefficients which corresponds to mxn-1
,
mxn-2
, mxn-3
,…,mxn-n
, value of x : integer)
fx = 0
e = (n-1) to 0, decrement 1
for N = 1 to n
y = mN * x(eN)
fx = fx + y
end
POST-CONDITION: fx : Output the value of a
polynomial evaluation
Input the coefficients of a polynomial
(any order)
Input a value of x
Input a value of step size (h)
Click "Solve!"
Output: True Value, Forward-Backward-
Centered Difference Approximations, and
Relative Error
Alg. 2: Getting the first derivative of a polynomial
PRE-CONDITION: polynomialderivative
(m1,m2,m3,...,mn: polynomial coefficients which
corresponds to mxn-1
, mxn-2
, mxn-3
,…,mxn-n
, value of x :
integer)
fxd = 0
e = (n-1) to 0, decrement 1
for N = 1 to n
dy = eN*mN*(x(eN)-1
)
fxd = fxd + dy
end
POST CONDITION: fxd : Output the derivative value of
a polynomial
Alg. 3: Getting the approximations of the first derivative
PRE-CONDITION: firstfinitedivideddifference
(m1,m2,m3,...,mn: polynomial coefficients which
corresponds to mxn-1
, mxn-2
, mxn-3
,…,mxn-n
, value of x
and step size (h) : integers)
fx = 0
fxd = 0
e = (n-1) to 0, decrement 1
forward = 0
backward = 0
for N = 1 to n
y = mN * x(eN)
dy = eN * mN * x(eN-1)
fwd = mN * (x-h)(eN)
bwd = mN * (x-h)(eN)
fx = fx + y
fxd = fxd + dy
forward = forward + fwd
backward = backward + bwd
end
forwarddiff = (forward-fx)/h
backwarddiff = (forward-fx)/(-h)
centerdiff = (forward-backward)/(2*h)
POST CONDITION: forwarddiff, backwarddiff
centerdiff : Output the forward, backward, and center
differences
Alg. 4: First Finite Divided Difference Calculator
PRE-CONDITION: firstfinitedivideddifferencecalc
(m1,m2,m3,...,mn: polynomial coefficients which
corresponds to mxn-1
, mxn-2
, mxn-3
,…,mxn-n
, value of x
and step size (h) : integers)
fx = 0
fxd = 0
e = (n-1) to 0, decrement 1
forward = 0
backward = 0
for N = 1 to n
y = mN * x(eN)
dy = eN * mN * x(eN-1)
fwd = mN * (x-h)(eN)
bwd = mN * (x-h)(eN)
fx = fx + y
fxd = fxd + dy
forward = forward + fwd
backward = backward + bwd
end
forwarddiff = (forward-fx)/h
backwarddiff = (forward-fx)/(-h)
centerdiff = (forward-backward)/(2*h)
forwardrelativeerror = absolute((forwarddiff-
fxd)/fxd*100);
backwardrelativeerror = absolute((backwarddiff-
fxd)/fxd*100);
centerrelativeerror = absolute((centerdiff-fxd)/fxd*100);
POST CONDITION: forwarddiff, backwarddiff
centerdiff : Output the forward, backward, and center
differences
IV. DATA AND RESULTS
Algorithm is the process on how to solve a problem with
the use of pseudocodes. In this section, it will give the results
of the four algorithms that were formulated.
It is given a polynomial equation of 2𝑥4
+ 5𝑥3
− 6𝑥2
−
𝑥 + 3 at 𝑥 = 2 and step size ℎ = 0.1. The following tables
demonstrates how the given algorithms work.
TABLE I. ALGORITHM FOR GETTING THE POLYNOMIAL EVALUATION
N mN eN x(eN)
y fx
1 2 4 16 32 32
2 5 3 8 40 72
3 -6 2 4 -24 48
4 -1 1 2 -2 46
5 3 0 1 3 49
TABLE II. ALGORITHM FOR GETTING THE FIRST DERIVATIVE OF A
POLYNOMIAL
N mN eN (x(eN)-1
) dy fxd
1 2 4 8 64 64
2 5 3 4 60 124
3 -6 2 2 -24 100
4 -1 1 1 -1 99
5 3 0 1 0 99
TABLE III. ALGORITHM FOR GETTING APPROXIMATIONS OF THE FIRST
DERIVATIVE
N fx fxd forward backward forwarddiff backwarddiff centerdiff
1 32 64 38.8962 26.0642 - - -
2 72 124 85.2012 60.3592 - - -
3 48 100 58.7412 38.6992 - - -
4 46 99 56.6412 36.7992 - - -
5 49 99 59.6412 39.7992 106.412 92.01 99.21
TABLE IV. ALGORITHM FOR FIRST FINITE DIVIDED DIFFERENCE
CALCULATOR
N fxd forward
diff
backward
diff
centerdi
ff
ferror berror cerror
1 64 - - - - - -
2 124 - - - - - -
3 100 - - - - - -
4 99 - - - - - -
5 99 106.4 92.01 99.21 7.48% 7.06% 0.21%
According to the calculations, we have come up to that
answers by simply following the algorithm that was
formulated. Using the Numerical Differentiation mobile app,
it also come up with the same answers (shown in Fig. 7),
verifying that the algorithms are correct.
Fig. 7 Answer to the given example using the First Finite Divided Difference
Calculator
In the given problem, the true first derivative value is 99,
and the approximations value for forward, backward, and
centered differences are 106.412, 92.01, and 99.21,
respectively. Those are only the approximated numerical
value of the first finite divided difference the reason why a
relative errors are included in the computations.
V. ANALYSIS
The results for getting the first finite divided difference
are verified that the algorithms that were formulated are
correct. As it was compared with the Numerical
Differentiation mobile app, they have the same results. With
the help of pseudocode, it became easier to code it by the use
of blocks programming that the MIT App Inventor 2 use.
VI. CONCLUSION
In conclusion, MIT app inventor has been a great tool for
helping app developers such as myself. It helps oneself
cultivate their skills and knowledge to prepare and contribute
for the growing demand for app developers. The use and
application of one’s learning in an academia such as discrete
mathematics (DISMATH) and numerical methods
(NUMMETH) is not only limited to what they have tackled.
It can be applied to many different ways such as this project.
This project, had combined the two by applying a concept
of DISMATH, in which the topic of algorithm, in another
subject course such as NUMMETH. There are a lot of other
things that can be solved or created by integrating inherited
knowledge.
APPENDIX A: HOME SCREEN BLOCKS
APPENDIX B: DEFINITION AND TIPS SCREEN BLOCKS
APPENDIX C: FIRST FINITE DIVIDED DIFFERENCE CALCULATOR SCREEN
ACKNOWLEDGMENT
The accomplishment of this final project in DISMATH
would not be possible without the help of some people so the
student would like to acknowledge with deep appreciation
and gratitude the following persons:
Engr. Melvin Kong Cabatuan, for teaching the concept of
algorithms, making it understandable by giving detailed
examples.
Dr. Argel Bandala, for teaching the concept of Numerical
Differentiation which gives me an idea how it will give
relation to DISMATH.
Paul Arroyo, for guidance and support throughout the
hardships in making this paper.
I also want to thank my family for understanding how
busy I am to make this project be a success.
And finally, I thank the Almighty God for giving me
strength and knowledge, guiding me throughout the days of
finishing this project.
REFERENCES
[1] "MIT App Inventor," 2012. [Online]. Available:
http://appinventor.mit.edu/explore/about-us.html. [Accessed April
2016].
[2] K. H. Rosen, Discrete Mathematics and Its Applications, New York:
McGraw-Hill, 2012.
[3] S. C. Chapra and R. P. Canale, Numerical Methods for Engineering,
New York: McGraw-Hill, 2010.
[4] R. L. Burden and J. D. Faires, "Numerical Analysis," in Numerical
Analysis, Ninth Edition, Boston, Brooks/Cole, Cengage Learning,
2011, pp. 174-182.

More Related Content

What's hot

Anything but simple Mathematica
Anything but simple MathematicaAnything but simple Mathematica
Anything but simple MathematicaSergeiPronkevich
 
Problem solving techniques in c language
Problem solving techniques in c languageProblem solving techniques in c language
Problem solving techniques in c languageJohn Bruslin
 
HOW TO FIND A FIXED POINT IN SHUFFLE EFFICIENTLY
HOW TO FIND A FIXED POINT IN SHUFFLE  EFFICIENTLYHOW TO FIND A FIXED POINT IN SHUFFLE  EFFICIENTLY
HOW TO FIND A FIXED POINT IN SHUFFLE EFFICIENTLYIJNSA Journal
 
Eigenface For Face Recognition
Eigenface For Face RecognitionEigenface For Face Recognition
Eigenface For Face RecognitionMinh Tran
 
Zero to ECC in 30 Minutes: A primer on Elliptic Curve Cryptography (ECC)
Zero to ECC in 30 Minutes: A primer on Elliptic Curve Cryptography (ECC)Zero to ECC in 30 Minutes: A primer on Elliptic Curve Cryptography (ECC)
Zero to ECC in 30 Minutes: A primer on Elliptic Curve Cryptography (ECC)Entrust Datacard
 
Some Engg. Applications of Matrices and Partial Derivatives
Some Engg. Applications of Matrices and Partial DerivativesSome Engg. Applications of Matrices and Partial Derivatives
Some Engg. Applications of Matrices and Partial DerivativesSanjaySingh011996
 
The Basics of MATLAB
The Basics of MATLABThe Basics of MATLAB
The Basics of MATLABMuhammad Alli
 
Exploiting Distributional Semantics Models for Natural Language Context-aware...
Exploiting Distributional Semantics Models for Natural Language Context-aware...Exploiting Distributional Semantics Models for Natural Language Context-aware...
Exploiting Distributional Semantics Models for Natural Language Context-aware...GiuseppeSpillo
 
Combinatorial Problems2
Combinatorial Problems2Combinatorial Problems2
Combinatorial Problems23ashmawy
 
A Comparative Study of Fingerprint Matching Algorithms
A Comparative Study of Fingerprint Matching AlgorithmsA Comparative Study of Fingerprint Matching Algorithms
A Comparative Study of Fingerprint Matching AlgorithmsIRJET Journal
 
Data mining assignment 3
Data mining assignment 3Data mining assignment 3
Data mining assignment 3BarryK88
 
Numerical diffrentiation and integration
Numerical diffrentiation and integrationNumerical diffrentiation and integration
Numerical diffrentiation and integrationPOONAMSINGH373
 
352735350 rsh-qam11-tif-15-doc
352735350 rsh-qam11-tif-15-doc352735350 rsh-qam11-tif-15-doc
352735350 rsh-qam11-tif-15-docFiras Husseini
 

What's hot (17)

Unit 1.1
Unit 1.1Unit 1.1
Unit 1.1
 
Anything but simple Mathematica
Anything but simple MathematicaAnything but simple Mathematica
Anything but simple Mathematica
 
Problem solving techniques in c language
Problem solving techniques in c languageProblem solving techniques in c language
Problem solving techniques in c language
 
HOW TO FIND A FIXED POINT IN SHUFFLE EFFICIENTLY
HOW TO FIND A FIXED POINT IN SHUFFLE  EFFICIENTLYHOW TO FIND A FIXED POINT IN SHUFFLE  EFFICIENTLY
HOW TO FIND A FIXED POINT IN SHUFFLE EFFICIENTLY
 
Eigenface For Face Recognition
Eigenface For Face RecognitionEigenface For Face Recognition
Eigenface For Face Recognition
 
Zero to ECC in 30 Minutes: A primer on Elliptic Curve Cryptography (ECC)
Zero to ECC in 30 Minutes: A primer on Elliptic Curve Cryptography (ECC)Zero to ECC in 30 Minutes: A primer on Elliptic Curve Cryptography (ECC)
Zero to ECC in 30 Minutes: A primer on Elliptic Curve Cryptography (ECC)
 
Some Engg. Applications of Matrices and Partial Derivatives
Some Engg. Applications of Matrices and Partial DerivativesSome Engg. Applications of Matrices and Partial Derivatives
Some Engg. Applications of Matrices and Partial Derivatives
 
The Basics of MATLAB
The Basics of MATLABThe Basics of MATLAB
The Basics of MATLAB
 
Exploiting Distributional Semantics Models for Natural Language Context-aware...
Exploiting Distributional Semantics Models for Natural Language Context-aware...Exploiting Distributional Semantics Models for Natural Language Context-aware...
Exploiting Distributional Semantics Models for Natural Language Context-aware...
 
Simplex Method
Simplex MethodSimplex Method
Simplex Method
 
Simplex method maximisation
Simplex method maximisationSimplex method maximisation
Simplex method maximisation
 
Combinatorial Problems2
Combinatorial Problems2Combinatorial Problems2
Combinatorial Problems2
 
Unit 1.5
Unit 1.5Unit 1.5
Unit 1.5
 
A Comparative Study of Fingerprint Matching Algorithms
A Comparative Study of Fingerprint Matching AlgorithmsA Comparative Study of Fingerprint Matching Algorithms
A Comparative Study of Fingerprint Matching Algorithms
 
Data mining assignment 3
Data mining assignment 3Data mining assignment 3
Data mining assignment 3
 
Numerical diffrentiation and integration
Numerical diffrentiation and integrationNumerical diffrentiation and integration
Numerical diffrentiation and integration
 
352735350 rsh-qam11-tif-15-doc
352735350 rsh-qam11-tif-15-doc352735350 rsh-qam11-tif-15-doc
352735350 rsh-qam11-tif-15-doc
 

Viewers also liked

Viewers also liked (17)

120 tennis clay
120 tennis clay120 tennis clay
120 tennis clay
 
Rita, Catarina e Lá Salete
Rita, Catarina e Lá SaleteRita, Catarina e Lá Salete
Rita, Catarina e Lá Salete
 
Andreia, Olívia e Florbela
Andreia, Olívia e FlorbelaAndreia, Olívia e Florbela
Andreia, Olívia e Florbela
 
Rita, Catarina e Salete
Rita, Catarina e SaleteRita, Catarina e Salete
Rita, Catarina e Salete
 
Ppt unicamp 15 12 finalizado pnaic
Ppt unicamp 15 12 finalizado pnaicPpt unicamp 15 12 finalizado pnaic
Ppt unicamp 15 12 finalizado pnaic
 
Información retribuciones ayto-fuenlabrada
Información retribuciones ayto-fuenlabradaInformación retribuciones ayto-fuenlabrada
Información retribuciones ayto-fuenlabrada
 
Corrientes educativas humanismo, pragmatismo
Corrientes educativas humanismo, pragmatismoCorrientes educativas humanismo, pragmatismo
Corrientes educativas humanismo, pragmatismo
 
Didáctica objeto de estudio
Didáctica objeto de estudioDidáctica objeto de estudio
Didáctica objeto de estudio
 
Rajoy
RajoyRajoy
Rajoy
 
Respuesta Sr. Coronel
Respuesta Sr. CoronelRespuesta Sr. Coronel
Respuesta Sr. Coronel
 
220 royal
220 royal220 royal
220 royal
 
Aprendizaje enseanza y propuesta pedaggica
Aprendizaje enseanza y propuesta pedaggicaAprendizaje enseanza y propuesta pedaggica
Aprendizaje enseanza y propuesta pedaggica
 
Proceso enfermero
Proceso enfermeroProceso enfermero
Proceso enfermero
 
Cercadors de videos
Cercadors de videosCercadors de videos
Cercadors de videos
 
Test 1
Test 1Test 1
Test 1
 
Principios currículum nacional
Principios currículum nacionalPrincipios currículum nacional
Principios currículum nacional
 
Soc 451, 5th class part 1
Soc 451, 5th class part 1Soc 451, 5th class part 1
Soc 451, 5th class part 1
 

Similar to First Finite Divided Difference Calculator App

Final project report
Final project reportFinal project report
Final project reportssuryawanshi
 
Simple Pendulum Experiment and Automatic Survey Grading using Computer Vision
Simple Pendulum Experiment and Automatic Survey Grading using Computer VisionSimple Pendulum Experiment and Automatic Survey Grading using Computer Vision
Simple Pendulum Experiment and Automatic Survey Grading using Computer VisionAnish Patel
 
A Fuzzy Interactive BI-objective Model for SVM to Identify the Best Compromis...
A Fuzzy Interactive BI-objective Model for SVM to Identify the Best Compromis...A Fuzzy Interactive BI-objective Model for SVM to Identify the Best Compromis...
A Fuzzy Interactive BI-objective Model for SVM to Identify the Best Compromis...ijfls
 
Scientific calculator project in c language
Scientific calculator project in c languageScientific calculator project in c language
Scientific calculator project in c languageAMIT KUMAR
 
A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...
A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...
A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...gerogepatton
 
IRJET - Application of Linear Algebra in Machine Learning
IRJET -  	  Application of Linear Algebra in Machine LearningIRJET -  	  Application of Linear Algebra in Machine Learning
IRJET - Application of Linear Algebra in Machine LearningIRJET Journal
 
A HYBRID COA/ε-CONSTRAINT METHOD FOR SOLVING MULTI-OBJECTIVE PROBLEMS
A HYBRID COA/ε-CONSTRAINT METHOD FOR SOLVING MULTI-OBJECTIVE PROBLEMSA HYBRID COA/ε-CONSTRAINT METHOD FOR SOLVING MULTI-OBJECTIVE PROBLEMS
A HYBRID COA/ε-CONSTRAINT METHOD FOR SOLVING MULTI-OBJECTIVE PROBLEMSijfcstjournal
 
A HYBRID COA/ε-CONSTRAINT METHOD FOR SOLVING MULTI-OBJECTIVE PROBLEMS
A HYBRID COA/ε-CONSTRAINT METHOD FOR SOLVING MULTI-OBJECTIVE PROBLEMSA HYBRID COA/ε-CONSTRAINT METHOD FOR SOLVING MULTI-OBJECTIVE PROBLEMS
A HYBRID COA/ε-CONSTRAINT METHOD FOR SOLVING MULTI-OBJECTIVE PROBLEMSijfcstjournal
 
SRGM with Imperfect Debugging by Genetic Algorithms
SRGM with Imperfect Debugging by Genetic AlgorithmsSRGM with Imperfect Debugging by Genetic Algorithms
SRGM with Imperfect Debugging by Genetic Algorithmsijseajournal
 
BEHAVIOR STUDY OF ENTROPY IN A DIGITAL IMAGE THROUGH AN ITERATIVE ALGORITHM O...
BEHAVIOR STUDY OF ENTROPY IN A DIGITAL IMAGE THROUGH AN ITERATIVE ALGORITHM O...BEHAVIOR STUDY OF ENTROPY IN A DIGITAL IMAGE THROUGH AN ITERATIVE ALGORITHM O...
BEHAVIOR STUDY OF ENTROPY IN A DIGITAL IMAGE THROUGH AN ITERATIVE ALGORITHM O...ijscmcj
 
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxJLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxvrickens
 
From_seq2seq_to_BERT
From_seq2seq_to_BERTFrom_seq2seq_to_BERT
From_seq2seq_to_BERTHuali Zhao
 
Traveling Salesman Problem in Distributed Environment
Traveling Salesman Problem in Distributed EnvironmentTraveling Salesman Problem in Distributed Environment
Traveling Salesman Problem in Distributed Environmentcsandit
 
TRAVELING SALESMAN PROBLEM IN DISTRIBUTED ENVIRONMENT
TRAVELING SALESMAN PROBLEM IN DISTRIBUTED ENVIRONMENTTRAVELING SALESMAN PROBLEM IN DISTRIBUTED ENVIRONMENT
TRAVELING SALESMAN PROBLEM IN DISTRIBUTED ENVIRONMENTcscpconf
 
A Comparison between FPPSO and B&B Algorithm for Solving Integer Programming ...
A Comparison between FPPSO and B&B Algorithm for Solving Integer Programming ...A Comparison between FPPSO and B&B Algorithm for Solving Integer Programming ...
A Comparison between FPPSO and B&B Algorithm for Solving Integer Programming ...Editor IJCATR
 
The Fundamental theorem of calculus
The Fundamental theorem of calculus The Fundamental theorem of calculus
The Fundamental theorem of calculus AhsanIrshad8
 

Similar to First Finite Divided Difference Calculator App (20)

Final project report
Final project reportFinal project report
Final project report
 
Simple Pendulum Experiment and Automatic Survey Grading using Computer Vision
Simple Pendulum Experiment and Automatic Survey Grading using Computer VisionSimple Pendulum Experiment and Automatic Survey Grading using Computer Vision
Simple Pendulum Experiment and Automatic Survey Grading using Computer Vision
 
A Fuzzy Interactive BI-objective Model for SVM to Identify the Best Compromis...
A Fuzzy Interactive BI-objective Model for SVM to Identify the Best Compromis...A Fuzzy Interactive BI-objective Model for SVM to Identify the Best Compromis...
A Fuzzy Interactive BI-objective Model for SVM to Identify the Best Compromis...
 
Scientific calculator project in c language
Scientific calculator project in c languageScientific calculator project in c language
Scientific calculator project in c language
 
A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...
A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...
A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...
 
Informe #1 de metodos
Informe #1 de metodosInforme #1 de metodos
Informe #1 de metodos
 
IRJET - Application of Linear Algebra in Machine Learning
IRJET -  	  Application of Linear Algebra in Machine LearningIRJET -  	  Application of Linear Algebra in Machine Learning
IRJET - Application of Linear Algebra in Machine Learning
 
A HYBRID COA/ε-CONSTRAINT METHOD FOR SOLVING MULTI-OBJECTIVE PROBLEMS
A HYBRID COA/ε-CONSTRAINT METHOD FOR SOLVING MULTI-OBJECTIVE PROBLEMSA HYBRID COA/ε-CONSTRAINT METHOD FOR SOLVING MULTI-OBJECTIVE PROBLEMS
A HYBRID COA/ε-CONSTRAINT METHOD FOR SOLVING MULTI-OBJECTIVE PROBLEMS
 
A HYBRID COA/ε-CONSTRAINT METHOD FOR SOLVING MULTI-OBJECTIVE PROBLEMS
A HYBRID COA/ε-CONSTRAINT METHOD FOR SOLVING MULTI-OBJECTIVE PROBLEMSA HYBRID COA/ε-CONSTRAINT METHOD FOR SOLVING MULTI-OBJECTIVE PROBLEMS
A HYBRID COA/ε-CONSTRAINT METHOD FOR SOLVING MULTI-OBJECTIVE PROBLEMS
 
SRGM with Imperfect Debugging by Genetic Algorithms
SRGM with Imperfect Debugging by Genetic AlgorithmsSRGM with Imperfect Debugging by Genetic Algorithms
SRGM with Imperfect Debugging by Genetic Algorithms
 
BEHAVIOR STUDY OF ENTROPY IN A DIGITAL IMAGE THROUGH AN ITERATIVE ALGORITHM O...
BEHAVIOR STUDY OF ENTROPY IN A DIGITAL IMAGE THROUGH AN ITERATIVE ALGORITHM O...BEHAVIOR STUDY OF ENTROPY IN A DIGITAL IMAGE THROUGH AN ITERATIVE ALGORITHM O...
BEHAVIOR STUDY OF ENTROPY IN A DIGITAL IMAGE THROUGH AN ITERATIVE ALGORITHM O...
 
Functions.pptx
Functions.pptxFunctions.pptx
Functions.pptx
 
Daa chapter 1
Daa chapter 1Daa chapter 1
Daa chapter 1
 
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxJLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
 
From_seq2seq_to_BERT
From_seq2seq_to_BERTFrom_seq2seq_to_BERT
From_seq2seq_to_BERT
 
Diff eq
Diff eqDiff eq
Diff eq
 
Traveling Salesman Problem in Distributed Environment
Traveling Salesman Problem in Distributed EnvironmentTraveling Salesman Problem in Distributed Environment
Traveling Salesman Problem in Distributed Environment
 
TRAVELING SALESMAN PROBLEM IN DISTRIBUTED ENVIRONMENT
TRAVELING SALESMAN PROBLEM IN DISTRIBUTED ENVIRONMENTTRAVELING SALESMAN PROBLEM IN DISTRIBUTED ENVIRONMENT
TRAVELING SALESMAN PROBLEM IN DISTRIBUTED ENVIRONMENT
 
A Comparison between FPPSO and B&B Algorithm for Solving Integer Programming ...
A Comparison between FPPSO and B&B Algorithm for Solving Integer Programming ...A Comparison between FPPSO and B&B Algorithm for Solving Integer Programming ...
A Comparison between FPPSO and B&B Algorithm for Solving Integer Programming ...
 
The Fundamental theorem of calculus
The Fundamental theorem of calculus The Fundamental theorem of calculus
The Fundamental theorem of calculus
 

First Finite Divided Difference Calculator App

  • 1. First Finite Divided Difference Calculator Using MIT App Inventor 2 Gomez, Camille Bianca C. Gokongwei College of Engineering BS Electronics and Communications Engineering Biñan, Laguna, Philippines camille_gomez@dlsu.edu.ph Abstract—This project is a user-friendly mobile application of solving the first derivative of a polynomial equation using the three methods of solving the first derivative of a polynomial equation: Forward Differentiation, Backward Differentiation, and Centered Differentiation. The software that was used for this mobile application is MIT App Inventor 2. The concept of Algorithm on Discrete Mathematics was applied in this project. This paper includes the pseudocodes for getting the true value of a given polynomial equation, true value derivative of a given polynomial equation and the first finite divided difference. Keywords—derivative; first finite divided difference; forward differentiation; backward differentiation; centered differentiation; MIT App Inventor; mobile application; algorithm; pseudocode I. INTRODUCTION MIT App inventor is a tool created to help aspiring app developers to build their own application right in the web browser. It is the beginner’s introduction to programming and making a mobile app that consists of a drag-and-drop building blocks [1]. All things needed to understand how the software works is included in their resources. The concept of algorithm from discrete mathematics and numerical differentiation from numerical methods will be implemented using the app inventor tool. Algorithm is a finite set of clear instruction or methods for performing a computation or to solve a problem. It can be implemented using a programming software (e.g. MATLAB, DevC) however the coding scheme for a certain programming software needs a correct command for it to be implemented and for this reason, a Pseudocode is used [2]. Pseudocode is considered to be the convention of any programming language that can be understood easily by humans to aid them on generating a program or code. The steps or instructions used to implement an algorithm are well described operations or statements in a pseudocode for it to be a non-specific programming language [2]. Finite Divided Difference is the approximation derived from Taylor series and is used to approximate certain problems numerically. Finite divided difference is commonly used in a problem with boundaries [3]. II. THEORETICAL CONSIDERATION A. Forward, Backward, and Centered Difference Finite difference is a topic from numerical method and is used to solve differential equation by using approximation and represented as: 𝑓′(𝑥𝑖) = 𝑓(𝑥 𝑖+1)−𝑓(𝑥 𝑖) 𝑥 𝑖+1−𝑥 𝑖 + 𝑂(𝑥𝑖+1 − 𝑥𝑖) (1) or 𝑓(𝑥𝑖) = ∆𝑓𝑖 ℎ + 𝑂(ℎ) (2) Where ∆𝑓𝑖 is the first forward difference and ℎ is the stepz size. The term ∆𝑓/ℎ is known as the first finite divided difference. The forward divided difference is derived from Taylor series, also backward difference approximation for the first derivative Eq. (3) and the centered difference approximation for the first derivative can also be derived Eq. (4) [3]. 𝑓′(𝑥𝑖) ≅ 𝑓( 𝑥𝑖)−𝑓( 𝑥𝑖−1) ℎ = ∇𝑓 ℎ (3) 𝑓′(𝑥𝑖) ≅ 𝑓( 𝑥𝑖+1)−𝑓( 𝑥𝑖−1) 2ℎ − 𝑂(ℎ2 ) (4) For a better understanding of the equations for forward, backward and centered difference, a graphical representation was shown in Fig. 1.
  • 2. Fig.1 A graphical depiction of forward (a), backward (b) and centered (c) finite-divided difference approximations of the first derivative [3] For the forward difference, we compute for the slope nearby the secant line (Approximation), the points (𝑥𝑖, 𝑓(𝑥𝑖)) and (𝑥𝑖+1, 𝑓(𝑥𝑖+1)). We choose a small number of ℎ which represents as the small change in 𝑥 and can be either positive or negative. Thus, it will give us the formula for forward difference [4]: 𝑓′(𝑥) = 𝑓(𝑥+ℎ)−𝑓(𝑥) ℎ (5) This is the same with backward difference, only differs with the position of the two points (𝑥𝑖−1, 𝑓(𝑥𝑖−1)) and (𝑥𝑖, 𝑓(𝑥𝑖)), giving us the formula for backward difference [4]: 𝑓′(𝑥) = 𝑓(𝑥)−𝑓(𝑥−ℎ) ℎ (6) Another formula to compute the slope nearby the secant line through the points (𝑥𝑖−1, 𝑓(𝑥𝑖−1)) and (𝑥𝑖+1, 𝑓(𝑥𝑖+1)), giving us the formula for centered difference [4]: 𝑓′(𝑥) = 𝑓(𝑥+ℎ)−𝑓(𝑥−ℎ) 2ℎ (7) It is more accurate to the true derivative value, if the given ℎ is much closer to 0 because as ℎ approaches to 0, the slope of the secant line will approaches the tangent line which is the true derivative line shown in Fig. 1. B. Approximation and Round-off Errors Numerical methods are the approximations for analytical solutions. Solutions that are derived manually will have some deviation thus producing errors [3]. Round-off error is the most known error when using numerical method. It happens when only a certain amount of significant digits are required to be presented. Learning how to determine or quantify error is a must in using numerical methods [3]. The following equations governs the quantification of an error: 𝑇𝑟𝑢𝑒 𝑉𝑎𝑙𝑢𝑒 = 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛 + 𝑒𝑟𝑟𝑜𝑟 (8) 𝐸𝑡 = 𝑇𝑟𝑢𝑒 𝑉𝑎𝑙𝑢𝑒 − 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛 (9) Where Et, true error, is the difference between the true value and the approximated value. Resulting for a relative true error: Ɛ 𝑡 = 𝐸 𝑡 𝑇𝑟𝑢𝑒 𝑉𝑎𝑙𝑢𝑒 𝑥 100% (10) Where Ɛt is the ratio between the true error with respect to the true value.
  • 3. III. DESIGN CONSIDERATIONS The design of this project is to calculate for the first derivative of a given polynomial equation in any order. It will also determine the percentage error of the forward, backward, and centered difference approximations of the first derivative to the true value of the first derivative using the concept of absolute and relative error. This mobile app is user friendly in a way that it tells the user how the calculator works where it is defined what the calculator is use for. It is show in Fig. 2 what the home screen looks like. Fig.2 Home Screen It has three buttons where it will lead the user to its preference, whether the details about the app, how to use the app, and the main objective of the app. On the “Definition” section shown in Fig. 3, it gives the description about Numerical Differentiation including the formulas that were used for the calculator. There is also a detail about the mobile app itself. Fig. 3 Definition Screen The “How to Use” button gives a specific example of a problem from the book [3] where it will tell the user how to use the calculator by telling what should be the input on the textboxes. It is shown in Fig. 4 what the screen looks like.
  • 4. Fig. 4 Tips Screen The last button “Calculator” will lead the user to the main objective of the mobile app shown in Fig. 5. It will ask the user for the polynomial, value of x, and the step size (ℎ). It is already shown in Fig. 4 how to do that. Then the user will click the “Solve” button and it will give the output below. Fig. 5 First Finite Divided Difference Calculator Screen Fig. 6 First Finite Divided Difference Calculator Process in mobile app Fig. 6 shows the process on how the calculator works. It’s only similar to what calculator really do, it only differs that in just one click it will solve for the true first derivative value, given the approximations and the relative error of each. In MIT App Inventor, it is important to know first how the program will work, and it is by making an algorithm. This design consists of four algorithms: First, determining how to get the polynomial evaluation of an equation, second, determining the numerical value of the first derivative polynomial, third, is by combining the two and the three approximations of the first derivative, and lastly, is the overall algorithm of the calculator. Alg. 1: Getting the polynomial evaluation PRE-CONDITION: polynomialeval (m1,m2,m3,...mn: polynomial coefficients which corresponds to mxn-1 , mxn-2 , mxn-3 ,…,mxn-n , value of x : integer) fx = 0 e = (n-1) to 0, decrement 1 for N = 1 to n y = mN * x(eN) fx = fx + y end POST-CONDITION: fx : Output the value of a polynomial evaluation Input the coefficients of a polynomial (any order) Input a value of x Input a value of step size (h) Click "Solve!" Output: True Value, Forward-Backward- Centered Difference Approximations, and Relative Error
  • 5. Alg. 2: Getting the first derivative of a polynomial PRE-CONDITION: polynomialderivative (m1,m2,m3,...,mn: polynomial coefficients which corresponds to mxn-1 , mxn-2 , mxn-3 ,…,mxn-n , value of x : integer) fxd = 0 e = (n-1) to 0, decrement 1 for N = 1 to n dy = eN*mN*(x(eN)-1 ) fxd = fxd + dy end POST CONDITION: fxd : Output the derivative value of a polynomial Alg. 3: Getting the approximations of the first derivative PRE-CONDITION: firstfinitedivideddifference (m1,m2,m3,...,mn: polynomial coefficients which corresponds to mxn-1 , mxn-2 , mxn-3 ,…,mxn-n , value of x and step size (h) : integers) fx = 0 fxd = 0 e = (n-1) to 0, decrement 1 forward = 0 backward = 0 for N = 1 to n y = mN * x(eN) dy = eN * mN * x(eN-1) fwd = mN * (x-h)(eN) bwd = mN * (x-h)(eN) fx = fx + y fxd = fxd + dy forward = forward + fwd backward = backward + bwd end forwarddiff = (forward-fx)/h backwarddiff = (forward-fx)/(-h) centerdiff = (forward-backward)/(2*h) POST CONDITION: forwarddiff, backwarddiff centerdiff : Output the forward, backward, and center differences Alg. 4: First Finite Divided Difference Calculator PRE-CONDITION: firstfinitedivideddifferencecalc (m1,m2,m3,...,mn: polynomial coefficients which corresponds to mxn-1 , mxn-2 , mxn-3 ,…,mxn-n , value of x and step size (h) : integers) fx = 0 fxd = 0 e = (n-1) to 0, decrement 1 forward = 0 backward = 0 for N = 1 to n y = mN * x(eN) dy = eN * mN * x(eN-1) fwd = mN * (x-h)(eN) bwd = mN * (x-h)(eN) fx = fx + y fxd = fxd + dy forward = forward + fwd backward = backward + bwd end forwarddiff = (forward-fx)/h backwarddiff = (forward-fx)/(-h) centerdiff = (forward-backward)/(2*h) forwardrelativeerror = absolute((forwarddiff- fxd)/fxd*100); backwardrelativeerror = absolute((backwarddiff- fxd)/fxd*100); centerrelativeerror = absolute((centerdiff-fxd)/fxd*100); POST CONDITION: forwarddiff, backwarddiff centerdiff : Output the forward, backward, and center differences IV. DATA AND RESULTS Algorithm is the process on how to solve a problem with the use of pseudocodes. In this section, it will give the results of the four algorithms that were formulated. It is given a polynomial equation of 2𝑥4 + 5𝑥3 − 6𝑥2 − 𝑥 + 3 at 𝑥 = 2 and step size ℎ = 0.1. The following tables demonstrates how the given algorithms work. TABLE I. ALGORITHM FOR GETTING THE POLYNOMIAL EVALUATION N mN eN x(eN) y fx 1 2 4 16 32 32 2 5 3 8 40 72 3 -6 2 4 -24 48 4 -1 1 2 -2 46 5 3 0 1 3 49 TABLE II. ALGORITHM FOR GETTING THE FIRST DERIVATIVE OF A POLYNOMIAL N mN eN (x(eN)-1 ) dy fxd 1 2 4 8 64 64 2 5 3 4 60 124 3 -6 2 2 -24 100 4 -1 1 1 -1 99 5 3 0 1 0 99
  • 6. TABLE III. ALGORITHM FOR GETTING APPROXIMATIONS OF THE FIRST DERIVATIVE N fx fxd forward backward forwarddiff backwarddiff centerdiff 1 32 64 38.8962 26.0642 - - - 2 72 124 85.2012 60.3592 - - - 3 48 100 58.7412 38.6992 - - - 4 46 99 56.6412 36.7992 - - - 5 49 99 59.6412 39.7992 106.412 92.01 99.21 TABLE IV. ALGORITHM FOR FIRST FINITE DIVIDED DIFFERENCE CALCULATOR N fxd forward diff backward diff centerdi ff ferror berror cerror 1 64 - - - - - - 2 124 - - - - - - 3 100 - - - - - - 4 99 - - - - - - 5 99 106.4 92.01 99.21 7.48% 7.06% 0.21% According to the calculations, we have come up to that answers by simply following the algorithm that was formulated. Using the Numerical Differentiation mobile app, it also come up with the same answers (shown in Fig. 7), verifying that the algorithms are correct. Fig. 7 Answer to the given example using the First Finite Divided Difference Calculator In the given problem, the true first derivative value is 99, and the approximations value for forward, backward, and centered differences are 106.412, 92.01, and 99.21, respectively. Those are only the approximated numerical value of the first finite divided difference the reason why a relative errors are included in the computations. V. ANALYSIS The results for getting the first finite divided difference are verified that the algorithms that were formulated are correct. As it was compared with the Numerical Differentiation mobile app, they have the same results. With the help of pseudocode, it became easier to code it by the use of blocks programming that the MIT App Inventor 2 use. VI. CONCLUSION In conclusion, MIT app inventor has been a great tool for helping app developers such as myself. It helps oneself cultivate their skills and knowledge to prepare and contribute for the growing demand for app developers. The use and application of one’s learning in an academia such as discrete mathematics (DISMATH) and numerical methods (NUMMETH) is not only limited to what they have tackled. It can be applied to many different ways such as this project. This project, had combined the two by applying a concept of DISMATH, in which the topic of algorithm, in another subject course such as NUMMETH. There are a lot of other things that can be solved or created by integrating inherited knowledge.
  • 7. APPENDIX A: HOME SCREEN BLOCKS APPENDIX B: DEFINITION AND TIPS SCREEN BLOCKS
  • 8. APPENDIX C: FIRST FINITE DIVIDED DIFFERENCE CALCULATOR SCREEN
  • 9. ACKNOWLEDGMENT The accomplishment of this final project in DISMATH would not be possible without the help of some people so the student would like to acknowledge with deep appreciation and gratitude the following persons: Engr. Melvin Kong Cabatuan, for teaching the concept of algorithms, making it understandable by giving detailed examples. Dr. Argel Bandala, for teaching the concept of Numerical Differentiation which gives me an idea how it will give relation to DISMATH. Paul Arroyo, for guidance and support throughout the hardships in making this paper. I also want to thank my family for understanding how busy I am to make this project be a success. And finally, I thank the Almighty God for giving me strength and knowledge, guiding me throughout the days of finishing this project. REFERENCES [1] "MIT App Inventor," 2012. [Online]. Available: http://appinventor.mit.edu/explore/about-us.html. [Accessed April 2016]. [2] K. H. Rosen, Discrete Mathematics and Its Applications, New York: McGraw-Hill, 2012. [3] S. C. Chapra and R. P. Canale, Numerical Methods for Engineering, New York: McGraw-Hill, 2010. [4] R. L. Burden and J. D. Faires, "Numerical Analysis," in Numerical Analysis, Ninth Edition, Boston, Brooks/Cole, Cengage Learning, 2011, pp. 174-182.