Is the Error O(1/n) in Linear Interpolation Correct?

  • Thread starter AxiomOfChoice
  • Start date
  • Tags
    Error
In summary, the conversation discusses a given function f and its values at certain points, as well as linear interpolation between these points. The speaker questions the validity of a claim made in a book, and provides their own calculations to show that the claim may not be accurate. They also mention that the errors in their calculations are bounded by 1/\sqrt n.
  • #1
AxiomOfChoice
533
1
Consider the following situation. You know, for a given function [itex]f[/itex] and [itex]i,k \in \mathbb N \cup \{ 0 \}[/itex], [itex]n\in \mathbb N[/itex], that

[tex]
f \left( \frac kn \right) = \frac{i}{\sqrt n}.
[/tex]

In addition, you know that either

[tex]
f \left( \frac{k+1}{n} \right) = \frac{i-1}{\sqrt n}
[/tex]

-OR-

[tex]
f \left( \frac{k+1}{n} \right) = \frac{i+1}{\sqrt n}.
[/tex]

And suppose that you linearly interpolate between k/n and (k+1)/n. The book I'm reading claims that, for any t between k/n and (k+1)/n, we have

[tex]
f(t) - f \left( \frac{\lfloor tn \rfloor}{n} \right) = O(1/n).
[/tex]

where of course I have referred to the floor function. (Incidentally, if [itex]\frac kn \leq t \leq \frac{k+1}{n}[/itex] as assumed, doesn't it follow that [itex]\lfloor nt \rfloor = k[/itex]?) Question: IS THIS (the part about O(1/n)) RIGHT? I don't think it is.
 
Last edited:
Physics news on Phys.org
  • #2
I've calculated, and it seems to me that if the FIRST option obtains, we have

[tex]
f(t) - f \left( \frac{\lfloor tn \rfloor}{n} \right) = \frac{k - tn}{\sqrt n},
[/tex]

whereas if the SECOND option obtains, we have

[tex]
f(t) - f \left( \frac{\lfloor tn \rfloor}{n} \right) = \frac{tn - k}{\sqrt n}.
[/tex]

So I know EXACTLY what the errors are as a function of [itex]t[/itex], and in either case they are bounded by [itex]1/\sqrt n[/itex], simply because [itex]|tn - k| \leq 1[/itex]. Have I done something wrong?
 

FAQ: Is the Error O(1/n) in Linear Interpolation Correct?

What is the meaning of O(1/n)?

O(1/n) refers to the time complexity of an algorithm, where the time taken for the algorithm to run is directly proportional to the inverse of the size of the input (n).

How is O(1/n) different from other time complexities?

O(1/n) is considered a constant time complexity, meaning that the time taken for the algorithm to run remains the same regardless of the size of the input. This is different from other time complexities, such as O(n) or O(n^2), where the time taken increases as the input size increases.

When is an algorithm considered to have an O(1/n) time complexity?

An algorithm is considered to have O(1/n) time complexity when the algorithm's execution time remains constant, regardless of the size of the input. This is often seen in algorithms that involve a single loop or constant number of operations.

How is O(1/n) calculated?

O(1/n) is calculated by determining the number of operations performed by the algorithm in relation to the size of the input. For example, if an algorithm performs 5 operations for an input of size 10, it would be represented as O(1/10).

What are some examples of algorithms with an O(1/n) time complexity?

Some examples of algorithms with O(1/n) time complexity include finding the maximum or minimum element in an array, checking if a number is even or odd, and accessing a specific element in a hash table. These algorithms have a constant execution time, regardless of the size of the input.

Similar threads

Replies
5
Views
1K
Replies
3
Views
2K
Replies
5
Views
2K
Replies
3
Views
2K
Replies
1
Views
1K
Replies
13
Views
2K
Replies
2
Views
2K
Back
Top