"aqtinstall" enables plotting in Python 3.14.3t by automating the installation of Qt binaries (e.g., PyQt6 ) , which are required by libraries like Matplotlib to render interactive graphs. It serves as a command-line alternative to the official Qt installer, facilitating the setup of necessary GUI frameworks, often in CI environments or specific Python versions. Dependency Management: It resolves and installs the required Qt components, allowing pip install matplotlib to function correctly for creating interactive plots. Version Compatibility: It can install specific, prebuilt Qt binaries compatible with the latest Python versions, such as 3.14, by targeting the required OS and compiler. Integration: The installed Qt libraries allow Matplotlib plots to be embedded directly into GUI applications, providing interactive, zoomable, and pannable figures.
$ sudo apt update
$ sudo apt install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev git gcc
$ curl -fsSL https://pyenv.run | bash
$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
$ echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(pyenv init -)"' >> ~/.bashrc
$ source ~/.bashrc
List versions: pyenv install --list
$ pyenv install 3.14.3t
Set global version
For python3.14.3t instead of PyQt6 install
$ pip install aqtinstall
in virtual environment of python3.14.3t
$ mkdir MULTITHREAD
$ cd MULTITHREAD
$ python3.14t -m venv .env
$ source .env/bin/activate
$ pip install aqtinstall
$ pip install --upgrade pip
$ pip install numpy matplotlib cxroots
import os
# Silence Qt font/logging warnings
os.environ["QT_LOGGING_RULES"] = "*.debug=false;qt.qpa.fonts.warning=false"
from cxroots import Circle
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
def count_zeros(f, df, contour_points):
"""
Counts zeros of f(z) within the region enclosed by contour_points.
f: The analytic function
df: The derivative of the function
contour_points: Array of complex numbers forming a closed loop
"""
# Evaluate f and f' at each point on the contour
fz = f(contour_points)
dfz = df(contour_points)
# Calculate the integrand: f'(z) / f(z)
integrand = dfz / fz
# Calculate dz (the difference between consecutive points)
dz = np.diff(contour_points, append=contour_points[0])
# Compute the contour integral using the trapezoidal rule
integral = np.sum(integrand * dz)
# The result should be an integer
return int(np.round((integral / (2j * np.pi)).real))
t = np.linspace(0, 2 * np.pi, 1000)
circle = 4 * np.exp(1j * t)
f = lambda z: 4*z**5 + 4*z**3 - 4*z + 9
df = lambda z: 20*z**4 + 12*z**2 - 4
print("The Argument Principle and the Logarithmic Derivative in Complex Analysis\n")
print("f(z) = 4*z**5 + 4*z**3 - 4*z + 9 ; df/dz(z) = 20*z**4 + 12*z**2 - 4\n")
print(f"Number of zeros in circle of radius 4: {count_zeros(f, df, circle)}\n")
# 2. Define a contour (e.g., a circle with radius 4 centered at 0)
C = Circle(0, 4)
# 3. Plot the contour itself to verify the search region
# 4. Find roots and plot them within the contour
roots = C.roots(f, df)
print(roots)
roots.show()
plt.show()
❯ cat complexPython9.py
import numpy as np
from cxroots import Circle
import os
# Silence Qt font/logging warnings
os.environ["QT_LOGGING_RULES"] = "*.debug=false;qt.qpa.fonts.warning=false"
import matplotlib
import matplotlib.pyplot as plt
def count_zeros(f, df, contour_points):
"""
Counts zeros of f(z) within the region enclosed by contour_points.
f: The analytic function
df: The derivative of the function
contour_points: Array of complex numbers forming a closed loop
"""
# Evaluate f and f' at each point on the contour
fz = f(contour_points)
dfz = df(contour_points)
# Calculate the integrand: f'(z) / f(z)
integrand = dfz / fz
# Calculate dz (the difference between consecutive points)
dz = np.diff(contour_points, append=contour_points[0])
# Compute the contour integral using the trapezoidal rule
integral = np.sum(integrand * dz)
# The result should be an integer
return int(np.round((integral / (2j * np.pi)).real))
t = np.linspace(0, 2 * np.pi, 1000)
circle = 4 * np.exp(1j * t)
f = lambda z: z**13 + 5*z + 2
df = lambda z: 13*z**12 + 5
print("The Argument Principle and the Logarithmic Derivative in Complex Analysis\n")
print("f(z) = z**13 +5*z +2 ; df/dz(z) = 13*z**12 + 5\n")
print(f"Number of zeros in circle of radius 4: {count_zeros(f, df, circle)}\n")
# 2. Define a contour (e.g., a circle with radius 4 centered at 0)
C = Circle(0, 4)
# 3. Plot the contour itself to verify the search region
# 4. Find roots and plot them within the contour
roots = C.roots(f, df)
print(roots)
roots.show()
plt.show()



No comments:
Post a Comment