1
$\begingroup$

I have the following as the first step to a sequence.

x = 2 - GoldenRatio;
Ceiling[x + x^(1/2)]

It gets a precision exception. The value is correct, but I would like to prevent the exception. (If we subtract 0.000001 from x, everything is fine.)

Is there a way to limit the precision? For one step only?

Edit: the sequence where 2-GoldenRatio is the seed.

x = 2 - GoldenRatio; t = Table[(x = Ceiling[x + x^(1/2)]), {2000}];

If ceiling is removed the first step works fine. However, I need the ceiling for alternate steps.

Edit2: $0 < x \leq 2-\phi$ where $\phi$ is the golden ratio. $\textit{When x = 2 - $\phi$, the first step equals $1$}$.

$\endgroup$
1
$\begingroup$

Does this get you what you need:

x = N[2 - GoldenRatio]
Ceiling[x + x^(1/2)]

0.381966
1

This doesn't get a precision exception.

This as per the update of your question also works without getting an error.

x = N[2 - GoldenRatio];
t = Table[(x = Ceiling[x + x^(1/2)]), {2000}];
$\endgroup$
  • $\begingroup$ That's the ticket! $\endgroup$ – Fred Kline Jul 10 '12 at 3:03
0
$\begingroup$

Perhaps you could make a value inexact:

x = 2` - GoldenRatio;
x + x^(1/2)
1.

Or use FullSimplify:

x = 2 - GoldenRatio;
x + x^(1/2) // FullSimplify
1
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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