Interactive Calculus

Muhammad Akhtar, El Paso Community College, Mathematics
Author Profile

Summary

In this assignment, students will develop a calculus application in MATLAB that can perform the following tasks:
1. Input Function: Prompt the user to enter a mathematical function in a single variable, x.
2. Derivative Calculation: Compute the derivative of the input function f(x) and display the result as f'(x).
3. Integral Calculation: Determine the integral of the input function f(x) and display the result as the integral f(x).
4. Visualization: Generate plots of the input function f(x), its derivative f'(x), and the integral of f(x) on the same xy-plane. Clearly label the plots with the corresponding function names: f(x), f'(x), and Integral.
5. Output Display: Display the input function f(x), its derivative f'(x), and the integral of f(x) in a clear and organized manner.


Learning Goals

Upon successful completion of this assignment, students will:
1. Gain hands-on experience in writing MATLAB scripts, enabling them to confidently apply the software for a variety of mathematical tasks.
2. Develop proficiency in accessing and utilizing MATLAB's comprehensive collection of mathematical functions, thereby enhancing their problem-solving capabilities.
3. Acquire the foundational MATLAB skills essential for tackling more complex engineering projects in future courses.

Context for Use

This interactive calculus activity can be completed either online or at home. It is designed for students who are currently enrolled in or have previously taken a calculus course in single-variable calculus. No prior MATLAB programming experience is required, as the activity will introduce the fundamentals of MATLAB programming.

Description and Teaching Materials

Students will develop a MATLAB script that performs the following tasks:

1. Utilize the dlgtitle function to create a title for a prompt and request the user to input a function f(x).

2. Employ the syms function to define the variable x as a symbolic expression.

3. Store the input function in the variable fx.

4. Calculate the derivative of fx using the diff() function and store the result in the variable derivativefx.
5. Determine the integral of fx using the int() function and assign the result to the variable integralfx.

6. Display the input function fx, the derivative derivativefx, and the integral integralfx.

7. Create a plot of the input function fx, its derivative derivativefx, and the integral integralfx on the same xy-plane using the plot function.

8. Label the plot with the corresponding function names: f(x), f'(x), and Integral.

9. Test the program with the following functions:
a. x^2
b. xsin(x)
c. (x+2)/(x+1)
10. Submit the MATLAB script along with the output for each test case.


Interactive Calculus with MATLAB (Acrobat (PDF) 153kB Nov13 23)



Teaching Notes and Tips

Considering that students may have limited or no prior MATLAB experience, provide them with an introductory overview of the following fundamental MATLAB concepts:
1. Writing, Running, and Saving MATLAB Scripts: Guide students through the process of writing MATLAB scripts using the MATLAB editor. Explain how to execute scripts and save them for future use.
2. Invoking the Symbolic Toolbox: Introduce the Symbolic Math Toolbox, a powerful MATLAB tool for manipulating symbolic expressions. Demonstrate how to activate the toolbox and utilize its functions.
3. Using Built-in Mathematical Functions: Familiarize students with essential MATLAB functions for mathematical operations, including differentiation (diff()), integration (int()), substitution (subs()), and limit evaluation (limit()).
4. Plotting Functions: Illustrate the use of the plot() function to create graphical representations of mathematical functions. Guide students through the process of generating plots and customizing their appearance.
5. Answering Questions in a Flash: Encourage students to actively engage with the learning material by posing questions and providing prompt, clear answers. This interactive approach will reinforce their understanding of MATLAB concepts.

Assessment

Verify that the program functions as intended:
1. Input Validation: The program should accept valid input without any errors. It should handle invalid input formats or values gracefully and provide informative error messages.

2. Correct Function Display: The program should accurately display the input function f(x), its derivative f'(x), and its integral ∫ f(x) dx. The expressions should be formatted appropriately using proper mathematical symbols.

3. Accurate Plot Generation: The program should generate a plot that faithfully represents the input function f(x), its derivative f'(x), and its integral ∫ f(x) dx. The plot should include clear labels for each function, appropriate axis scales, and a consistent visual style.

References and Resources

COMPUTER PROGRAMING WITH MATLAB by J. MICHAEL FITZPATRIC AND AKOS LEDECZI, 1ST REVIZED PDF EDITON