Assignment - 17-02-2025 - Jupyter Notebook
Assignment - 17-02-2025 - Jupyter Notebook
reg no:2240205
In [6]: 1 #### 1) Code with comments
2
3 from sympy import * # Import the sympy library for symbolic mathematics
4 x, y, z = symbols("x, y, z") # Define symbols x, y, z for symbolic computation
5
6 def u_giu(u): # Define a function to find the analytic function given the real part
7 ux = diff(u, x) # Compute the partial derivative of u with respect to x
8 print("ux=", ux) # Print the partial derivative ux
9 uy = diff(u, y) # Compute the partial derivative of u with respect to y
10 print("uy=", uy) # Print the partial derivative uy
11 fp = simplify(ux - 1j * uy) # Compute the complex derivative f'(z) = ux - i*uy
12 print("f'(x,y)=", str(fp)) # Print the complex derivative f'(z)
13 g = fp.subs({x: z, y: 0}) # Substitute x with z and y with 0 to get f'(z, 0)
14 print("f'(z,0)=", g) # Print the derivative f'(z, 0)
15 f = integrate(g, z) # Integrate f'(z, 0) with respect to z to get f(z)
16 return "f=" + str(f) # Return the analytic function f(z)
17
18 def v_giu(v): # Define a function to find the analytic function given the imaginary
19 vx = diff(v, x) # Compute the partial derivative of v with respect to x
20 print("vx=", vx) # Print the partial derivative vx
21 vy = diff(v, y) # Compute the partial derivative of v with respect to y
22 print("vy=", vy) # Print the partial derivative vy
23 fp = simplify(vy + 1j * vx) # Compute the complex derivative f'(z) = vy + i*vx
24 print("f'(x,y)=", str(fp)) # Print the complex derivative f'(z)
25 g = fp.subs({x: z, y: 0}) # Substitute x with z and y with 0 to get f'(z, 0)
26 print("f'(z,0)=", g) # Print the derivative f'(z, 0)
27 f = integrate(g, z) # Integrate f'(z, 0) with respect to z to get f(z)
28 return "f=" + str(f) # Return the analytic function f(z)
29
30
31
32
In [7]: 1 #Problem 2
2
3 # Define the imaginary part v(x, y)
4 v = -2 * sin(x) * (exp(y) - exp(-y))
5
6 # Use the v_giu function to find the analytic function f(z)
7 F = v_giu(v)
8 print(F)
ux= 2*x
uy= -2*y
f'(x,y)= 2.0*x + 2.0*I*y
f'(z,0)= 2.0*z
'f=1.0*z**2'
In [ ]: 1