c++ – Tengo un erro usando el comando mesh, el error es at 80 X, Y, Z, and C cannot be complex. en matlab

Tengo que graficar esta funcion, pero me da error.
Este es el codigo

  >> u=linspace(-2,2,200);
  >> v=linspace(-4,4,200);
  >> (x,y)=meshgrid(u,v);
  >> z=sqrt(16-4.*x.^2-y.^2);
  >> mesh(x,y,z)

  ??? Error using ==> mesh at 80
  X, Y, Z, and C cannot be complex.

introducir la descripción de la imagen aquí

Gracias de ante mano.

Plotting imaginary part on y-axis against real part on x-axis of complex momentum

I want to plot a complex momentum in complex plane where the y-axis shows imaginary values and x-axis shows the real values. I tried ReIm command but it plots Re and Im parts not Re vs Im.
Below is an example which plots Im and Re parts but I need Im vs Re. Any suggestions please?

Clear[m, M, s, t]
    m = 0.34
    M = 5;
    t = m^2 + M^2 - s/2 + 1/2 Sqrt[s - 4 m^2] Sqrt[s - 4 M^2];
    tplot = Plot[{Im@t, Re@t}, {s, 4 m^2, 4 M^2}, PlotRange -> All, 
      Frame -> True]

Complex conditional logic for Webform field

I have a complex scenario in Webforms, where field #states depends on multiple OR / AND conditional logic.

For Example:

field_d has a visibility condition where field_a must be filled and either of field_b or field_c must be filled. I am not sure how to proceed with that kind of Yaml logic. I have tried something like below but it seems not to work.

visible:

  ':input(name="field_a")':
      filled: true

  and

  (
  ':input(name="field_b")':
      filled: true

  or

  ':input(name="field_c")':
      filled: true
  )

Thanks.

python – PyQt5 developing complex Window GUI and making everything its own class

TLDR: Is my code following best practices for OOP and PyQt5 regarding inheritance, and is it okay to initialise classes within another class? What can I do to improve my methods, or what would be a better approach to my specific problem?

I’m very new to OOP and PyQt5. My Code creates a GUI with 2 tab widgets, each with multiple tabs, and each tab with its own layouts and widgets.

To make the code manageable (in my beginner opinion), I’ve turned everything into a class. The Window class handles the Window and Layout and creates instances of the tab widgets. The Tabs classes handle Tab layouts and create instances of tablets (pages). The Tablet class handles tablets and their layouts and adds widgets such as buttons, labels etc.

Window Layout

Versions:

python                 3.7.3
PyQt5                  5.15.4
PyQt5-Qt5              5.15.2
PyQt5-sip              12.8.1

CODE

"""
Initialises Window, Sets out the geometry management, and adds Widgets
"""
import sys

from PyQt5.QtCore import pyqtSignal, pyqtSlot
from PyQt5.QtWidgets import (
  QApplication, QGridLayout, QMainWindow, QTableWidgetItem, QWidget
)

from PyQt5.QtWidgets import (
  QComboBox, QFormLayout, QHBoxLayout, QVBoxLayout,
  QLabel, QPushButton, QTabWidget, QTableWidget, QWidget
)


class Window(QMainWindow):
    """Create an instance of Window. Sets up main Window"""
    # my_signal = pyqtSignal(int)
    def __init__(self):
        super().__init__()
        self.setMinimumSize(1000, 800)
        self.centralWgt = QWidget()  # create central widget
        self.setCentralWidget(self.centralWgt)  # set central widget
        self.tabIn = InputTab()  # create input tab widget
        self.tabOut = OutputTab()  # create input tab widget
        self.windowLayout()  # set window layout

        # TODO: Move this and "test" to a class to keep Window minimal
        self.tabIn.tablet1.btnApply.clicked.connect(self.test)

    def test(self):
        """
        When tabIn tablet1 btnApply pressed, Do something in tabOut tablet1
        """
        self.tabOut.tablet1.textGreeting.setText(“Hello”)
        print("Here!")

    def windowLayout(self):
        """Handles the main windows layout"""
        self.layout = QGridLayout()
        self.centralWgt.setLayout(self.layout)
        self.layout.addWidget(self.tabIn, 0, 1)  # Add widgets to layout
        self.layout.addWidget(self.tabOut, 1, 1, 2, 1)  # Add widgets to layout
        # Handle window and widget resizing
        self.layout.setColumnStretch(0, 1)
        self.layout.setColumnStretch(1, 1)
        self.layout.setRowStretch(0, 1)
        self.layout.setRowStretch(1, 1)
        self.layout.setRowStretch(2, 1)


# TAB MANAGEMENT


class Tabs(QTabWidget):
    """Tabs master class"""
    def __init__(self):
        super().__init__()
        self.tabs = QTabWidget()  # Initialise Tab Widget
        self.layout = QVBoxLayout()  # Define Tab Widget Layout
        self.setLayout(self.layout)  # Set Tab Widget Layout
        self.setStyleSheet('QTabBar { font-size: 12pt;}')  # Set tab title size


class InputTab(Tabs):
    """Creates and sets up the InputTab Class. Inherits from Tab Class"""
    def __init__(self):
        super().__init__()
        self.tablet1 = ItemTablet(QWidget())  # Initialise tablet
        self.tabs.addTab(self.tablet1, "Item Queries")  # Add tablet
        self.layout.addWidget(self.tabs)  # Add tablets to layout


class OutputTab(Tabs):
    """Creates and sets up the OutputTab Class. Inherits from Tab Class"""
    def __init__(self):
        super().__init__()
        self.tablet1 = TableTablet(QWidget())  # Initialise tablet
        self.tabs.addTab(self.tablet1, "Output - Item Table")  # Add tablet
        self.layout.addWidget(self.tabs)  # Add tablets to layout


# TABLET MANAGEMENT #


class Tablets(QTableWidget):
    """The Tablets master class. Contains shared methods, variables"""
    def __init__(self, widget):
        super().__init__()
        self.widget = widget  # set tablet widget as given widget type
        self.layout = QVBoxLayout()  # create tablet outer layout
        self.setLayout(self.layout)  # set tablet outer layout
        self.setStyleSheet('font-size: 10pt;')  # Set tablet font size

    def populateForm(self, formFields):
        """Populates a form layout with dict key value pairs"""
        for k, v in formFields.items():
            self.frmLayout.addRow(k, v)  # Add items to tablet form layout

    def stdButtons(self):
        """Adds Apply and Clear buttons to bottom of tablet."""
        self.btnApply = QPushButton(text="Apply")
        self.btnClear = QPushButton(text="Clear")
        self.btnLayout.addWidget(self.btnApply)
        self.btnLayout.addWidget(self.btnClear)

    def stdFormLayout(self):
        """Creates a Form with horizontal buttons at bottom"""
        self.frmLayout = QFormLayout()  # create tablet sublayout
        self.btnLayout = QHBoxLayout()  # create tablet sublayout
        self.layout.addLayout(self.frmLayout)  # set tablet sublayout
        self.layout.addLayout(self.btnLayout)  # set tablet sublayout


class ItemTablet(Tablets):
    """Handles Item Tablet"""
    def __init__(self, widget):
        super().__init__(widget)
        self.stdFormLayout()  # choose stdFormLayout as a sublayout
        self.stdButtons()  # add stdButtons to sublayout
        # create form items
        self.lblItems = QLabel("Item name")
        self.cmbItems = QComboBox()
        self.cmbItems.addItems(("1", "2", "3"))

        # add form items to dict to setup widget associations
        self.formFields = {
            self.lblItems: self.cmbItems,
        }
        self.populateForm(self.formFields)  # add items to form layout


class TableTablet(Tablets, QTableWidget):
    """Handles the output table tablet"""
    def __init__(self, widget):
        super().__init__(widget)
        self.style = "::section{Background-color:lightgray;border-radius:9px;}"
        self.header = self.horizontalHeader()
        self.header.setStyleSheet(self.style)
        self.textGreeting = QLineEdit()
        self.layout.addWidget(self.textGreeting)


if __name__ == "__main__":
    app = QApplication(())
    window = Window()
    window.show()
    sys.exit(app.exec_())

complex analysis – Generalized Hardy-Ramanujan Sum

I am looking for a proof of the following fabulous identity by Ramanujan

$$sum_{n = 1}^{infty}dfrac{1}{n^{2q – 1}}left(a^{2q – 2}cothdfrac{npi b}{a} + (-1)^qb^{2q – 2}cothdfrac{npi a}{b}right) = dfrac{2}{pi ab}sum_{k = 0}^{q}(-1)^{k – 1}zeta(2k)zeta(2q – 2k)a^{2q – 2k}b^{2k}$$

I’m most interested in a proof making use of complex analysis, Mellin transforms, Infinite series.

Thanks.

reference request – Different ways of defining the Chern character of a complex

Consider a finite complex $E$ of (holomorphic) vector bundles on a (complex) manifold $X$, i.e, the complex is of the form
$$
0 to E_N to E_{N-1} to dots to {E_0} to 0,
$$

where the bundles are equipped with connections $D_i$. By K-theory, one may consider the complex $E$ as the alternating sum $sum_i (-1)^i (E_i)$, and it is then natural to define the Chern character (as a form) as $ch(E,D) := sum_{i=0}^N (-1)^i ch(E_i,D_i)$, and the Chern form as $c(E,D) := prod_{i=0}^N c(E_i,D_i)^{(-1)^i}$, where $ch(E_i,D)$ and $c(E_i,D)$ denote the Chern character and Chern form of $(E_i,D_i)$.

Alternatively, for a fixed $k$, one may express the Chern character as a polynomial in the Chern forms, $ch_k = S_k(c_1,dots,c_k)/k!$, where $S_k$ is the polynomial which expresses the Newton polynomials in terms of the elementary symmetric polynomials, i.e., what is sometimes called the Hirzebruch-Newton polynomial. For example, $S_1(t_1)=t_1$, $S_2(t_1,t_2)=t_1^2-2t_2$ etc. With the help of the polynomials $S_k$ above, one could alternatively define a Chern character of $E$ by
$widetilde{ch}_k(E,D)=S_k(c_1(E,D),dots,c_k(E,D))/k!$.

I have only found mentioned in passing or implicitly that these definitions coincide, i.e., $ch_k(E,D) = widetilde{ch}_k(E,D)$, but not any precise argument. Does anyone know of a convenient reference or proof of this fact?

complex geometry – Quaternonic Kaehler Chern connection

For a Riemannian manifold the natural connection is of course the Levi-Civita connection. For a complex manifold the natural connection is the Chern connection, which coincides with the Levi-Civita when the manifold is Kaehler. What happens in the quaternionic K”ahler case? Is there a “quaternonic Chern connection” for hyper-Kaehler manifolds, and if so, does it coincide with the Levi-Civita connection? On another note, what happens for manifolds of exceptional holonomy?

calculus and analysis – Extract real part of a complex function

I have a problem for extracting the real part of a complex number. The problem is the following: Suppose $f(z)=frac{1}{z+frac{Delta_{1}}{z+frac{Delta_{2}}{z+frac{Delta_{3}}{z+…}}}}$, in which z is a complex number $(z= a+bi)$ and $Delta_{1}$, $Delta_{2}$ … are number and $f(z)$ is a continued fraction.
And I want to compute $phi(b)$ since I would like to plot $phi(b)$ in the end

$$phi(b)=lim_{arightarrow0}Ref(a+bi)$$

But Mathematica doesn’t allow me to do that. I use “Limit” in Mathematica and set all $Delta_{n} = 0 , n > 1$ and $Delta_{1}=1$ , I get 0.
Even I let some $Delta_{n} $ to be nonzero, I still end up with 0.

Here is my code. I set $Delta_{1}=1$ and $Delta_{2}=0.5$, rest are zero.

Limit(ComplexExpand(Re(1/(a + b*I + (1/(a + b*I + (0.5/(a + b*I))))))), a -> 0)

Can someone help me with this ? I am guessing the “Limit” function in Mathematica can’t not handle this problem.

Thank you very much !!!

calculus and analysis – Extract real part of a complex number

I have a problem for extracting the real part of a complex number. The problem is the following: Suppose $f(z)=frac{1}{z+frac{Delta_{1}}{z+frac{Delta_{2}}{z+frac{Delta_{3}}{z+…}}}}$, in which z is a complex number $(z= a+bi)$ and $Delta_{1}$, $Delta_{2}$ … are number and $f(z)$ is a continued fraction.
And I want to compute $phi(b)$ since I would like to plot $phi(b)$ in the end

$$phi(b)=lim_{arightarrow0}Ref(a+bi)$$

But Mathematica doesn’t allow me to do that. I use “Limit” in Mathematica and set all $Delta_{n} = 0 , n > 1$ and $Delta_{1}=1$ , I get 0.
Even I let some $Delta_{n} $ to be nonzero, I still end up with 0.

Here is my code. I set $Delta_{1}=1$ and $Delta_{2}=0.5$, rest are zero.

Limit(ComplexExpand(Re(1/(a + b*I + (1/(a + b*I + (0.5/(a + b*I))))))), a -> 0)

Can someone help me with this ? I am guessing the “Limit” function in Mathematica can’t not handle this problem.

Thank you very much !!!

plotting – Plot part of a contour curve of the imaginary part of a complex function

Use RegionFunction

Clear("Global`*")

f(z_) := ((z + 1/z)^2 - 4)*(1 - I)

Legended(
 Show(
  ComplexContourPlot(Im(f(z)) == 0, {z, 2},
   ContourStyle -> Red,
   RegionFunction -> Function({z, func}, 0 < Re(f(z))),
   PlotPoints -> 75),
  ComplexContourPlot(Im(f(z)) == 0, {z, 2},
   ContourStyle -> Blue,
   RegionFunction -> Function({z, func}, Re(f(z)) <= 0),
   PlotPoints -> 75)),
 Placed(LineLegend({Red, Blue},
   {"Re(f(z))>0", "Re(f(z))≤0"}), {.7, .8}))

enter image description here