Образователни технологии

INTEGRATED LESSONS IN CALCULUS USING SOFTWARE

Отворен достъп

https://doi.org/10.53656/math2023-4-4-int

Резюме. Today, both secondary and higher education cannot be effective without the use of innovative technologies. Therefore, all pedagogical workers try to use modern means of organizing educational activities, which cover the entire learning process from defining the goal to reaching the results.This article proposes to consider one of the methods of conducting integrated classes with a combination of analytical computing and specific software application. The above considerations can help students more effectively master the complex theoretical material of the calculus course. The article aims to consider some methods of studying and interpreting the theory of calculus using the free computer mathematics system Maxima and the Python language.

Ключови думи: calculus; computer mathematics system; Maxima; Python; differential calculus; integration

1. Introduction

Twenty years ago, many ministries of education put forward the following theses to teachers: “The main task of the \(21^{\text {st }}\) century is the modernization of education. Education must acquire an innovative character. Information technologies open up new opportunities for knowledge of human activities, etc.” Since then, many changes and amendments have been made to the curricula and programs of secondary and higher schools. However, there are still many discussions on the development of methodological concepts and approaches to studying, first, subjects of the natural and scientific cycles. In particular, this also applies to modern mathematics, since it already acts not only as a branch of knowledge but also as a powerful method of scientific knowledge in other sciences.

The use of innovative technologies in the educational process is already an integral part of the modern world. This is especially true when teaching fundamental disciplines for IT specialties. For many teachers several years of experience show that conducting integrated classes with a combination of analytical calculations and software helps students master the complex theoretical material of higher mathematics.

Figure 1

This article discussed using the Maxima software environment and the Python programming language to study the course of theoretical and practical calculus effectively. A computer algebra system (CAS) is a multifunctional software tool that can perform mathematical operations with data in symbolic or numerical form and create visualizations of data and calculation results. Using CAS, it is possible to avoid cumbersome calculations when solving typical mathematical problems, such as calculating the values of functions, solving equations and inequalities and their systems, and constructing various graphs.

Figure 2

Commercial programs such as Maple, Wolfram Mathematica, MATLAB, MathCad, etc. are among the most well-known CASs, and Axiom, FriCAS, Maxima, Reduce, etc. are freely distributed CASs. However, when studying mathematical disciplines, students should prefer using free programs, specifically Maxima \({ }^{1}\). Maxima is a universal CAS that can solve various mathematical problems. For example, this program allows performing various transformations of expressions, such as simplification, substitution, graphing, finding limits of functions, differentiation, calculating indefinite and definite integrals, expansion of functions into series, etc. (De Souza et al. 2004). Among the main advantages of using Maxima \({ }^{1}\), in addition to open access, is a user-friendly interface with built-in menus for basic mathematical operations. Also, a significant advantage is the availability of versions of Windows, Mac OS X, Linux, and Android \({ }^{1}\). The issues of using the Maxima system in solving calculus problems have been studied by many authors, in particular (Fauzi et. al. 2012); (Karjanto 2021); (Karjanto & Husain 2021).

Figure 3

An additional tool for visualization and practical implementation of the theory of mathematical analysis is the object-oriented programming language Python \({ }^{2}\). Python has a set of structured programming constructs and contains many libraries for scientific calculations. A significant advantage over other programming environments is that Python is available on various platforms, including Linux. The use of Python in teaching calculus was considered in articles (Pereira Junior et al. 2022); (Park et al. 2019); (Vanderplas & Schanafelt 2017).

2. Aim of the study

This article proposes to raise the question of the methodology of teaching the theoretical course of mathematical analysis so that its study is more accessible and exciting to students and rationally combines the logical rigor of the discipline and its visibility. In this article, we focus only on some aspects of the mathematical analysis course and consider visualization of some theoretical concepts, statements, and formulas of calculus, as well as how to solve practical tasks using various application programs.

3. Results and Discussion

Limits of Sequences and Functions using Python. The course of calculus usually starts with studying the theory of real numbers. However, since students easily understand this topic, we do not focus on it. The next step is to study the theory of numerical sequences. For the student to better learn the concepts and properties of infinitely small and large numerical sequences, it is worth considering tasks of various types. Thus, along with studying various purely technical methods of calculating limits, it is advisable to offer students the task of visualizing the convergence of the sequence in the figure and calculating the limit with a given accuracy.

Example 1. Evaluate \(\lim _{n \rightarrow \infty} \tfrac{3 n^{2}-4 n+1}{n-2 n^{2}+9}\).

Compiling a small code in Python, it is possible to demonstrate stable dynamics of behaviour already for the first twenty elements of the numerical sequence \(\tfrac{3 n^{2}-4 n+1}{n-2 n^{2}+9}\). From fig. 1 the student can determine the limit value of the sequence.

Example 2. When studying monotonic sequences and the number \(e\), it is possible to demonstrate to students the calculation of the number \(e=\lim _{n \rightarrow \infty}\left(1+\tfrac{1}{n}\right)^{n}\) with good accuracy by compiling the code in Python in several lines (fig. 2).

When studying the limit of a function at a fixed point, continuity and uniform continuity of a function, the teacher can also demonstrate these concepts in pictures. For example, Python tools (and functions of the matplotlib.pyplot library) can visually show the convergence of points on the graph to the limit value of the function.

Example 3. Draw a limit graphically: \(\lim _{x \rightarrow-1} \tfrac{x+1}{\sqrt{6 x^{2}+3 x+3}}\).

To solve the problem in the unit neighbourhood of the point \(x=-1\), we consider a sequence of points that converge to their limit value 1 and calculate the value of the function \(f(x)\) at these points. We mark the obtained coordinates (red dots in the fig. 3) on the function graph (blue colour).

In addition, students can be offered various tasks for evaluating limits of numerical sequences and the limits of functions at a fixed point using Python (for this, the appropriate functions of the SymPy library) and Maxima are used.

Derivative Visualization in Maxima. The study of differential calculus should begin with the visualization of the geometric interpretation of the derivative. Let us consider the graph of a function \(y=f(x)\) at the neighbourhood of point \(x_{0}\). At the indefinite approach of point \(P\left(x_{0}+\Delta x ; y_{0}+\Delta y\right)\) along the graph of a function \(y=f(x)\) to the point \(P_{0}\left(x_{0} ; y_{0}\right)\), the secant line \(P_{0} P\) approaches some limiting position, which is called a tangent to the curve \(f(x)\) at the point \(P_{0}\) ( (Denisiuk et al. 2009).

Example 4. Let us demonstrate the geometric content of the derivative for the function \(y=x^{2}-4 x+10\) at the point \(x_{0}=4\).

To solve this problem, we construct a family of secants and tangents at a point to the graph of this function at the point \(x_{0}=4\). To find the equations of the secant and the tangent to the graph of the function \(y=x^{2}-4 x+10\) at the point \(x_{0}\) and plot the graphs, let us use the CAS Maxima.

First, let us construct a equation of the tangent line of the form \(y=k x+b\). The slope \(k\) of the tangent line of \(f(x)=x^{2}-4 x+10\) is given by taking the limit as \(\Delta x\) goes to 0 for the point \(x_{0}=4\) :

\[ k=f^{\prime}\left(x_{0}\right)=\lim _{\Delta x \rightarrow 0} \tfrac{f\left(x_{0}+\Delta x\right)-f\left(x_{0}\right)}{\Delta x}=4 \]

Next, substituting the found value \(k=4\) into the equation of the tangent line, we get the equation \(y=4 x-6\). Implementing this procedure in Maxima using the command limit (expr, \(x\), val) to find the limit of the expression expr as the real variable \(x\) approaches the value val (Salz 2022), we obtain the dialog from fig. 4:

Figure 4

Let us now construct the family of secant lines for the graph of the function \(y=x^{2}-4 x+10\), which pass through points \(\left(x_{0} ; y_{0}\right)\) and \(\left(x_{1}=4 x+h ; y_{1}\right)\), by using the equation \(y=m\left(x-x_{0}\right)+y_{0}\), where \(m=\tfrac{y_{1}-y_{0}}{x_{1}-x_{0}}\) is the slope. In the Maxima program, using the ratsimp(expr) command to the expression expr (Salz 2022), we get the general equation for this family of secant lines as shown on fig. 5.

We see that, as the values of \(\left(x_{1} ; y_{1}\right)=(4+h ; y(4+h))\) approach \(\left(x_{0} ; y_{0}\right)=(4 ; 10)\), the secant lines themselves approach the tangent line to the function \(y=x^{2}-4 x+10\) at \(x_{0}\), which represents the limit of the secant lines. As the values of \(h=1.5,0.5,0.05\) get closer to 0, the secant lines also approach the tangent line \(y=4 x-6\) (red line in fig. 6). The graphical representation was obtained using the command wxplot2d(explicit(f(x),x,xmin,xmax)) (Salz 2022).

Figure 5

Figure 6

Applications of Derivatives in Python. The Taylor and Maclaurin formulas and later the Taylor/Maclaurin series are studied in the section on applications of the derivative, particularly for approximate calculations. For students to better understand the possibility of replacing some functions with a \(n\)th degree polynomial (\(n\) is a nonnegative integer), the figure can demonstrate the gradual polynomial approximation of corresponding functions in the neighbourhood of zero.

Example 5. Let us demonstrate the graphical approximation of the Maclaurin series to the function \(\cos (3 x)\) in the neighbourhood of zero. Namely, by using the constructed graph, we verify the equality:

(1)\[ \cos (3 x)=1-\tfrac{(3 x)^{2}}{2!}+\tfrac{(3 x)^{4}}{4!}-\cdots+(-1)^{m} \tfrac{(3 x)^{2 m}}{(2 m)!}+\cdots \]

We gradually increase the number of terms on the right-hand side to solve the problem and construct corresponding graphs of polynomial functions. It can be seen that when the number of terms in the polynomial increases, the partial sums on the right of (1) converge to the left-hand side near 0.

We get the result shown on fig. 7.

Figure 7

This figure was obtained by compiling a Python program using the matplotlib. pyplot library.

Applying Maxima for Integration. When studying integral calculus for students of IT programs, along with analytical calculations, it is worth showing methods of calculating integrals using computer algebra systems.

Using the Maxima system, it is possible to compute indefinite integrals and find antiderivatives using symbolic representation. In general, integrate(\(f(x), x\) ) is a command that most users can easily use to compute various basic integrals \(\int f(x) d x\) (Salz 2022). In Maxima, it is possible to find indefinite integrals from various types of integrands using only this command, in particular from the simplest irrational expressions and differential binomials. However, when integrating some irrationalities, for example, integrals of the form

\[ \int R\left(x, \sqrt{a x^{2}+b x+c}\right) d x \text { and } \int R\left(x, X^{r_{1} / s_{1}}, \cdots, X^{r_{n} / s_{n}}\right) d x, \] where \(\mathrm{R}(\cdot)\) is a rational function, \(X=(a x+b) /(c x+d), r_{i} / s_{i}, i \geq 1\) are fractions, the Maxima system does not immediately provide an answer. In such cases, it is necessary to use a standard integration method, such as the substitution technique.

Example 6. Find \(\int \tfrac{d x}{\sqrt{(x-1)(x-2)^{3}}}\).

The Maxima system does not show the antiderivative when using the integrate command directly (fig. 8). Instead, it converts the entry from the previous command to the specified indefinite integral (fig. 9).

Figure 8

However, after simplifying the integral function using the radcan(expr) command, where expr is an expression containing logs, exponentials, and radicals, we got an integral that can already be computed using the integrate command. The % symbol indicates that the radcan command is applied to the last line.; nouns causes the evaluation of noun forms (typically unevaluated functions such as integrate or diff) in expr.

Example 7. Find \(\int \tfrac{d x}{2 x+\sqrt[3]{(x-1) x^{2}}}\).

Figure 9

This integral is the integral of an irrational function and is found analytically by changing the variable. As can be seen, the direct application of the integrate command, even with the radcan simplification command, does not show the original (fig. 10). To solve this problem, we need to use the substitution rule in Maxima.

Figure 10

A function changevar (expr, \(G(x, t), t, x\) ) (Maxima 5.46.0. Manual 2022) makes the change of variable in a given noun form integrate expression such that the old variable of integration is \(x\), the new variable of integration is \(t\), and \(x\) and \(t\) are related by the equation \(G(x, t)=0\).

We use the substitution \((x-1) / x=t^{3}\), revealing the irrationality using the changevar command since it is impossible to express \(x\) in terms of \(t\) with the help of Maxima if there is a radical expression (fig. 11). As a result of this substitution, the CAS shows a new integral of the variable \(t\) in a non-calculable form. To compute such an integral, we need to enter the %, nouns command from the keyboard.

Figure 11

Also, in the Maxima system, many additional packages are designed for solving various mathematics problems. In particular, among them is the package bypart. mac, which contains the command of /integration by parts for an indefinite integral, that is, using the formula \(\int f(x) d x=\int u d v=u v-\int v d u\) (Strang G.1991). This command has the form byparts(\(\left.f(x), x, u(x), v^{\prime}(x)\right)\) (Maxima 5.46.0. Manual 2022); as a result, the antiderivative of function \(f(x)\) is displayed.

Figure 12

Example 8. Find \(\int x^{3} \ln x d x\).

To use the bypart.mac package, we need to preload it using the load(bypart) command. Next, in the description of the byparts command, we specify the integrand \(f\), the variable of integration \(x\), the functions \(u=\ln x\) (we choose a function between \(x^{3}\) and \(\ln x\), which is easier to differentiate than to integrate) and \(v^{\prime}(x)=x^{3}\). After the Shift+Enter combination, we obtain the result of integration by parts (fig. 12).

The application of Maxima is also convenient when studying the topic „Integrating of rational functions“. When integrating rational expressions of the form \(\int P(x) / Q(x) d x\), where \(P(x)\) and \(Q(x)\) are polynomials, the Maxima system also uses the integrate command. However, it is often advisable to perform elementary transformations using the functions built into the package before using it in an integrand. For example, the partfrac \((f(x), x)\) command expands the expression \(f(x)\) in partial fractions with respect to the main variable \(x\).

Example 9. Find ∫𝑥5 /(𝑥3 −1)𝑑𝑥. Find \(\int x^{5} /\left(x^{3}-1\right) d x\).

After using the partfrac command to decompose the integral \(x^{5} /\left(x^{3}-1\right)\), let us integrate the resulting expression using the main integrate command (fig. 13).

Figure 13

Figure 14

Finding the Indefinite Integral in Python. In order to computethe indefinite integral in symbolic form, the SymPy library in Python is used (Vanderplas & Schanafelt 2017). SymPy is a powerful Python symbolic mathematics library that can be considered a full-featured computer algebra system. SymPy has various functions in symbolic computation, calculus, statistics, algebra, discrete mathematics, combinatorics, and physics. In particular, SymPy contains methods for computing indefinite, definite, and improper integrals. The integrate() command is used for such tasks. Let us give several ways to computeindefinite integrals.

Example 10. Find ∫(𝑥3−2𝑥2+12)𝑑𝑥. Find \(\int\left(x^{3}-2 x^{2}+12\right) d x\).

The process of finding such an integral in Python is as shown on fig. 14.

Figure 15

Example 11. Find \(\int \tfrac{x^{5}}{x^{3}-1} d x\).

Similarly, we get in Python as shown on fig. 15.

Figure 16

However, the integrate () command does not integrate all functions. Similar to Maxima, integrals to which substitution rule or integration by parts is to be applied must be prepared first and then proposed the substitution. In such cases, models: sympy.sympify(),sympy.integrals.transforms() are used.

Calculating Definite Integrals with Maxima. To evaluate definite integrals \(\int_{a}^{b} f(x) d x\) in the Maxima package, use the integrate \((f(x), x, a, b)\) command.

Example 12. Evaluate the integral \(\int_{\pi / 6}^{\pi / 4} \tfrac{d x}{\cos ^{2} x}\).

Let us computethe integral using the integrate command (fig. 16).

As described above, in the Maxima system, the changevar command is used for the substitution method in integration. When calculating definite integrals, it is also used for specific substitutions. First, the integral is displayed on the screen with a new variable \(t\) and new limits of integration, and then it is computed using the command %, nouns. As with finding indefinite integrals, it is helpful to use this formula to check the efficiency of using different substitutions and when it is not possible to find the integral directly using the integrate command.

Example 13. Evaluate the integral \(\int_{0}^{4} \tfrac{1}{1+\sqrt{x}} d x\).

Figure 17

After entering the integral with the integrate command, apply \(\sqrt{x}=t\) substitution using the changevar \((\%, \operatorname{sqrt}(x)=t, t, x)\) command (fig. 17). An apostrophe before a Maxima command indicates a gap in the integral calculation. Next, the system questions whether the new variable \(t\) is negative or positive. To answer this question, enter the first letter \(p\), which indicates positive values of the variable \(t\). The following appearing line already contains an integral with a new variable \(t\), and new limits of integration (found automatically). The last step is to use the %, nouns command to compute the result.

Evaluating Definite Integrals in Python. The SymPy library also is used to compute the definite integral in Python. However, since not all indefinite integrals can be computed in the symbolic form, and therefore not all definite integrals can be analytically computed, it is necessary to use the methods of their approximate calculation. For IT students, it would be interesting not only to compute integrals approximately but also to evaluate the accuracy of these approximations and to conclude which method gives more accurate results. For this purpose, it is possible to take such an integral, which is easily calculated analytically, and compute it on Python with various functions, then compare the results and conclude the method‘s accuracy.

Let us consider the most popular methods of numerical integration (Epperson 2013).

1. Right Riemann sums:

\[ \int_{a}^{b} f(x) d x \approx h \sum_{k=0}^{n-1} f\left(x_{k}\right), \text { where } h=\tfrac{b-a}{n}, x_{k}=a+k h \] with a calculation error \(\Delta \leq \tfrac{M_{1}(b-a)^{2}}{2 n}\), where \(\left|f^{\prime}(x)\right| \leq M_{1}\).

An alternative can be the formula for median rectangles:

(2)\[ \int_{a}^{b} f(x) d x \approx h \sum_{k=0}^{n-1} f\left(x_{k}+\tfrac{h}{2}\right) \]

with an error \(\Delta \leq \tfrac{M_{2}(b-a)^{3}}{24 n^{2}}\), where \(\left|f^{\prime \prime}(x)\right| \leq M_{2}\). This formula is generally more accurate.

2. The trapezoidal rule:

(3)\[ \int_{a}^{b} f(x) d x \approx h\left(\tfrac{f(a)+f(b)}{2}+\sum_{k=1}^{n-1} f\left(x_{k}\right)\right) \]

with an error \(\Delta \leq \tfrac{M_{2}(b-a)^{3}}{12 n^{2}}\), where \(\left|f^{\prime \prime}(x)\right| \leq M_{2}\).

3. Simpson’s rule:

\[ \int_{a}^{b} f(x) d x \approx \tfrac{h}{3}\left(f(a)+f(b)+2 \sum_{k=1}^{n-1} f\left(x_{2 k}\right)+4 \sum_{k=0}^{n-1} f\left(x_{2 k+1}\right)\right), \] where \(h=\tfrac{b-a}{2 n}, x_{k}=a+k h\), with an error \(\Delta \leq \tfrac{M_{3}(b-a)^{5}}{180 n^{4}}\), where \(\left|f^{(4)}(x)\right| \leq M_{3}\).

Let us implement these methods in Python.

Figure 18

Example 14. Evaluate the integral \(\int_{0}^{\sqrt{\pi / 2}} x \sin \left(x^{2}\right) d x\).

1) If we analytically calculate the given integral using the substitution rule, we get result

(5)\[ \int_{0}^{\sqrt{\pi / 2}} x \sin \left(x^{2}\right) d x=0.5 \]

2) Let us apply the Midpoint Rule in Python.

а) We use the ready-made quad function from the scipy.integrate package (fig. 18). It gives the result of integration and the accuracy of calculations.

b) Then we program formula (2) of the midpoint rule (fig. 19).

3) Let us use the trapezoidal rule (fig. 20).

a) If we compare with the result (5), we can see that the trapezoidal rule gives worse accuracy than the midpoint rule.

Figure 19

b) Then we program formula (3) of the trapezoidal rule (fig. 21).

We can see that the formula we programmed gives a better result than the ready-made trapz function.

4) Let us apply Simpson’s rule that is, formula (4) as shown on fig. 22. This method also gives a good result.

Figure 20

Therefore, comparing the analytically computed integral (5), we can conclude that the results obtained by the Median rectangles formula and Simpson’s rule are more accurate.

Figure 21

Figure 22

Conclusion

As we can see, a problem in calculus can be visualized using CAS tools or a programming language. There are two main aspects of CAS usage. The first aspect is direct visualization of the appropriate way of solving a particular problem for a better understanding of the use of the method to show its practical application. The second aspect is a significant saving of calculation time.

Depending on the numerical or symbolic task, the choice arises to choose the appropriate type of CAS. This is exactly what the teacher‘s role should be, that is, to guide the student in choosing the software that is most efficient and quickly able to solve the task. In the Maxima system, most mathematical analysis methods are already programmed. The user only needs to learn the appropriate syntax of the functions and use them properly. However, without understanding the mathematical methods used, it is not always possible to apply them correctly. There are several tasks where the user must first perform specific actions (transformation, simplification) to use the syntax of the corresponding Maxima function.

It is worth showing the capabilities of Python during learning of various fundamental disciplines from the very first year for students of IT specialties to gain programming skills and experience. In addition, thereby continue to develop the ability of students to program the formulas, methods or algorithms necessary to solve many mathematical problems.

Therefore, this article shows the capabilities of Maxima and Python and, accordingly, gives the student a choice for the applied application of the theory of calculus.

NOTES

1. MAXIMA. A Computer Algebra System, [viewed 13 January 2023]. Available from: https://maxima.sourceforge.io/index.html.

2. MAXIMA 5.46.0. Manual [viewed 13 January 2023]. Available from: https:// maxima.sourceforge.io/docs/manual/maxima_toc.html#SEC_Contents

REFERENCES

DE SOUZA, P.N., et al., 2004. The Maxima Book, [viewed 13 January 2023]. Available from: https://maxima.sourceforge.io/docs/maximabook/ maximabook-19-Sept-2004.pdf.

DENISIUK, V. P., et al., 2009. Higher mathematics. Part 1: Manual. Kyiv: NAU.

EPPERSON, J. F., 2013. An Introduction to Numerical Methods and Analysis, 2rd edition. Wiley.

KADO, K., 2022. A teaching and learning the fundamental of calculus through Python-based coding. International Journal of Didactical Studies, vol. 3, no. 1, 15006 [viewed 13 January 2023]. Available from: https://doi.org/10.33902/IJODS.202215006.

KARJANTO, N., 2021. Calculus and Digital Natives in Rendezvous: wxMaxima Impact. Educ. Sci., no. 11, рр. 490, [viewed 13 January 2023]. Available from: https://doi.org/10.3390/educsci11090490.

KARJANTO, N., HUSAIN, H.S., 2021. Not Another Computer Algebra System: Highlighting wxMaxima in Calculus. Mathematics, no. 9, pp. 1317 [viewed 13 January 2023]. Available from: https://doi.org/10.3390/math9121317.

MOHD AYUB, A.F. et al., 2012. WxMaxima Computer Software as an Aid to the Study of Calculus by Students with Different Learning Approaches, Procedia – Social and Behavioral Sciences, no. 64, рр. 467 – 473, [viewed 13 January 2023]. Available from: https://doi.org/10.1016/j. sbspro.2012.11.055.

PEREIRA JUNIOR, R.A., et al., 2022. Cálculo diferencial e integral evoluindo a inteligência computacional Mediante a linguagem Python de programação[in Portuguese][Differential and integral calculus evolving computational intelligence through the Python programming language]. Brazilian Journal of Development, vol. 8, no. 9, pp. 64737 – 64761 [viewed 13 January 2023]. Available from: https://doi.org/10.33902/ IJODS.202215006.

PARK, K.-E., et al., 2019. Teaching and Learning of University Calculus with Python-based Coding Education. Communications of Mathematical Education, vol. 33, no. 3, pp. \(163-180\) [viewed 13 January 2023]. Available from: https://doi.org/10.7468/JKSMEE.2019.33.3.163.

SALZ, S., 2022. CAS Maxima Workbook. [viewed 13 January 2023]. Available from: https://roland-salz.de/Maxima_Workbook.pdf.

STRANG, G., 1991. Calculus. Wellesley-Cambridge Press.

VANDERPLAS, J., SCHANAFELT, D., 2017. Python Data Science Handbook: Essential Tools for Working With Data. 1a ed. Sebastopol, CA: O‘Reilly Media.

Година LXVI, 2023/4 Архив

стр. 373 - 389 Изтегли PDF