0
$\begingroup$

To clarify: I'm creating a computer program and I'm trying to find the actual mathematical way of approaching my problem. Given a number x, a is 0.7x. After doing some testing, it seems that to get back up to x from a, I can multiply by 1.42857143, but sometimes this isn't enough precision and gets a number that is very wrong.

Is there a blatantly obvious solution to this that I can't see? I want to find a better way to solve this without repeatedly adding 1 until it's right.

Thanks!

$\endgroup$
4
  • 7
    $\begingroup$ what are the restraints of your program? could you simply divide by $.7$? $\endgroup$ Dec 28, 2020 at 2:34
  • 2
    $\begingroup$ With finite precision it may actually be impossible to recover $x$ exactly, depending on what gets rounded when. $\endgroup$ Dec 28, 2020 at 2:50
  • $\begingroup$ I can't divide by .7 as it's horribly off. And It's ok with me if it's off slightly, by at most 1. $\endgroup$
    – Emily
    Dec 28, 2020 at 4:41
  • $\begingroup$ What language are you using? You may try Newton Rhapson division but the accuracy depends on multiplication accuracy. $\endgroup$
    – Anvit
    Dec 28, 2020 at 16:31

2 Answers 2

1
$\begingroup$

Precision of operations is limited on computers.

What data type do you use? Float? Double?

To get better precision, you may want to use the types like BigDecimal.

If this is not sufficient, use other tools for programming like Mathematica.

$\endgroup$
1
$\begingroup$

Ooooookay so it looks like I'm an idiot. 1.42857143 is 10÷7, and somehow I didn't notice that. I can simply just repeat the value if I want more precision.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged .