Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert rounded decimal to (approximate) radical value?

I've made a lot of random math programs to help me with my homework (synthetic division being the most fun) and now I'm wanting to reverse a radical expression.

For instance, in my handy TI calculator I get

.2360679775

Well, I want to convert that number to it's equivalent irrational expression, which is

sqrt(5)-2

I realize I could brute force it... but that takes out the fun, and isn't nearly so easy when you consider the significant round-off error of floating point.

So how would you do it? Is there is a trivial algorithm?

like image 594
Earlz Avatar asked Feb 19 '10 06:02

Earlz


2 Answers

Inverse Symbolic Calculator

(I originally linked to this which seems to be gone.)

like image 161
Darius Bacon Avatar answered Sep 21 '22 22:09

Darius Bacon


Well, your example hasn't actually transformed the input to the equivalent irrational expression, but to an equivalent irrational expression. As the Inverse Symbolic Calculator indicates, there are many candidate irrational expressions within a tolerance of the decimal number in your example, and there will be just as many irrationals within any degree of tolerance of any decimal number you specify. It's all to do with the density of irrationals along the number line.

So to answer your questions:

  • I would limit myself to a number of terms such as sqrt(2), sqrt(3), sqrt(small prime numbers), e, pi, and integers, plus rationals with small prime denominators and approximate the decimals with a few terms based on those plus the four basic arithmetical operators;
  • Is this algorithm trivial ? You decide. In general, though, I think it will be impossible to find an algorithm for determining a canonical representation of any decimal fraction as a series of irrational terms and integers, for the simple reason that no such canonical representation exists.

But then, my real and irrational maths is very rusty, I look forward to proofs that I am wrong and counter-examples.

like image 28
High Performance Mark Avatar answered Sep 24 '22 22:09

High Performance Mark