Add vertical lines to `ComplexPlot3D` at roots

I have a Table of 6 plots of polynomials of increasing degree, using ComplexPlot3D:

Clear["Global`*"];  poly[z_] := Sum[k*z^k, {k, 1, n}];  Table[ComplexPlot3D[poly[z], {z, -1.5 - 1.5*I, 1.5 + 1.5*I}], {n, 1, 6}] 

enter image description here

I would like to add a black vertical line passing through each root of the polynomials. You can kind of see where they are from the plots, but lines would be a helpful visualisation aid.

I can obtain the roots easily enough:

Table[{poly[z], Roots[poly[z] == 0, z]}, {n, 1, 6}] 

But how do I convert the data provided by Roots into vertical lines? Ultimately, I want to be able to do this for polynomials of arbitrary degree, so a ‘manual’ solution isn’t much help.

Thanks in advance, and stay safe.

Expression involving square roots not simplifying

I have a relatively simple expression here that is not simplifying:

$ $ \frac{2 s_0 \left(\sqrt{\gamma ^5 s_0}+\sqrt{\gamma ^9 s_0}\right)+\sqrt{\gamma ^3 s_0}+2 \sqrt{\gamma ^7 s_0}+\sqrt{\gamma ^{11} s_0}+\sqrt{\gamma ^7 s_0^5}}{\gamma \left(\gamma ^2+\gamma s_0+1\right){}^2} $ $

$  Assumptions = {(s0 | \[Gamma]) \[Element] Reals, \[Gamma] > 0,     s0 > 0}; (Sqrt[s0 \[Gamma]^3] + 2 Sqrt[s0 \[Gamma]^7] + Sqrt[s0^5 \[Gamma]^7] +    Sqrt[s0 \[Gamma]^11] +    2 s0 (Sqrt[s0 \[Gamma]^5] + Sqrt[s0 \[Gamma]^9]))/(\[Gamma] (1 +      s0 \[Gamma] + \[Gamma]^2)^2) // Simplify (Sqrt[s0 \[Gamma]^3] + 2 Sqrt[s0 \[Gamma]^7] + Sqrt[s0^5 \[Gamma]^7] +     Sqrt[s0 \[Gamma]^11] +     2 s0 (Sqrt[s0 \[Gamma]^5] + Sqrt[s0 \[Gamma]^9]))/(\[Gamma] (1 +       s0 \[Gamma] + \[Gamma]^2)^2) == Sqrt[s0 \[Gamma]] // Simplify 

The output is:

(Sqrt[s0 \[Gamma]^3] + 2 Sqrt[s0 \[Gamma]^7] + Sqrt[  s0^5 \[Gamma]^7] + Sqrt[s0 \[Gamma]^11] +   2 s0 (Sqrt[s0 \[Gamma]^5] + Sqrt[s0 \[Gamma]^9]))/(\[Gamma] (1 +     s0 \[Gamma] + \[Gamma]^2)^2) True 

Why is Mathematica not simplifying to this much simpler form $ \sqrt{s_0 \gamma}$ , I think my assumptions should be enough. I can do the simplification by hand

What is the most efficient algorithm to compute polynomial coefficients from its roots?

Given $ n$ roots, $ x_1, x_2, \dotsc, x_n$ , the corresponding monic polynomial is $ y = (x-x_1)(x-x_2)\dotsm(x-x_n) = \prod_{i}^n (x – x_i)$ . To get the coefficients (i.e. $ y = \sum_{i}^n a_i x^i$ ), a straightforward expansion requires $ O(n^2)$ steps.

Alternatively, if $ x_1, x_2, \dotsc, x_n$ are distinct with each other. The problem is equivalent to polynomial interpolation with $ n$ points: $ (x_1, 0), (x_2, 0), \dotsc, (x_n, 0)$ . The fast polynomial interpolation algorithm can be run in $ O(n\log^2(n))$ time.

I want to ask whether there is any more efficient algorithm better than $ O(n^2)$ ? Even if there are duplicated values among $ \{x_i\}$ ? If it helps, we can assume that the polynomial is over some prime finite field, i.e. $ x_i \in \mathbf{F}_q$ .

Function of square roots returns value with 0 imaginary part

I am considering the following function called funAl:

1/2 (1 + (Sqrt[3] Sqrt[868 - 1700 xi + 825 xi^2])/Sqrt[4 - 25 xi^2]) 

This function occurs as a boundary in one of my integrals which i am integrating with Vegas numerically. For all considered values of xi funAl should be real and less than 1. But for some values of xi (values which are allowed), i get something like:

funAl //. xi -> 0.973991669410735` 
0.942244 + 0. I 

Vegas stopes integrating because of non-real values, but as you see the imaginary part is just 0. NIntegrate for example works perfectly fine. Any ideas why the funtions funAl containing only square roots gives back such values?

The integral is of the following form:

contr42 =   Vegas[Sqrt[xi^2*u0Max2^2 - mu^2]*u0Max2*1/(2*(2*Pi)^3)*g*    J2[xi *u0Max2], {xi, 14/15, 1}, {alpha, funAl,     1}, {eta, 0, 1}, {rho, 0, 1}, {beta, 0, 1}, MaxPoints -> 10^6] 

So values of xi are inserted into funAl and return the kind of numbers given above and due to the imaginary part i get an error.

Creation of aggregate root that contains references to other aggregate roots

I would like to model the following entities: “Person”, “Company” and the aggregate that ties the two together “Membership”. I have identified that Person and Company are aggregate roots. Thus, “Membership” would hold a reference (id) of both those aggregate roots, plus other value objects/entities that a membership holds (for example the title that the person has for that company).

In my architecture I have the following layers: Api controllers, services, domains, repository. When creating a Membership object, the controller receives two identifiers (for person and for company). Currently the service is responsible for making a call to the CompanyService – to ensure that a company with that id exists and to the PersonService – to ensure a person with that id exists. However, in the Domain model I currently have a constructor that takes in two ids, which makes it feel really anemic. Also, in a further iteration, there will be the addition of a list of references to a third aggregate root, Vehicle. Thus a vehicle can exist by itself, or it can also belong to a membership.

Is this a bad way of modelling these entities? Is there a better way? I have read about the notion of domain services and application services, but my application does not currently have that distinction and I don’t know if that concept would help in this case.

Even the behaviour of the aggregate roots feels a bit dry when it comes to functionality related to the other aggregate roots it holds references for: ie. the Membership domain model would have the ability to “Link a car”, setting a car for itself, but again, receiving just an identifier that it would add to a list of identifiers.

Sum over powers of roots of unity gives only partial answer

Mathematica seems to be unable to handle sums over roots of unity. For example, Simplify[Sum[Exp[2 Pi I a b/m], {a, m}], {b, m} \[Element] Integers] yields 0 instead of a piecewise function like:$ $ \begin{cases} 0 & gcd(b,m)=1\ m & \text{otherwise} \end{cases} \ $ $ Has anybody managed to obtain the correct answer?

How to define Composition Roots for libraries (Javascript/inversify)

I’m building a console app (A), which depends on library B. Library B further depends on library C. I am building all 3 entities. Most of the development completed so far has been done using a functional design and so far this is working well, and is currently stateless, and no instantiations have been needed so far. I am now at a point where I need to declare some dependencies and inject them as appropriate. The interaction between libraries B and C should be transparent to the application A. I have been reading up on dependency injection/inversion of control and I’ve decided that I will use inversify as the dependency injection framework. One point I am ‘stuck’ on is the notion of Composition Roots and where they should be created. I found this article ‘’ which states that the CR should be as close to the main entry point of the application. It also says that CRs, are not applicable to libraries just applications. But the interaction between libraries B & C is an implementation detail that the client should not be aware of. So what is the correct resolution to this issue? I’m inclined to define a CR in library B so that its dependency on a component in library C can be injected. This seems correct to me, but it does seem at odds with established wisdom. To quote the article: “Only applications should have Composition Roots. Libraries and frameworks shouldn’t.”. It seems that to do this correctly, the client app needs to be aware of all the implementation crud and its up to the client to compose everything via a Composition Root.

But if library B needs a dependency to be injected into it (which comes from library C), how do we do this? I’m now suffering analysis paralysis …

PS, I also considered this article: Design/Architecture for passing cross-cutting parameters via constructors at composition roots?, but that does not address the issue of the application/client being aware of downstream dependencies.

Statistical tests for modular roots of high complexity integer sequences?

Take two integers $ n$ and $ m$ with $ 0<\log_2m<n<m$ .

Let $ r=(2(n!)+1)\bmod m$ .

Denote the two roots of $ ((2(n!)+1)\bmod m)^2\bmod m$ by $ r_1$ and $ r_2$ .

One of $ r_1$ and $ r_2$ equals $ r$ .

  1. Is there a statistical test that performs better than a random coin toss at finding correct one of $ r_1$ or $ r_2$ ?

  2. Can we replace $ a(n!)+b$ by any other sequence whose complexity is purportedly high while a statistical test can separate them with significance?