4
$\begingroup$

I am trying to find a solution for $N$ for the following equation.

$$ \frac{\exp(-\sigma^2/2)}{(1 - \exp(-\sigma^2/2))} - \exp(-(N^2-3N+3)\sigma^2/2) \frac{(N-1 + \exp(-N \sigma^2/2) - N \exp(-\sigma^2/2))}{((1 - \exp(-\sigma^2/2))^2 N} < \epsilon $$

So, I just checked for a solution where it is equal to $\epsilon$.

Solve[Exp[-S^2/2]/(1 - Exp[-S^2/2]) - 
   Exp[-(N^2 - 3 N + 3) S^2/2] (N - 1 + Exp[-N S^2/2] - 
       N Exp[-S^2/2])/((1 - Exp[-S^2/2])^2 N ) ==  p, N] 

I get the following error.

Solve::nsmet: This system cannot be solved with the methods available to Solve.
$\endgroup$
5
  • $\begingroup$ Use n not N because capital N is a builtin. In any case, this equation is too complex to solve using Solve. I'm assuming you want a fully symbolic solution and you haven't got numerical values for S etc. ? $\endgroup$
    – flinty
    Commented Dec 21, 2022 at 12:59
  • $\begingroup$ Yes, I want a full symbolic solution and I haven't tried with a single $S$ . $\endgroup$
    – CfourPiO
    Commented Dec 21, 2022 at 13:07
  • 1
    $\begingroup$ Do you have any reason to believe a compact symbolic solution should exist? It looks to me like it's just too complicated for Mathematica. $\endgroup$
    – flinty
    Commented Dec 21, 2022 at 13:09
  • $\begingroup$ I just tried with $n$ and a value for $S$ as $3$. Still the same error. I think it is too complex to find a solution. $\endgroup$
    – CfourPiO
    Commented Dec 21, 2022 at 13:10
  • $\begingroup$ Not really. I do not know for sure if it has a direct solution. I was just trying if it is possible. $\endgroup$
    – CfourPiO
    Commented Dec 21, 2022 at 13:11

2 Answers 2

6
$\begingroup$

For convenience we define:

f[n_, s_] := Exp[-s^2/2]/(1 - Exp[-s^2/2]) - 
             Exp[-(n^2 - 3 n + 3) s^2/2] (n - 1 + Exp[-n s^2/2] - 
                                           n Exp[-s^2/2])/((1 - Exp[-s^2/2])^2 n)

One can simply visualize solutions with e.g.

Manipulate[
  ContourPlot[f[n, s] == p, {n, -2, 4}, {s, 0, 6}, 
  ContourStyle -> Thick, PerformanceGoal -> "Quality"], {p, 0, 1, 1/10000}]

and then it is straightforward to find a symbolic solutions prescribing appropriate parameters s and p, e.g.

With[{p = 3/10000, s = 4}, Solve[f[n, s] == p, n, Reals]]

enter image description here

These are exact solutions expressed in terms of Root objects and they cannot be expressed analytically in terms of radicals, see e.g. How do I work with Root objects?. For more detalied discussion of a powerful function Solve see e.g. What is the difference between Reduce and Solve?

pp = Thread[{With[{p = 3/10000}, SolveValues[f[n, 4] == p, n, Reals]],4}];
With[{p = 3/10000}, 
  ContourPlot[{f[n, s] == p, s == 4}, {n, 0, 5/2}, {s, 2, 9/2}, 
    ContourStyle -> Thick, PlotPoints -> 50, 
    Epilog -> {Red, PointSize[0.02], Point[pp]}]]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thank you so much for the detailed answer. I will look into it. $\endgroup$
    – CfourPiO
    Commented Dec 22, 2022 at 10:01
1
$\begingroup$

Note: The method below is focused mainly on the case where $N$ is integer (which OP confirms is the case in the comment below)

You can get a symbolic function/expression if you solve for $\sigma$ with the caveat that you will have to consider a finite set of explicit integers.

Notice that for a fixed $N$, say $N=3$, you have a polynomial equation if you change variables and rearrange the equation like this :

f[n, s] - ϵ /. s -> Sqrt[2] Sqrt[-Log[z]] /. n -> 3 // 
   Together // Numerator // Simplify

$$-z^5-z^4+2 z^3-3 z (\epsilon +1)+3 \epsilon$$

The above equation should equate to zero.

You do not have to use a change of variables however, you can solve the equation directly.

Here is a function to generate nmax solutions:

table[nmax_] := 
 Table[{n -> m, 
   Refine[Solve[{f[m, s] == ϵ, s > 0}, s, 
     Reals], ϵ > 0]}, {m, nmax}]

The three first solution for $N\in\{1,2,3\} $:

Important note ! : $\sigma$ positive below is left as a means to simplify the discussion below but you should remove it in your code. See important footnote in bold at the end.

table[4]

$$\left( \begin{array}{cc} n\to 1 & \left\{\left\{s\to \sqrt{2} \sqrt{\log \left(\frac{\epsilon +1}{\epsilon }\right)}\right\}\right\} \\ n\to 2 & \left\{\left\{s\to \sqrt{2} \sqrt{\log \left(\frac{\sqrt{4 \epsilon ^2+12 \epsilon +1}+2 \epsilon +1}{4 \epsilon }\right)}\right\}\right\} \\ n\to 3 & \left\{\left\{s\to \sqrt{2} \sqrt{\log \left(\text{Root}\left[3 \text{$\#$1}^5 \epsilon +\text{$\#$1}^4 (-3 \epsilon -3)+2 \text{$\#$1}^2-\text{$\#$1}-1\&,1\right]\right)}\right\}\right\} \\ \end{array} \right)$$

The first two are explicit and the third involves the root of a quintic which can not be solved in terms of radicals but it can be solved in terms of hypergeometric functions as shown in this Wikipedia page : https://en.wikipedia.org/wiki/Bring_radical#Other_characterizations

The next root involves the solution to a polynomial of degree 10. Maybe one can find an explicit solution but for the question here you do not need to and in general functions based from Root are full fledged symbolic functions for which you can find series expansions at small and large arguments, locate singularities symbolically with FunctionSingularities and much more. You just might have trouble with integration which such functions but that is not the question here.

Consider now a value for $\epsilon$ such as $\epsilon=0.4$

table[4] /. ϵ -> 0.4

(* {{n -> 1, {{s -> 1.58289}}}, {n -> 2, {{s -> 1.41233}}}, {n -> 3, {{s -> 1.56111}}}, {n -> 4, {{s -> 1.58272}}}} *)

We can plot s=$\sigma$ for 10 values of n=$N$ with $\epsilon=0.4$

Note: Takes a while you might want to store the generated list if you plan to plot a lot with a fixed value of nmax

table[10] // Map[{n, s} /. {#[[1]], #[[2, 1, 1]]} &] // 
ReplaceAll[\[Epsilon] -> 0.4] // ListPlot

enter image description here

We can also plot $\sigma$=s for different $N$ as a function of $\epsilon$ where each curve is labeled by the value of $N$:

table[4] // Map[{s, n} /. {#[[1]], #[[2, 1, 1]]} &] // 
  MapApply[Callout] // Plot[#, {ϵ, 0, 0.5}] &

enter image description here


Important footnote

I imagine that s=$\sigma$>0 imposes that the solution is positive for any $\epsilon$. In that case, one is excluding solutions that are positive or negative depending on the value of $\epsilon$. To be safe one should perhaps remove the $\sigma$>0 constraint above.

$\endgroup$
4
  • $\begingroup$ Thank you so much for the detailed answer. And, yes I should have mentioned the constraints like $\sigma > 0$ and $N$ is an integer. $\endgroup$
    – CfourPiO
    Commented Dec 22, 2022 at 10:02
  • 1
    $\begingroup$ @CfourPiO Actually, imposing $\sigma>0$ might exclude solutions that are positive or negative depending on the value of $\epsilon$. Hence, that constraint should be removed in the scenario of the code above. $\endgroup$ Commented Dec 22, 2022 at 19:28
  • 1
    $\begingroup$ @CfourPiO I made an edit but maybe don't bother much with it, I just did some cleaning and removed the claim that Root with a transcendental function is not really symbolic. What I meant is that you did not have a function depending on another variable just a single number for a given choice of parameters. $\endgroup$ Commented Dec 22, 2022 at 20:39
  • $\begingroup$ Thanks for the clarification. $\endgroup$
    – CfourPiO
    Commented Dec 23, 2022 at 9:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.