Quiz: Symbolic Math in Python

Main.PythonQuiz17 History

Hide minor edits - Show changes to markup

May 18, 2022, at 03:38 AM by 10.35.117.248 -
Changed line 45 from:
Incorrect. The function returns the derivatives at the current time and state values, not the solution.
to:
Incorrect. Use sp.Symbol('x').
Changed line 52 from:
Incorrect. The user-defined function returns the derivatives at the requested time and state values.
to:
Incorrect. Use sp.Symbol('x')
Changed lines 86-87 from:
(:toggle hide q3a button show="Select":)

(:div id=q3a:)

to:
(:toggle hide q4a button show="Select":)

(:div id=q4a:)

Changed lines 93-94 from:
(:toggle hide q3b button show="Select":)

(:div id=q3b:)

to:
(:toggle hide q4b button show="Select":)

(:div id=q4b:)

May 18, 2022, at 03:37 AM by 10.35.117.248 -
Added lines 1-98:

(:title Quiz: Symbolic Math in Python:) (:keywords quiz, test, Python, plot, sympy, symbolic, equations, introduction, course:) (:description Learning assessment on symbolic math solutions with Python.:)


1. What are some of the SymPy Python package capabilities for symbolic math operations? Check all that apply.

A. Analytic (exact) derivatives
(:toggle hide q1a button show="Select":)

(:div id=q1a:)

Correct.

(:divend:)

B. Analytic (exact) definite integrals
(:toggle hide q1b button show="Select":)

(:div id=q1b:)

Correct.

(:divend:)

C. Analytic (exact) indefinite integrals
(:toggle hide q1c button show="Select":)

(:div id=q1c:)

Correct.

(:divend:)

D. Simplification
(:toggle hide q1d button show="Select":)

(:div id=q1d:)

Correct.

(:divend:)


2. In order to use the symbolic features of SymPy (import sympy as sp), a variable such as x must first be declared as follows (see help video):

A. x = sp.Variable('x')
(:toggle hide q2a button show="Select":)

(:div id=q2a:)

Incorrect. The function returns the derivatives at the current time and state values, not the solution.

(:divend:)

B. x = sp.Parameter('x')
(:toggle hide q2b button show="Select":)

(:div id=q2b:)

Incorrect. The user-defined function returns the derivatives at the requested time and state values.

(:divend:)

C. x = sp.Symbol('x')
(:toggle hide q2c button show="Select":)

(:div id=q2c:)

Correct.

(:divend:)


3. Analytic solutions are not exact.

A. True
(:toggle hide q3a button show="Select":)

(:div id=q3a:)

Incorrect. Numerical solutions are not exact. Analytic solutions are exact.

(:divend:)

B. False
(:toggle hide q3b button show="Select":)

(:div id=q3b:)

Correct. Numerical solutions are not exact. Analytic solutions are exact.

(:divend:)


4. Numerical solutions are typically an approximation of an exact solution.

A. True
(:toggle hide q3a button show="Select":)

(:div id=q3a:)

Correct. One example is to use a finite difference to calculate a derivative such as df(x)/dx = f(x1)-f(x0) / (x1-x0). As the difference between x1 and x0 decreases, the approximation become more exact until the limits of machine precision (number of decimal places that can be stored by a computer) introduces round-off or truncation error.

(:divend:)

B. False
(:toggle hide q3b button show="Select":)

(:div id=q3b:)

Incorrect. The exact analytic solution is often not possible, but the numeric error can be approximated and reduced to a specified level.

(:divend:)