Constructing a Computer Algebra System Capable of Generating Pedagogical Step-By-Step Solutions
Total Page:16
File Type:pdf, Size:1020Kb
DEGREE PROJECT IN COMPUTER SCIENCE AND ENGINEERING, SECOND CYCLE, 30 CREDITS STOCKHOLM, SWEDEN 2016 Constructing a Computer Algebra System Capable of Generating Pedagogical Step-by-Step Solutions DMITRIJ LIOUBARTSEV KTH ROYAL INSTITUTE OF TECHNOLOGY SCHOOL OF COMPUTER SCIENCE AND COMMUNICATION Constructing a Computer Algebra System Capable of Generating Pedagogical Step-by-Step Solutions DMITRIJ LIOUBARTSEV Examenrapport vid NADA Handledare: Mårten Björkman Examinator: Olof Bälter Abstract For the problem of producing pedagogical step-by-step so- lutions to mathematical problems in education, standard methods and algorithms used in construction of computer algebra systems are often not suitable. A method of us- ing rules to manipulate mathematical expressions in small steps is suggested and implemented. The problem of creat- ing a step-by-step solution by choosing which rule to apply and when to do it is redefined as a graph search problem and variations of the A* algorithm are used to solve it. It is all put together into one prototype solver that was evalu- ated in a study. The study was a questionnaire distributed among high school students. The results showed that while the solutions were not as good as human-made ones, they were competent. Further improvements of the method are suggested that would probably lead to better solutions. Referat Konstruktion av ett datoralgebrasystem kapabelt att generera pedagogiska steg-för-steg-lösningar För problemet att producera pedagogiska steg-för-steg lös- ningar till matematiska problem inom utbildning, är vanli- ga metoder och algoritmer som används i konstruktion av datoralgebrasystem ofta inte lämpliga. En metod som an- vänder regler för att manipulera matematiska uttryck i små steg föreslås och implementeras. Problemet att välja vilka regler som ska appliceras och när de ska göra det för att skapa en steg-för-steg lösning omdefineras som ett grafsök- ningsproblem och varianter av algoritmen A* används för att lösa det. Allt sätts ihop till en prototyp av en lösare vilken utvärderas i en studie. Studien var ett frågeformulär som delades ut till gymnasiestudenter. Resultaten visade att även fast lösningar skapade av programmet inte var lika bra som lösningar skapade av människor, så var de an- ständiga. Fortsatta föbättringar av metoden föreslås, vilka troligtvis skulle leda till bättre lösningar. Contents 1 Introduction 1 1.1 Problem statement . 1 1.2 Problem definition, scope and evaluation . 2 1.3 Layout of this document . 3 2 Related Work 5 2.1 Applications of computer algebra . 5 2.2 Computer algebra systems with step-by-step capabilities . 6 3 Computer Algebra Systems 9 3.1 A brief overview . 9 3.2 Construction of computer algebra systems . 9 3.2.1 Representation of primitive types . 9 3.2.2 Representation of mathematical formulas . 10 3.2.3 Algorithms . 12 3.2.4 Interface . 13 4 SymPy 15 4.1 Representation of mathematical formulas . 15 4.2 Creation of SymPy objects . 17 4.3 Algorithms . 18 4.4 Output . 19 5 Method 21 5.1 Considerations for a step-by-step CAS . 21 5.1.1 Pedagogical considerations . 21 5.1.2 Differences to normal CASs . 22 5.2 Overview of chosen method . 23 5.3 Modifications to SymPy . 25 5.3.1 Classes . 25 5.3.2 Termlists and Factorlists . 26 5.3.3 Object creation and canonical form . 27 5.3.4 Input . 28 5.3.5 Output . 29 5.4 Rules . 30 5.4.1 sortBoth . 31 5.4.2 simplifyTerms . 32 5.4.3 simplifyProduct . 33 5.4.4 groupPow . 33 5.4.5 eqRules . 33 5.5 Search . 34 5.5.1 Redefining the problem as a graph search . 34 5.5.2 Implicitly generating the graph . 35 5.5.3 Simplify . 36 5.5.4 ShowEquality . 38 5.5.5 Solve . 38 5.6 Interface . 39 6 Results 41 6.1 Evaluation . 41 6.2 Presentation of the results . 43 6.2.1 Result totals for questions 1 to 5 . 44 6.2.2 Result totals for questions 1 to 5 by different math courses . 48 6.2.3 Result totals for questions 1 to 5 by different high school years 50 6.2.4 Results for turing-type question 6 . 51 7 Discussion 53 7.1 Discussion of results . 53 7.2 Solution aesthetics and fairness . 54 7.3 Discussion of the questionnaire answers . 55 7.4 Further work . 55 7.5 Conclusion . 56 Bibliography 57 A Questionnaire 61 B Questionnaire Raw Results 69 C Search Algorithm Pseudocode 71 D Rules 73 D.1 Rules . 73 D.1.1 negAddToSub . 73 D.1.2 negNeg . 73 D.1.3 negDivNumer . 73 D.1.4 negDivDenom . 73 D.1.5 negTerms . 74 D.1.6 negPlusminusRewrite . 74 D.1.7 negPlusminus . 74 D.1.8 negMul . 74 D.1.9 negNegMul . 74 D.1.10 termsToCommonDenom . 74 D.1.11 termsOnSameDenom . 75 D.1.12 mulRemove0 . 75 D.1.13 mulRemove1 . 75 D.1.14 divRemove0 . 75 D.1.15 divRemove1 . 75 D.1.16 rewriteMulOnDiv . 75 D.1.17 divMulDiv . 76 D.1.18 divDivDiv . 76 D.1.19 divDivMul . 76 D.1.20 mulDivDiv . 76 D.1.21 shortenFactorsSamediv . 76 D.1.22 mulInto . 77 D.1.23 mulTermsFull . 77 D.1.24 distrQuadPosNeg . 77 D.1.25 distrQuadPosPos . 78 D.1.26 distrQuadNegNeg . 78 D.1.27 powExpand . 78 D.1.28 breakOut . 78 D.1.29 factorizePoly . 78 D.1.30 factQuadPosNeg . 79 D.1.31 factQuadPosPos . 79 D.1.32 factQuadNegNeg . 79 D.1.33 simplifyPow . 79 D.1.34 simplifyPowFrac . 80 D.1.35 simplifyPowFracNeg . 80 D.1.36 powFracRewrite . 80 D.1.37 powPow . 80 D.1.38 powRoot . 80 D.1.39 powRemove1 . 80 D.1.40 divPowToPowneg . 80 D.1.41 sqrt0 . 81 D.1.42 simplifyRoot . 81 D.1.43 rootNegImg . 81 D.1.44 simplifyRootFrac . 81 D.1.45 rootFracTopNeg . 81 D.1.46 rootFracBotNeg . 81 D.1.47 rewriteRootFrac . 81 D.1.48 rootPow . 82 D.1.49 plusminusSplitRename . 82 D.1.50 pqFormula . 82 Chapter 1 Introduction 1.1 Problem statement Math education in schools (primary school and high school) teaches new concepts by first providing a theoretical explanation of the concept, then showing a few examples and finally the students practice the concept by solving problems related to the concept. However, for some students that may not be enough, as they may get stuck on the problem solving part. The text book only has the answer, and the student may wonder how that answer was reached. The answer might give a clue to how to solve it, but it is not very pedagogical. Furthermore, if a student did solve the problem, he or she can see that the answer is correct, but does not get any feedback on the solution unless the teacher manually checks it. The root of the problem is that manually producing pedagogical solutions to every math problem in a text book is time consuming, and would most likely re- quire the solutions to be printed in a separate book, making the whole package significantly more expensive. A way of solving this problem is through automation with a program that could solve mathematical problems and return the solutions. This would allow the creators of math text books, or independent companies, to efficiently create solutions to many problems quickly. Such a program could also be useful in the hands of students as that would allow on-demand solution generation and eliminate the problem of having to publish the solutions. However, a balance has to be established between study help and protection against cheating, as some students would inevitably use it to simply get done with their homework. The goal of this thesis is to design and construct a program that can solve this problem, i.e. automatically generate pedagogical solutions to math.