0% found this document useful (0 votes)
12 views2 pages

Assignment - 17-02-2025 - Jupyter Notebook

The document contains Python code using the sympy library to compute analytic functions from given real and imaginary parts. It defines two functions, u_giu and v_giu, which calculate the complex derivative and integrate to find the analytic function. The code also includes examples demonstrating the use of these functions with specific mathematical expressions.

Uploaded by

fractaldiffusion
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

Assignment - 17-02-2025 - Jupyter Notebook

The document contains Python code using the sympy library to compute analytic functions from given real and imaginary parts. It defines two functions, u_giu and v_giu, which calculate the complex derivative and integrate to find the analytic function. The code also includes examples demonstrating the use of these functions with specific mathematical expressions.

Uploaded by

fractaldiffusion
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment_17-02-2025 ¶

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)

vx= (-2*exp(y) + 2*exp(-y))*cos(x)


vy= (-2*exp(y) - 2*exp(-y))*sin(x)
f'(x,y)= (2.0*I*(1 - exp(2*y))*cos(x) - 2*(exp(2*y) + 1)*sin(x))*exp(-y)
f'(z,0)= -4*sin(z)
f=4*cos(z)
In [8]: 1 # given problem
2 F=u_giu(x**2-y**2)
3 display(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 ​

You might also like