Lab 3
Exercise 1: Symbolic Differentiation
Define the symbols (x), (y), and (z) using SymPy.
Define the expression ( f(x, y) = x^3 \sin(y) + e^{x^2 \cdot y} ).
Compute the following derivatives:
Partial derivative of (f) with respect to (x).
Partial derivative of (f) with respect to (y).
Mixed partial derivative (\frac{\partial^2 f}{\partial x \partial y}).
Evaluate the second partial derivative (\frac{\partial^2 f}{\partial y^2}) at (x = 1) and (y = \pi/4).
Consider the plane curve defined by p(x,y) = x^4 y^2− x^2y^3 + x-y = 0. Locally at the point (1, 1), we view y
as a function of x, that is: as y(x). What is the value for y'(1)?
Exercise 2: Higher-Order and Unevaluated Derivatives
Define the expression ( g(x) = x^6 + 4x^4 - 2x^2 + 1 ).
Compute the second, third, and fourth derivatives of (g(x)).
Create an unevaluated derivative for ( \frac{d^5}{dx^5} g(x) ) using the Derivative class.
Evaluate the unevaluated derivative from step 3 using doit() and confirm the result.
Find and plot the critical points of (g(x)) within the interval ([-2, 2]).
Exercise 3: Symbolic Integration
Define the expression ( h(x) = x^3 + \cos(x) ).
Compute:
The indefinite integral of (h(x)).
The definite integral of (h(x)) over ([0, \pi]).
Define a new expression ( p(x) = x^2 e^{-x^2} ) and compute its improper integral over ([0, \infty)).
Solve for ( C ) such that the integral of ( h(x) + C ) over ([0, \pi]) equals 10.
Exercise 4: Series Expansion
Define the expression ( f(x) = \cos(x) \cdot e^x ).
Compute the Taylor series expansion of (f(x)) around (x = 0) up to the 8th order.
Define the expression ( g(x) = \ln(1 + x^2) ). Compute its asymptotic expansion as (x \to \infty) up to 4 terms.
Truncate the Taylor series from step 2 by removing the (O(x^n)) term and write the resulting polynomial explicitly.
Exercise 5: Solving Differential Equations
Define the second-order ODE ( y'' - 2y' + y = 0 ).
Solve the ODE symbolically and display the general solution.
Solve the ODE with initial conditions:
( y(0) = 1 )
( y'(0) = 0 ).
Plot the solution with initial conditions using lambdify and matplotlib.
Exercise 6: Systems of ODEs
Define the coupled system:
[
y_1'(x) = y_1(x) + y_2(x), \quad y_2'(x) = -y_1(x) + 2y_2(x)
]
Solve the system symbolically using dsolve.
Extract and manipulate the solutions for (y_1(x)) and (y_2(x)).
Verify the solutions satisfy the original system using checkodesol.