Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Is it possible to find function that describes irrational things?

  1. Aug 8, 2008 #1
    i.e. decimals of an irrational number, pi(n), etc.

    The function itself, f(n), can change with n, as long as it changes in a patterned way.

    This seems like a straight foreword question, either you can for all, or you can't for all. A simple example of a changing function would be the Fibonacci sequence.

    Also, do you think that a function such as this(one that describes an irrational thing), could have to do with a floor, ceiling, or some type of rounding, function?
  2. jcsd
  3. Aug 8, 2008 #2


    User Avatar
    Science Advisor

    Perhaps you need to give more detail about what you want.

    "f(n)= the nth decimal place of [itex]\pi[/itex]" is a perfectly good function that gives "decimals of an irrational number".
  4. Aug 8, 2008 #3
    Can you define f(n) using n and/or [tex]\pi[/tex] in such a way where the change in f(n) is considered patterned?

    Edit: Basically what I'm asking is, is it possible to make prime a counting function, where (if [tex]\pi_k(n)[/tex] changes with [tex]n_k[/tex]) [tex]\pi_k(n)[/tex] is patterned.
    Last edited: Aug 8, 2008
  5. Aug 8, 2008 #4


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    It's really not clear what you're asking for. But I can answer one specific thing: there are straightforward formulas for the n-th decimal digit of a real number, such as

    [tex]\left\lfloor 10^{-n} x - 10 \left\lfloor 10^{-n-1} x \right\rfloor
  6. Aug 8, 2008 #5
    Here is my question the simplest way I can put it:

    Is there a way to define [tex]\pi(n)[/tex](prime counting function), for all n?
  7. Aug 8, 2008 #6


    User Avatar
    Science Advisor
    Homework Helper

    "[itex]\pi(n)[/itex] is the number of primes less than or equal to n."

    Are you asking if there is a closed-form expression for this? In that case, the answer is still yes; MathWorld and Wikipedia both have pages on this (something like 'prime formulas').
  8. Aug 8, 2008 #7
    I got this from wikipedia. This is sort of the question I was asking. I wondering whether a P(n) function exists for all n. It clearly states no, which is what thought for a non-constant polynomial function, but what about a function that constantly changes to a pattern? A poor example:

    [tex]P_1=\sum^n_{k=0}(n_{n-k})*((2n-1)+P_{n-1})mod(\lfloor tan^n(\frac{2\pi}{2\pi+n})\rfloor) [/tex]

    [tex]P_2=\sum^n_{k=0}(n_{n-k})*((2n-1)+P_{n-1})mod(\lfloor tan^n(\frac{2\pi}{2\pi+n})\rfloor) + \lfloor \prod^{P_{n-1}}_{k=n}(ln(k))\rfloor[/tex]

    [tex]P_3=\sum^n_{k=0}(n_{n-k})*((2n-1)+P_{n-1})mod(\lfloor tan^n(\frac{2\pi}{2\pi+n})\rfloor) + \lfloor \prod^{P_{n-1}}_{k=n}(ln(k))\rfloor - \lfloor \prod^{P_{n-2}}_{k=n}(ln(k))\rfloor[/tex]

    This function probably makes no sense at all, it was just an example.
  9. Aug 8, 2008 #8


    User Avatar
    Science Advisor
    Homework Helper

    Such functions certainly exist, they're just not polynomials (unless they're constant). An example would be the function P_n, which sends a positive integer n to the nth prime.
  10. Aug 8, 2008 #9


    User Avatar
    Science Advisor
    Homework Helper

    Here, I sense a communication problem. When you say "function", I think you mean to say "closed-form expression". Is that right?
  11. Aug 11, 2008 #10
    The integral of 4/(1+t^2) with respect to T from 0 to X describes pi if X = 1.

    [tex]\pi\ = \int_{0}^1\frac{4}{1 + t^2} dt[/tex]
  12. Aug 12, 2008 #11
    This is only true if you setup a constraint i.e. if x=1.

    Here's a question, can an expression of any kind, describe the change from any prime to the next prime?
  13. Aug 12, 2008 #12
    You have so many undefined terms it is impossible to know where to begin.

    What does 'the change from prime to prime' even mean? As has been pointed out before, functions can be defined that describe *anything*, the only question is whether that function has a 'nice' form, or can be calculated quickly. But you'd need to define what you consider 'nice' and 'quickly' to mean.
  14. Aug 12, 2008 #13
    I think this is what I was looking for:
    [tex]p_n = 1 + \sum_{m=1}^{2^n} \left\lfloor \left\lfloor { n \over 1 + \(\sum_{j=2}^m \left\lfloor {(j-1)! + 1 \over j} - \left\lfloor{(j-1)! \over j}\right\rfloor \right\rfloor) } \right\rfloor^{1 \over n} \right\rfloor[/tex]

    An expression in the form [tex] P_n=f(N_p)[/tex], where everything is defined.
  15. Aug 12, 2008 #14
    Well, yes. But that IS a function that describes an irrational number in a non-circular fashion (i.e, a function f(x) = [tex] \pi\ =\ 3.14159265358979323 [/tex] would be circular)

    Ummm... I don't think so. I mean there are obviously functions that one could write that could do that. But since that would involve using if-then statements I don't know if it would qualify as an expression.
  16. Aug 13, 2008 #15


    User Avatar
    Science Advisor
    Homework Helper

    Of course. One expression would be "the difference between the (n+1)th prime and the nth prime". Another would be [itex]p_{n+1}-p_n.[/itex] Another, using your expression above, would be

    [tex]\sum_{m=1}^{2^{n+1}} \left\lfloor \left\lfloor { {n+1} \over 1 + \(\sum_{j=2}^m \left\lfloor {(j-1)! + 1 \over j} - \left\lfloor{(j-1)! \over j}\right\rfloor \right\rfloor) } \right\rfloor^{1 \over {n+1}} \right\rfloor - \sum_{m=1}^{2^n} \left\lfloor \left\lfloor { n \over 1 + \(\sum_{j=2}^m \left\lfloor {(j-1)! + 1 \over j} - \left\lfloor{(j-1)! \over j}\right\rfloor \right\rfloor) } \right\rfloor^{1 \over n} \right\rfloor[/tex]
  17. Aug 13, 2008 #16


    User Avatar
    Science Advisor
    Homework Helper

    Let's standardize our terminology here:
    • Expression: any well-formed mathematical statement. Examples: x = y, y + 3, "the set of numbers one greater than a prime", and any of the below.
    • Function: an expression which relates any x from the function's domain to exactly one y from the function's codomain. Examples: the function from the set of people on Earth to the set {Jan 1, Jan 2, Jan 3, ..., Dec 30, Dec 31} defined by f(x) = the birthday of x, or any of the closed-form functions below.
    • Closed-form expression: an expression which can be written with a particular subset of the symbols, say {+, -, *, /, ^, %, sum, !, 0, 1, floor, sin} plus function variables. Examples: 7! or any of the closed-form functions below.
    • Closed-form function: a closed-form expression which is a function. Examples: f(x) = sin (x), f(n) = [itex]\lfloor\sqrt n\rfloor.[/itex]
  18. Aug 13, 2008 #17
    I was under the impression that there existed no type of function or expression that took the form of [tex]P_n=f(N_p)[/tex]. I originally assumed this because 1) I've been told numerous times that there wasn't (probably told that there was no function), and 2) everybody makes a huge deal about the distribution of primes and finding an easy way to find all of the primes, and so I thought there existed no expression.

    Here's a final question, why, if we already have an expression in the form, [tex]P_n=f(N_p)[/tex], are people still searching for high prime numbers?

    [tex]p_n = 1 + \sum_{m=1}^{2^n} \left\lfloor \left\lfloor { n \over 1 + \(\sum_{j=2}^m \left\lfloor {(j-1)! + 1 \over j} - \left\lfloor{(j-1)! \over j}\right\rfloor \right\rfloor } \right\rfloor^{1 \over n} \right\rfloor[/tex]

    Isn't this expression good enough to find any/all of the primes?
  19. Aug 13, 2008 #18


    User Avatar
    Science Advisor
    Homework Helper

    The statement "There is no function that maps a positive integer n to the nth prime" is wrong. The statement "There is no closed-form expression that maps a positive integer n to the nth prime" is wrong, assuming closed-form expressions can use addition, subtraction, multiplication, division, exponents, factorials, indexed sums, and the floor function.

    I'm not being condescending at all with the following statement:
    Anyone who says that there is no formula for the primes doesn't know what they're talking about. There is no sensible interpretation under which that is true.

    Yes, the formula I posted takes something like 2 * 4n factorial calculations, which takes a really long time for n greater than, say, 50. But calculating the difference between the 101st prime and the 100th prime, 547 - 541 = 6, is very easy. So improving on this closed-form expression with efficient algorithms is important.

    Using the formula from post #13 to calculate that p_10 = 29 would take 1024 steps through the main loop. Each pass through the main loop runs the inner loop up to 1023 times. Each pass through the inner loop requires the calculation of two factorials, which may be as large as 1023! > 102336. In total, over a million factorials are computed, most of which are huge.

    But you can instead check each number from 1 to 30 for divisibility by 2, 3, and 5 to determine that 29 is the 10th prime.

    This method, millions of times faster than the formula from post #13, is called "trial division" and is considered too slow to test the primality of any but the smallest numbers.

    Given enough time that expression will (presumably) find any prime desired. But using a dual-core 1 THz computer, finding the 100th prime with that method would take longer than the life of the universe.
  20. Aug 13, 2008 #19


    User Avatar
    Science Advisor
    Homework Helper

    Here's a time comparison for finding the kth prime.

    If factorials are calculated directly, the formula from post #13 takes [itex]O(8^{k+\varepsilon})[/itex] multiplications,with yet higher bit complexity.

    Trial division takes [itex]O(\sqrt n)[/itex] time for each number, so [itex]O(k\sqrt k)=O(n^{1.5})[/itex] time overall. (Actually it's not quite that bad, since most will exit early.)

    APR takes [itex]O((\log n)^{\log\log\log n})[/itex] and AKS takes [itex]O((\log n)^{12}[/itex] for each prime, so the test with either would take [itex]O(k^{1+\varepsilon})[/itex] total steps. (Efficient versions of AKS exist which take substantially less time, but it's not relevant here.)

    The real way to do the problem is with the sieve of Eratosthenes, which takes time [itex]O(k\log k\log\log k).[/itex] It might not seem like much of an improvement on the above, but it's far simpler and millions of times faster. (No one would use the above for this purpose; that would be silly.)

    The sieve of Atkin, though not as simple as the above, is faster at [itex]O(k/\log\log k).[/itex] This is the first sublinear algorithm for the problem from the list so far.

    Meissel's method counts primes up to a given bound. It takes [itex]O(k/(\log k)^3)[/itex] time, and once you have that it takes negligible effort to find the prime needed with a small sieve and binary search.

    Mapes' method, an improved way to count primes, takes only [itex]O(k^{0.7})[/itex] and so is the first method on this list that finishes in time o(k).

    The Lagarias-Miller-Odlyzko method is the current best, taking [itex]O(k^{2/3}).[/itex]
  21. Aug 21, 2008 #20
    yes, there are formulas for many of these functions. Mathworld has a lot of them on their site, as well as many more number theoretic formulae.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook