1. Introduction
The Hadamard product is a sort of multiplication of matrices and in spite of the usual product, it is commutative. This product of matrices is a classical topic in linear algebra that is useful in statistics and physics and it is also studied and used in combinatorial and probabilistic problems. Its applications can be found not only in mathematics but also, for instance, in cryptography, information theory, and data compression such as jpeg format.
Around 2010, in [
1,
2], the Hadamard product of matrices was extended to the Hadamard product of varieties in the study of the geometry of 
binary Boltzmann machine. The Hadamard product of varieties is also related to 
tropical geometry [
3,
4,
5].
Successively, in the last few years, the Hadamard product of projective varieties has been widely studied from the point of view of projective geometry and tropical geometry.
The paper [
3], where Hadamard products of general linear spaces are studied, can be considered the first step in this direction, while other papers, for example, Refs. [
6,
7,
8,
9,
10,
11], study the Hadamard product of varieties in relation with star configurations, Hilbert functions, apolarity, and so on.
The computation of the Hadamard product 
 of two varieties 
X and 
Y can be conducted in terms of suitable projections of Segre Embedding (Definitions 1 and 2) or working with the ideals of 
X and 
Y and using Elimination Theory (Definition 3). This second approach has two main benefits: first, we can use Computer Algebra software, such as 
Macaulay2 [
12], to produce explicit computations and examples; secondly, we can generalize the Hadamard product to any kind of ideal, that is, to ideals which are not associated with varieties (for example, monomial ideals, edge ideals, clutter ideals).
This second fact led us to study carefully the behavior of the Hadamard product of monomial ideals. In Proposition 1, we prove that the Hadamard product of square-free monomial ideals is square-free. The class of square-free monomial ideals is a classical object in commutative algebra, which has a strong connection with combinatorial structures and invariants of hypergraphs. We address our research in the spirit of the paper [
13], where another operation between ideals, the so-called join (Definition 4), is taken into consideration and the join of monomial ideals is studied. Moving as in [
13], but using the Hadamard product instead of the join, we discover that the Hadamard product of two monomial ideals is nothing more than their sum (Theorem 1), a much easier behavior with respect to the join.
Coming back to the first benefit of the algebraic approach, that is, the use of computer algebra software, it is clear that writing down all the instructions for the computation of the Hadamard product of two ideals is not so difficult, but requires some time. For this reason, the first author created the 
Hadamard.m2 package of 
Macaulay2 which has been verified for Macaulay2 development and it can be found at 
https://github.com/imanbj/Hadamard-m2 (accessed on 1 September 2021). The second part of this paper is intended to be a tutorial that provides a brief introduction to the use of 
Hadamard.m2 for the Hadamard product of varieties.
  4. Hadamard.m2
We give now some explanations of the commands in Hadamard.m2 together with examples.
Looking at the documentation page, we can note that the package contains:
Types
- ∘
 Point - a new type for points in projective space.
Functions and commands
- ∘
 hadamardPower - computes the Hadamard powers of varieties;
- ∘
 hadamardProduct - computes the Hadamard product of varieties;
- ∘
 idealOfProjectivePoints - computes the ideal of a set of points;
- ∘
 point - constructs a projective point from the list or array of coordinates.
Methods
- ∘
 hadamardPower(Ideal,ZZ) - computes the r-th Hadamard power of varieties;
- ∘
 hadamardPower(List,ZZ) - computes the r-th Hadamard power of a set of points;
- ∘
 hadamardProduct(Ideal,Ideal) - computes the Hadamard product of two homogeneous ideals;
- ∘
 hadamardProduct(List) - computes the Hadamard product of a list of homogeneous ideals or points;
- ∘
 hadamardProduct(List,List) - computes the Hadamard product of two sets of points;
- ∘
 “idealOfProjectivePoints(List,Ring)”
- see idealOfProjectivePoints - computes the ideal of a set of points;
- ∘
 “point(VisibleList)”(see point) - constructs a projective point from the list or array of coordinates.
- ∘
 Point * Point - entry-wise product of two projective points;
- ∘
 Point == Point - check equality of two projective points.
In this package, a point can be constructed in two different and equivalent ways: both from a list {} and both from an array []. Hence both the commands p = point {1,2,3} and p = point [1,2,3] define the same point . In the following examples, we use both methods to define points.
Once the package is loaded the Hadamard product of two points is defined by ∗.
Example 2. Consider the points .
Macaulay2, version 1.21
i1 : loadPackage"Hadamard"
i2 : p = point {1,2,3};
i3 : q = point [-1,2,5];
i4 : p * q
o4 = Point{-1, 4, 15}
i5 : x = point [1,1,2];
i6 : y = point {2,2,4};
i7 : x == y
o7 = true
i8 : p == q
o8 = false
 The function hadamardProduct is one of the main functions in Hadamard.m2.
hadamardProduct is multi-functional and works in different ways: it computes the Hadamard products of two ideals, two sets of points, or a list of ideals or points. Hence, according to the aim of computation, hadamardProduct can have a different number of inputs.
Before showing some examples, we mention the mathematical approach inside hadamardProduct.
Let 
X and 
Y be two varieties in 
. Denote by 
 and 
 their corresponding vanishing ideals. We consider
	Let 
. We define the map
	Hence, we have that 
.
Example 3. Consider the ideals I and J.
i9  : S = QQ[x,y,z,w];
i10 : I = ideal(x-y+z,z+y+w);
i11 : J = ideal(2∗x-y,w+x+y+z);
i12 : hadamardProduct(I,J)
o12 = ideal(6x^2 - 9x∗y + 3y^2 - 2x∗z + 2y∗z + 2x∗w - y∗w)
 Example 4. Using idealOfProjectivePoints, one can compute the vanishing ideal of a list of points. Here, we use two different methods to compute the Hadamard product of two points. First, we use ∗ and then idealOfProjectivePoints.
i13 : p = point {1,-1,4,2};
i14 : q = point {1,2,0,-1};
i15 : idealOfProjectivePoints({p∗q},S)
o15 = ideal (z, y - w, 2x + w)
Now, we first use idealOfProjectivePoints to compute the defining ideals of the points; then, we apply hadamardProduct.
i23 : Ip = idealOfProjectivePoints({p},S)
o23 = ideal (z - 2w, 2y + w, 2x - w)
i24 : Iq = idealOfProjectivePoints({q},S)
o24 = ideal (z, y + 2w, x + w)
i25 : hadamardProduct(Ip,Iq)
o25 = ideal (z, y - w, 2x + w)
i26 : o25 == o15
o26 = true
 Example 5. Due to Remark 1, consider the curve  defined by  and the point . The Hadamard product  is the line . However, the point  cannot be obtained as  with .
i27 : T = QQ[x,y,z];
i28 : IX = ideal(x*y-z^2)
i29 : p = point[1, 0, 2]
i30 : Ip = idealOfProjectivePoints({p},T)
o30 = ideal (y, 2x - z)
i31 : hadamardProduct(Ip,IX)
o31 = ideal y
 Given two sets of points L and M, hadamardProduct returns the list of (well-defined) entry-wise multiplications of pairs of points in the Cartesian product .
Example 6. Consider the two sets of points L and M.
i32 : L = point\{{0,1}, {1,2}};
i33 : M = point\{{1,0}, {2,2}};
i34 : hadamardProduct(L,M)
o34 = {Point{1, 0}, Point{0, 2}, Point{2, 4}}
Note that the map π is not defined on all  since point{0,1} ∗ point{1,0} = point{0,0}.
 The Hadamard products of a list of ideals or points are constructed by using the binary function hadamardProduct(Ideal,Ideal), or Point ∗ Point iteratively. So, in this case, hadamardProduct requires in input only one argument given by the list, as shown in the following example.
Example 7. Consider again the ideals I and J of Example 3 and let K be an ideal different from I and J.
i35 : K = ideal(2∗x-y,w+x+y+z, z-w)
o35 = ideal (2x - y, x + y + z + w, z - w)
i36 : L = {I,J,K};
i37 : hadamardProduct(L)
o37 = ideal(72x^2  - 54x*y + 9y^2  + 16x*z - 8y*z - 16x*w + 4y*w)
i38 : P = point\{{1,2,3},{-1,1,1},{1,1/2,-1/3}};
i39 : hadamardProduct(P)
o39 = Point{-1, 1, -1}
 For any projective variety 
X, we defined, in 
Section 2, its Hadamard square 
 and its higher Hadamard powers 
.
Give a homogeneous ideal I or a set of points L, the r-th Hadamard power of I or L is computed via the function hadamardPower. The function computes the r-times Hadamard products of I or L to itself.
Example 8. Consider the ideals I and K of Examples 3 and 7.
i40 : hadamardPower(J,3)
o40 = ideal(8x - y)
i41 : hadamardPower(K,3)
o41 = ideal (z - w, 27y + 64w, 27x + 8w)
i42 : L = {point{1,1,1/2},point{1,0,1},point{1,2,4}};
i43 : hadamardPower(L,2)
o43 = {Point{1, 0, 1}, Point{1, 0, 1/2}, Point{1, 0, 4},
       Point{1, 4, 16}, Point{1, 2, 2}, Point{1, 1, 1/4}}
 Example 9. Here is another example of Hadamard power.
i44 : S = QQ[x,y,z];
i45 : X = point\ {{1,1,0},{0,1,1},{1,2,-1}};
i46 : A = idealOfProjectivePoints(X,S)
o46 = ideal(3x∗z - y∗z + z^2, 3x∗y - 3y^2 - y∗z + 4z^2,
            3x^2 - 3y^2 - 2y∗z + 5z^2, y^2z + y∗z^2 - 2z^3)
i47 : A2 = hadamardPower(A,2)
o47 : ideal(y^2∗z - 18x∗z^2+ y∗z^2 - 2z, x∗y∗z - 4x∗z^2,
            x^2∗z - x∗z^2, 2x^3 - 3x^2∗y + x∗y^2 - 6x∗z^2)
i48 : X2 = hadamardPower(X,2);
i49 : A2 == idealOfProjectivePoints(X2,S)
o49 = true
 Theorem 2 ([
5])
. Let L and M be two lines in . Then  is a quadratic form. Example 10 (Example 6.1 in [
3])
. Let L be the line in  through points  and  and M the line through  and  Let  be the homogeneous coordinates of . We compute  as follows:i50 : S = QQ[x,y,z,w];
i51 : L = matrix{{2, 3, 5, 7},{11, 13, 17, 19}};
i52 : IL = ideal flatten entries(matrix{gens S} ∗ gens ker L);
i53 : M = matrix {{23, 29, 31, 37},{41, 43, 47, 53}};
i54 : IM = ideal flatten entries(matrix{gens S} ∗ gens ker M);
i55 : hadamardProduct(IL,IM)
o55 = ideal(88128x^2 - 89280x∗y - 5299632y^2 - 817938x∗z + 8896641y∗z -
            1481805z^2 - 321510x∗w - 1777545y∗w - 54250z∗w + 116375w^2)
 Example 11. Let  and  be two monomial ideals. By Theorem 1, we know that the Hadamard product  is equal to .
i56 : M1 = ideal(x∗y,x∗z,w);
i57 : M2 = ideal(y^2,x∗w,x^2∗y);
i58 : hadamardProduct(M1,M2)
o58 = ideal(w, x∗z, y^2 , x∗y)
i59 : M1+M2
o59 = ideal(x∗y, x∗z, w, y^2 , x∗w, x^2y)
i60 : o58 == o59
o60 = true
i61 : trim o59
o61 = ideal(w, x∗z, y^2 , x∗y)
 Since coordinate hyperplanes are defined by monomial ideals (with only one variable), Theorem 1 gives another proof of part of the following Lemma.
Lemma 3 (Lemma 4.1 in [
15])
. Let  be any coordinate hyperplane, for . Then,- (i) 
  is the linear subspace .
- (ii) 
  for any hypersurface C different from a coordinate hyperplane.
 Example 12. Let  and  be two lines in . One can see that the Hadamard product  is the point  obtained by the intersection of  and . We have that .
i62 : S = QQ[x,y,z];
i63 : IL1 = ideal(x);
i64 : IL2 = ideal(y);
i65 : hadamardProduct(IL1,IL2)
o65 = ideal(y,x)
i66 : IL1+IL2
o66 = ideal(y,x)