finite element method – Problem with NDSolveValue : “The function value {$Failed} is not a list of numbers with dimensions…”

I was having fun modifying a code given to me as an answer to a previous problem here, courtesy of user Alex Trounev (Thank you again), when I encountered a certain error which I had never seen before.

Here is the aforesaid code :

r0 = 0.5;
h = 1;
(Alpha) = 0.8;

(*region definition*)
reg = Cuboid({.5, 0., 0.}, {1., 2 Pi, 1.});

reg3D = ImplicitRegion(
   r0^2 <= x^2 + y^2 <= 1 && 0 <= z <= 1, {x, y, z});

(*equation + conditions*)
eq1 = D(u(t, r, (Theta), z), 
    t) - (D(u(t, r, (Theta), z), r, r) + 
     1/r*D(u(t, r, (Theta), z), r) - 
     1/((Alpha)^2 r^2) D(u(t, r, (Theta), z), (Theta), (Theta)) + 
     D(u(t, r, (Theta), z), z, z));

ic = u(0, r, (Theta), z) == 1;

bc = DirichletCondition(u(t, r, (Theta), z) == Exp(-5 t), r == r0);
nV = NeumannValue(1, r == 1);
pbc = PeriodicBoundaryCondition(u(t, r, (Theta), z), (Theta) == 0, 
   TranslationTransform({0, 2 (Pi)*(Alpha), 0}));

(*solution computation*)
sol = NDSolveValue({eq1 == nV, ic, bc, pbc}, 
   u, {t, 0, 2}, {r, (Theta), z} (Element) reg);

PlotPoints(Rule)50,PlotLabel(Rule)Row({"t = 

When I run the code, after some time, I get greeted with the following error :

NDSolveValue::nlnum: The function value {$Failed} is not a list of numbers with dimensions {39639} at {t,u(t,r,(Theta),z),(u^(1,0,0,0))(t,r,(Theta),z)} = {0.0138161,{<<1>>},{-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,<<15>>,-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,-4.66626,<<39589>>}}.

When I click on the three dots next to the error, I don’t find any information on the error like it’s usually the case. I then decide to google some answers.
I found some answers here while also trying to comprehend the error by looking at this and finally that answer here.

So if I did understand it correctly, such error arises when you use NDSolve (or NDSolveValue) to get a symbolical solution to your equation, but problems come up when you try to numerically evaluate it for plotting purpose, or when trying to get a symbolical result with a function that requires numerical values ?

In any case, I do not really understand why I get such error as my plot part is currently between (* … *) so it shouldn’t matter. As for the rest of the code, I do not really see an error but I am just a beginner so…

Anyway, can a kind fellow enlighten me please ?

Deterministic Finite Automata vs Java

You need to select a device controller. You have two options:
Option 1: Implement with a DFA
Option 2: Implement using Java
The primary advantage of a DFA over a program written in Java is as follows:

Answer choices:

  • A DFA requires fewer computational resources
  • A DFA is faster than a program in Java
  • Running a DFA costs less than running a program written in Java
  • It doesn’t matter if we use a DFA or a program written in Java, as long as it gets the job done

ag.algebraic geometry – Algebras Morita equivalent with the Weyl Algebra and its smash products with a finite group

My question os motivated, naturally, by the problem of classifying symplectic reflection algebras up to Morita equivalence (a classical reference for rational Cherednik algebras is Y. Berest, P. Etingof, V. Ginzburg, “Morita equivalence of Cherednik algebras” MR2034924; the most up do date work in this subject I know of is I. Losev;

and also the problem of understading rings of differential operators on irreducilbe affine varieties $X$ up to Morita equivalence (a nice discussion of this problem can be found in Y. Berest, G. Wilson, “Differential isomorphism and equivalence of algebraic varieties” MR2079372)

Given that:

(Question 1): What are the more general known conditions on a symplectic reflection algebra $H_{1,c}(V,Gamma)$ that imples it is Morita equivalent to $mathcal{D}(V) rtimes Gamma$?

(Question 2): What are the recent developments made in the study of equivalence of rings of differential operators up to Morita equivalence (and in particular Morita equivalent to the Weyl algebra) since Berest, Wilson (op. cit.)?

(Question 3): Etingof in “Cherednik and Hecke algebras of varieties with a finite group action” MR3734656 introduces more general versions of rational Cherednik algebras and discuss the possibility of extending the results in Y. Berest, O. Chalykh, Quasi-invariants of complex reflection groups MR 2801407 in this setting. So, being optmistic, one hipotetically could obtain results similar as those discussed in Berest, Etingof, Ginzburg (op. cit) regarding Morita equivalence of these generalized rational Cherednik algebras with smash products of rings with differential operatos with a finite groups. Has this line of inquiry lead to results relvant to this discussion so far?

(Question 4): This is totally unrelated to the previous questions. It is more of a very open question in ring theory: are there interesting simple Noetherian algebras, coming from another areas than those above, which are Morita equivalent to a Weyl algebra or a smash product of it with a finite group?

finite element method – Mesh Refinement for interpolation of f[x,y] fails for all but the simplest f

I would like to interpolate a function, f(x,y,z), on a mesh of the unit cube, starting with a coarse tetrahedral mesh and refining tetrahedra as needed to reduce the interpolation error below a tolerance. The problem: DiscretizeRegion(Cuboid(),MeshRefinementFunction->mrf) ignores my mrf. In an attempt to understand, I have simplified to a toy version of the problem (2D, on a square instead of a cube, with a simple form for f). I discovered that of the following 5 mathematically equivalent forms for f, the last works and the others do not:

fDirect({x_, y_}) = Cos(2*Pi*x)*Sin(2*Pi*y)
fDelayed({x_, y_}) := Cos(2*Pi*x)*Sin(2*Pi*y)
fEmbedded1 = Function({p}, fDirect(p))
fEmbedded2 = fDirect(#1) & 
fPureFun = Function({p}, Cos(2*Pi*p((1)))*Sin(2*Pi*p((2))))

Here is what the unrefined mesh looks like:

sq = DiscretizeRegion(bm, MaxCellMeasure -> Infinity)

Coarse mesh of unit square without refinement

The resulting mesh has 4 nodes and 2 triangular elements.

Now we define a refinement function. For the toy problem I have adopted a simplified form of the error estimate. I check the error only at the center of each tetrahedron. The center is at Mean(vertices). The true value there is f(Mean(vertices)). My “interpolated value” there is just the mean of f at the individual vertices, Mean(f/@vertices). When Abs(error)>tolerance, the function returns True. A diagnostic print statement lets us see when the mesh refinement function is called.

This does not work for the first definition of f. Here is what that looks like:

 mrf = Function({vertices, area}, 
   Module({fest, ftrue, error, tolerance, test}, 
    fest = Mean(fDirect /@ vertices); 
    ftrue = fDirect(Mean(vertices)); 
    error = fest - ftrue; tolerance = 0.43; 
    test = Abs(error) > tolerance; 
    Print({vertices, area, fest, ftrue, error, tolerance, test}); 
sq = DiscretizeRegion(bm, MeshRefinementFunction -> mrf, 
  MaxCellMeasure -> Infinity)
Print("The mesh has ", Length(mc = MeshCoordinates(sq)), " nodes.")
Print("The mesh has ", 
 Length(mcells = MeshCells(sq, 2)), " triangular cells.")

Failed mesh refinement using a direct definition of f(x,y)

Notice that the mrf is called only once (there is output for only one diagnostic Print()) despite that there are two triangles. In that one call the error exceeds tolerance and the mrf returns true (i.e., do a refinement), yet there is no subsequent refinement. Definitions 2 – 4 produce the same result.

It does work for definition 5. Here is what it’s supposed to look like when it works:

mrf = Function({vertices, area}, 
   Module({fest, ftrue, error, tolerance, test},
    fest = Mean(fPureFun /@ vertices);
    ftrue = fPureFun(Mean(vertices));
    error = fest - ftrue;
    tolerance = 0.43;
    test = Abs(error) > tolerance;
    Print({vertices, area, fest, ftrue, error, tolerance, test});
sq = DiscretizeRegion(bm, MeshRefinementFunction -> mrf, 
  MaxCellMeasure -> (Infinity))
Print("The mesh has ", Length(mc = MeshCoordinates(sq)), " nodes.")
Print("The mesh has ", 
 Length(mcells = MeshCells(sq, 2)), " triangular cells.")

Working mesh refinement with f defined as a pure function

In the working case, we get a diagnostic print output for each cell of the mesh with repeats for several iterations, until all triangular elements have interpolation error estimates below tolerance.

It seems odd that the change that makes a difference here is a difference in the definition of f, which is internal to a module within a function definition. This seems a failure of encapsulation.

Definitions 3 and 4 were attempts to hide one of the apparently unacceptable forms of definition inside of the acceptable pure function definition form, but this did not work.

Unfortunately, my non-toy version of f is not easily written as a pure function (the one mode that worked above). That function is the end result of tens of pages of development within the notebook. It calls a number of functions, uses a numerical differential equation solver, an iterative root finder,… It’s not a simple function, which is why I want to tabulate and interpolate it.

Is this a bug? Is there a workaround–another way to access mesh refinement within Mathematica? Or would this work if only I did it correctly? (How does one do it correctly?)

Asymptotic formula for number of topologies on the finite point-set ${1,2,dots,n}$

Let $n$ be a finite positive integer.

  • Is there an asymptotic formula for (or good lower / upper bounds) for the number of topologies on the point-set ${1,2,ldots,n}$ ?
  • What if we restrict to only counting topologies which are "truely distinct" ?

linear algebra – The number of $Mtimes N$ matrices with the rank $r$ and the weight $w$ over a finite field $mathbb{F}_{q}$

Let $M$,$N$ and $m$ be positive integers.
Let $p$ be a prime number.
Let $w$ and $r$ be nonnegative integers which satisfy $wleq MN$ and $rleq min(M,N)$.
We set $q=p^{m}$.
Let $mathbb{F}_{q}$ be a finite field of order $q$.
Let $mathbb{F}_{q}^{Mtimes N}$ be the set of all $Mtimes N$ matrices over $mathbb{F}_{q}$.
For $Sinmathbb{F}_{q}^{Mtimes N}$, let $mathrm{w}(S)$ be the number of nonzero elements of the matrix $S$, which is called “the weight of the matrix $S$.”
For $Sinmathbb{F}_{q}^{Mtimes N}$, let $mathrm{rank}(S)$ be the rank of the matrix $S$.
Please derive the number of $Mtimes N$ matrices with the rank $r$ and the weight $w$ over a finite field $mathbb{F}_{q}$,
i.e. $|{Sinmathbb{F}_{q}^{Mtimes N}| mathrm{w}(S)=w,mathrm{rank}(S)=r}|$.

irreducible polynomials – How do find the generators of multiplicative group in finite field

Input: p (prime number), n (positive number)
Output: g ( generator )

I just have found a irreducible polynomial over Fp(x)
Then, I must find all generators of the multiplicate group from this irreducible polynomial, but I don’t know how to do.
I’m a newbie so I wanna understand clearly to code this problem.
Anyone has a general solution for this? Please help me step by step.Tks

finite differences – Existence of a solution for the discrete pde $nabla a nabla f = g$ in $mathbb{Z}^d$ with $g$ periodic

I first asked this question on math.stackexchange as I first thought it was somewhat innocent.

I would like if one can solve the problem $nabla^* a nabla f =g$ in $mathbb{Z^d}$ with $f(0)=c$ where
nabla^* a nabla f(x) = sum _{y sim x} a(x,y)(f(y)-f(x))

with $a(x,y)=a(y,x)$ and $0< theta le a(x,y)<1$, with $xsim y$ denoting $|x-y|_1 =1$. I am particularly interested in the case in which $g$ is periodic (say of period $N$ in every coordinate) and satisfying $sum_{z in mathbb{Z}^d_N} g(z) = 0$.

In the homogeneous case (a(x,y)equiv 1), we could just use that the problem is equivalent to solving it in the torus, which is much simpler. It does not seen like a good idea to brute force the solution via convolution with the Green function $G_a$ of $nabla^* a nabla$, that is
f(x)-f(0) = sum_{y in mathbb{Z}^d}(G_a(x,y)-G_a(0,y)) g(y)

as I do not expected it to be convergent, (I am guessing that $|G_a(x,y)-G_a(0,y)|lesssim |x-y|^{1-d}$).

So can I guarantee such $f$ exists? Do I have any (semi-explicit) good representation for it?
I appreciate any references or suggestions.

plotting – How to generate a region with a finite width/height on say $ y $-direction, but infinite on $ x $-direction?

I want to use such a region as an Epilog in other figures. I have tried with HalfPlane, thinking RegionIntersection might work.

r1 = HalfPlane[{{0, -.5}, {1, -.5}}, {0, 1}];
r2 = HalfPlane[{{0, .5}, {1, .5}}, {0, -1}];
Region[RegionIntersection[r1, r2]]

But it is not a graphics primitive so that it can not be used as an Epilog.

algorithms – How to convert finite automata to regular expressions?

There are several methods to do the conversion from finite automata to regular expressions. Here I will describe the one usually taught in school which is very visual. I believe it is the most used in practice. However, writing the algorithm is not such a good idea.

This algorithm is about handling the graph of the automaton and is thus not very suitable for algorithms since it needs graph primitives such as … state removal. I will describe it using higher-level primitives.

The key idea

The idea is to consider regular expressions on edges and then removing intermediate states while keeping the edges labels consistent.

The main pattern can be seen in the following to figures. The first has labels between $p,q,r$ that are regular expressions $e,f,g,h,i$ and we want to remove $q$.

p-q-r automaton

Once removed, we compose $e,f,g,h,i$ together (while preserving the other edges between $p$ and $r$ but this is not displayed on this):

enter image description here


Using the same example as in Raphael’s answer:

1-2-3 automaton

we successively remove $q_2$:

1-3 automaton

and then $q_3$:

1 automaton

then we still have to apply a star on the expression from $q_1$ to $q_1$. In this case, the final state is also initial so we really just need to add a star:

$$ (ab+(b+aa)(ba)^*(a+bb))^* $$


L(i,j) is the regexp of the language from $q_i$ to $q_j$. First, we remove all multi-edges:

for i = 1 to n:
  for j = 1 to n:
    if i == j then:
      L(i,j) := ε
      L(i,j) := ∅
    for a in Σ:
      if trans(i, a, j):
        L(i,j) := L(i,j) + a

Now, the state removal. Suppose we want to remove the state $q_k$:

  for i = 1 to n:
    for j = 1 to n:
      L(i,i) += L(i,k) . star(L(k,k)) . L(k,i)
      L(j,j) += L(j,k) . star(L(k,k)) . L(k,j)
      L(i,j) += L(i,k) . star(L(k,k)) . L(k,j)
      L(j,i) += L(j,k) . star(L(k,k)) . L(k,i)

Note that both with a pencil of paper and with an algorithm you should simplify expressions like star(ε)=ε, e.ε=e, ∅+e=e, ∅.e=∅ (By hand you just don’t write the edge when it’s not $∅$, or even $ε$ for a self-loop and you ignore when there is no transition between $q_i$ and $q_k$ or $q_j$ and $q_k$)

Now, how to use remove(k)? You should not remove final or initial states lightly, otherwise you will miss parts of the language.

for i = 1 to n:
  if not(final(i)) and not(initial(i)):

If you have only one final state $q_f$ and one initial state $q_s$ then the final expression is:

e := star(L(s,s)) . L(s,f) . star(L(f,s) . star(L(s,s)) . L(s,f) + L(f,f))

If you have several final states (or even initial states) then there is no simple way of merging these ones, other than applying the transitive closure method. Usually this is not a problem by hand but this is awkward when writing the algorithm. A much simpler workaround is to enumerate all pairs $(s,f)$ and run the algorithm on the (already state-removed) graph to get all expressions $e_{s,f}$ supposing $s$ is the only initial state and $f$ is the only final state, then doing the union of all $e_{s,f}$.

This, and the fact that this is modifying languages more dynamically than the first method make it more error-prone when programming. I suggest using any other method.


There are a lot of cases in this algorithm, for example for choosing which node we should remove, the number of final states at the end, the fact that a final state can be initial, too etc.

Note that now that the algorithm is written, this is a lot like the transitive closure method. Only the context of the usage is different. I do not recommend implementing the algorithm, but using the method to do that by hand is a good idea.