1
$\begingroup$

I have several doubts about notation. I would appreciate any clarifications.

a) I can express, for example, a periodic or semi-periodic number without writing it in its rational form. Can such notation be recognized by Mathematica?

Examples:

$$a= 0. \bar{8}, b= 1.34\bar{5}$$

b) If I do the a/b operation with the numbers above, how do I force Mathematica to write the result in a non-decimal rational form?

c) How do I solve the following equations involving nested radicals?

$$\sqrt{x+\sqrt{x+\sqrt{x+...}}}=12$$ $$\sqrt{x+\sqrt{x-\sqrt{x+\sqrt{x-...}}}}=15$$

edit It seems that I did not express myself very well. If I have any rational decimal as a result, how can I get MMA to express it to me in the form a/b? Apologies for putting more than one question, I thought they were part of the same

$\endgroup$
5
  • $\begingroup$ For your first query about repeating decimals: see 15818 $\endgroup$
    – Syed
    Commented May 6, 2022 at 2:58
  • $\begingroup$ For c) take a look at mathematica.stackexchange.com/questions/87359/…. $\endgroup$
    – JimB
    Commented May 6, 2022 at 3:31
  • 2
    $\begingroup$ Please don't ask multiple distinct questions in one post. It's not obvious how question (c) is related to the former 2 questions. $\endgroup$
    – xzczd
    Commented May 6, 2022 at 3:34
  • $\begingroup$ For $a$, we have FromDigits[{{0, {8}}, 1}] and for $b$ FromDigits[{{1, 3, 4, {5}}, 1}]. You can look up the docs for the input syntax of FromDigits/RealDigits. $\endgroup$
    – Michael E2
    Commented May 7, 2022 at 23:34
  • $\begingroup$ For c), if $a_n\rightarrow y$, then Solve[{y == Sqrt[x + y], y == 12}, {y, x}] and Solve[{y == Sqrt[x + Sqrt[x - y]], y == 15}, {y, x}] can be used to solve for x. $\endgroup$
    – Michael E2
    Commented May 8, 2022 at 0:26

2 Answers 2

6
$\begingroup$
Clear["Global`*"]

a = ResourceFunction["RepeatingDecimalToRational"][0.8, 1]

(* 8/9 *)

a // N[#, 20] &

(* 0.88888888888888888889 *)

b = ResourceFunction["RepeatingDecimalToRational"][1.345, 1]

(* 1211/900 *)

b // N[#, 20] &

(* 1.3455555555555555556 *)

EDIT: If you do not wish to use ResourceFunction["RepeatingDecimalToRational"], RootApproximant or Rationalize will often give the desired result depending on the precision involved.

bd = 1211/900.

(* 1.34556 *)

#@bd & /@ {RootApproximant, Rationalize}

(* {1211/900, 1211/900} *)

However,

bd2 = 1211/900.0`9

(* 1.34555556 *)

#@bd2 & /@ {RootApproximant, Rationalize, Rationalize[#, 0] &}

(* {Root[-2 + #^3 - 3 #^5 - #^6 + #^7 + #^8& , 2, 0], 1.34555556, 1211/900} *)

END EDIT

Equate the functions in terms of themselves

Solve[(SolveValues[{f1 == Sqrt[x + f1], f1 > 0, x > 0}, f1][[1]] // 
  Normal) == 12, x][[1]]

(* {x -> 132} *)

Check:

With[{x = 132.0`10},
 FixedPointList[Sqrt[x + #] &, 1]]

(* {1, 11.532562595, 11.980507610, 11.999187790, 11.999966158, \
11.999998590, 11.999999941, 11.999999998, 12.000000000, 12.000000000} *)

Next function

Solve[(SolveValues[{f2 == Sqrt[x + Sqrt[x - f2]],
        f2 > 0, x > 0}, f2][[1]] // Normal) == 15, x][[1]]

(* {x -> 211} *)

Check:

With[{x = 211.0`10},
 FixedPointList[Sqrt[x + Sqrt[x - #]] &, 1]]

(* {1, 15.016370292, 14.999980511, 15.000000023, 15.000000000, \
15.000000000} *)
$\endgroup$
1
$\begingroup$

Look at:

enter image description here

If you square this expression you get:

x+12 == 12^2

and

x== 12^2-12 == 132

Not much more complicated is:

enter image description here

Squaring results in :

x + Sqrt[x-15] == 15^2
Solve[x + Sqrt[x - 15] == 15^2, x]

enter image description here

$\endgroup$
2
  • $\begingroup$ I understand how to do it by hand, I wanted to know how to do it in MMA $\endgroup$
    – BeTDa
    Commented May 7, 2022 at 3:09
  • $\begingroup$ The idea that after squaring the original LHS is reproduced is beyond MMA. AI has still a long way to go. And it does not hurt to think a little. $\endgroup$ Commented May 7, 2022 at 7:16

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