0
$\begingroup$

I would like to solve an equation like this $\frac{\log(2)}{\log(3)}=\frac{n-0.5}{k-0.5}$ where $n$, $k$ are positive integers and $\log$ is natural logarithm. Of course, I can do only numerical approximation, because $\log(2)$ is not a rational number (transcendental), but if I tell to Mathematica NSolve with assumptions $n$, $k$ integers, then it does not work or return me not integer values for $n$ and $k$.

Also, I understand that it is not 100% proper equation, because there are 2 variables and 1 equation, but I need to get any $n$ and $k$ which will make it equals or minimum possible integer $n$, $k$ with the specified precision. But maybe there is a way...

$\endgroup$
4
  • $\begingroup$ Please post input code for this. $\endgroup$ Nov 28, 2018 at 23:08
  • $\begingroup$ You are not "solving an equation" when you're finding variables that minimize an expression. Restate your question incorporating your precision requirement. $\endgroup$ Nov 28, 2018 at 23:33
  • $\begingroup$ @DavidG.Stork It is not a minimize task. It is about finding one of many possible solutions. Maybe it is called differently, I would call it "select the appropriate value which satisfies equation". $\endgroup$
    – Zlelik
    Nov 29, 2018 at 18:35
  • $\begingroup$ Of course it's an optimization. There is no exact solution. The best to expect is an approximation. For that, there will be a tradeoff between the size of the integers {n,k} and the closeness of approximation. $\endgroup$ Nov 29, 2018 at 23:45

4 Answers 4

2
$\begingroup$
FindInstance[
  Log[2]/Log[3] - (n - 1/2)/(k - 1/2) < .005 && {n, k} > 1, {n, k}, Integers]
(* {{n -> 198, k -> 24}} *)
$\endgroup$
2
  • $\begingroup$ It should be RealAbs[Log[2]/Log[3] - (n - 1/2)/(k - 1/2)] instead of [Log[2]/Log[3] - (n - 1/2)/(k - 1/2)], is not so? $\endgroup$
    – user64494
    Nov 29, 2018 at 8:03
  • $\begingroup$ Yes, it does not work without RealAbs. 198 and 24 is not correct, k should be bigger than n. This one works FindInstance[ RealAbs[Log[2.0]/Log[3.0] - (n - 1/2)/(k - 1/2)] < 0.001 && {n, k} > 1, {n, k}, Integers]. If I put Log[2] instead of Log[2.0] it does not work too. $\endgroup$
    – Zlelik
    Nov 29, 2018 at 18:31
1
$\begingroup$

One can get good estimates from the convergents of a modest precision continued fraction approximation to Log[3]/Log[2]. In this case we require odd numerator and denominator (to account for the fact that the desired approximation is equivalent to (2*n-1)/(2*k-1)).

Convergents[ContinuedFraction[N[Log[3]/Log[2], 20]]]

(* Out[117]= {1, 2, 3/2, 8/5, 19/12, 65/41, 84/53, 485/306, 1054/665, \ 24727/15601, 50508/31867, 125743/79335, 176251/111202, 301994/190537, \ 16785921/10590737, 17087915/10781274, 85137581/53715833, \ 272500658/171928773, 357638239/225644606, 630138897/397573379} *)

So some "good" approximate solutions are {n,k}={(65+1)/2,(41+1)/2}={33,21} and {n,k}={(24727+1)/2,(15601+1)/2}={12364,8701}`.

Here are the discrepancies.

In[120]:= N[Log[3]/Log[2] - (33 - 1/2)/(21 - 1/2)]

(* Out[120]= -0.00040335293738 *)

In[121]:= N[Log[3]/Log[2] - (12364 - 1/2)/(7801 - 1/2)]

(* Out[121]= -1.68253566635*10^-9 *)

$\endgroup$
0
$\begingroup$

I could be wrong, but I'm fairly certain the reason that Mathematica is not returning a result is that there are no integers which solve the equation you provided.

FindInstance[Log[2]/Log[3] == (n-1/2)/(k-1/2), {n, k}, Integers]

returns an empty list. However,

FindInstance[Log[2]/Log[3] == (n-1/2)/(k-1/2), {n, k}, Reals]

does return an answer of n = 0 and k = 1/2 - Log[3]/(2 Log[2]).

Log[2]/Log[3] is an irrational number. For integer n and k, if we subtract 1/2 from each, we'll find ourselves with a decimal of 0.5 after each number. If we multiply the top and bottom by 2, we have an integer on the top and an integer on the bottom. This means the right hand side is rational, and the left side is irrational. This equation has no solution for integer n and k.

$\endgroup$
3
  • $\begingroup$ This one works fine FindInstance[ RealAbs[Log[2.0]/Log[3.0] - (n - 1/2)/(k - 1/2)] < 0.001 && {n, k} > 1, {n, k}, Integers] and after I get n and k validation works fine. $\endgroup$
    – Zlelik
    Dec 1, 2018 at 21:13
  • $\begingroup$ @Zlelik I guess I misunderstood your question. I thought you were looking for exact integers. On reading it again, I realize you were just looking for integers that are close. I'm glad you were able to find an answer! $\endgroup$
    – MassDefect
    Dec 4, 2018 at 17:11
  • $\begingroup$ Yes, you are right. As I mentioned, the exact solution does not exist, because Log[2] and Log[3] are transcendental numbers, which cannot be written as a fraction of integers. $\endgroup$
    – Zlelik
    Dec 6, 2018 at 8:31
0
$\begingroup$

Continued fraction representation is a clever approach.

Convergents[Log[2]/Log[3], 10] // N

Convergents is related ContinuedFraction, better lockup the Mathematica documentation. The numbers in nominator and denominator are as required uneven and can be solved for {n,k}. The convergence is rapid and the solution row of tuples can be kept short. Another approach ist Rationalize.

Table[Rationalize[Log[2]/Log[3], 0.01^k], {k, 1, 10}]

But for the approximation with 0.01 the solutions are often even and no solution for {n,k} exists.

Since the task is to explore natural numbers {n,k} a selection method is in a generative manner requested to get good approximations to the real number of the given quotient of the natural logarithms of 2 and 3. One nice approach is the Mercator representation of the logarithm: http://mathworld.wolfram.com/MercatorSeries.html log[1+x] with 1 instead of 2 and the corresponding for 3. http://mathworld.wolfram.com/images/equations/MercatorSeries/NumberedEquation1.gif Calculate the finite partial sum of the infinite sums and convert the rationalized quotient and you will go well, most probable. Your ratio is the reciprocal of the Hausdorf dimension for the Sierpinski triangle. For example, the Cantor set, a zero-dimensional topological space, is a union of two copies of itself, each copy shrunk by a factor 1/3; hence, it can be shown that its Hausdorff dimension is log(2)/log(3) ≈ 0.63. This leads to nice representations. Within Mathematica this start is http://mathworld.wolfram.com/CantorSet.html. or stick to the finite sum concept and select the series expansion, taylor series like on this overview page http://www.math.com/tables/expansion/log.htm. A good approximation is

 {Log[2]/Log[3] // N, 53715833/85137581 // N}

With is both

0.63093

up to five digit precision.

{n,k}={26857917,42568791}

with emerges from the 8´s term in the shown Rationalize approximation series. The Convergents approach take 10 and is therefore much solver in convergence and the Rationalize paths.

The series expansion are much more complicated and not really in the question included. The mathematical interpretation is therefore far beyond the scope of the question.

$\endgroup$

Your Answer

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

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