## 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 ‘https://blog.ploeh.dk/2011/07/28/CompositionRoot/’ 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.

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?

## Polynomial roots equation

$$P\in C[X],\ P=X^3-X^2+6X-1$$ and $$\alpha_1,\alpha_2,\alpha_3$$ it’s roots. Find $$\alpha_1^5+\alpha_2^5+\alpha_3^5$$. I know there are some recursive formulas to solve this but I cannot remember them or their author.

## nature of roots of Quadratic equation

If the roots of the equation $$ax^2 + 2bx + c=0$$ are real and disrinct, then show that the roots of the equation $$x^2-2(a+b)x+a^2+b^2+2c^2=0$$ are non-real complex numbers.

## Question on nature of roots (proving).

My attempt:

I simplified the given expression, applied the discriminant for two real roots and got stuck on this inequality: $$({a}^2 – {ab}+{b}^2)$$ > 0

Any help would be most appreciated.

## Roots of $x^n-x^{n-1}-\cdots-x-1$

It is easy to see that $$f(x)=x^n-x^{n-1}-\cdots-x-1$$ has only one positive root $$\alpha$$ which lies in the interval $$(1,2)$$. But it is claimed that this root is a Pisot number, i.e., the other roots are in the open $$\{z\in \mathbb{C}: |z|<1\}$$. I have tried the following, but I failed. I considered $$P(x)=(1-x)f(x)=x^{n+1}-2x^n+1=x^n(x-2)+1$$ and then I tried to use Rouche’s theorem, by picking $$g(x)=-x^n(x-2)$$ and trying to show that $$1<|g(z)|+|P(z)|$$ for $$|z|=1$$. Proving this implies that $$P(x)$$ has $$n$$ roots in $$\{z\in \mathbb{C}: |z|<1\}$$ which demonstrates the claim. But this inequality fails at $$z=1$$. Can you give me an idea how one can prove this claim?

## Read model with data from multiple aggregate roots (different contexts)

I’m curious to how to join data from multiple aggregate roots in an read model for an event sourced aggregate root. Can try to take a simple example:

If I have an aggregate root called Cart which supports following events in it’s event stream (properties in parentheses – keep in mind this is an simple example):

AddProductToCart(cartId: Int, productId: Int) RemoveProductFromCart(cartId: Int, productId: Int) AddUserLicenseToProduct(cartId: Int, productId: Int, userId: Int) RemoveUserLicenseFromProduct(cartId: Int, productId: Int, userId: Int) EmptyCart(cartId: Int) 

It’s ok when projecting read models with data coming from this event stream. I can for example project a cart object which looks something like this:

Cart(cartId: Int, products: List[Product])  Product(productId: Int, userLicenses: List[UserLicense]) UserLicense(userId: Int) `

But how does one join data from another aggregate root in another context into this cart projection. For example if I wanted to extend the read model with data from the Product aggregate root which lives in another context. Let’s say I would like to extend it with productName and productType.

Take into consideration we are working in an distributed system, where Product and Cart would be live in different services/applications.