Infinite loop

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • user923005

    #31
    Re: Infinite loop

    On Mar 20, 8:32 pm, "user923005 " <dcor...@connx. comwrote:
    /*
    Here's my version of your 1/e program:
    */
    I call it a 1/e program be cause the divided difference for one unit
    step is A(n)/A(n+1) = 1/e (approximately)

    You could also call it an e program, because you can get the same
    series (asymptotically ) by multiplying the previous term by e.

    e.g.
    ....
    9.0000000000000 00000 27145.247361213 536000000
    10.000000000000 000000 73788.778437947 738000000

    27145.247361213 536 * e =73788.43263101 260340026529804 9315

    e.g.
    ....
    99.000000000000 000000
    331282515698122 690000000000000 00000000000000. 000000000000000 000
    99.500000000000 000000
    546192530242544 100000000000000 00000000000000. 000000000000000 000
    100.00000000000 0000000
    900519242508405 510000000000000 00000000000000. 000000000000000 000

    331282515698122 690000000000000 00000000000000 * e =
    900519242508405 302330870179174 11

    Seems to answer pretty nearly.
    Since there are two calls to exp() in there with different args, I
    guess it won't be a good way to calculate e, but I hope it has some
    interesting properties that you are looking for.

    Comment

    • user923005

      #32
      Re: Infinite loop

      On Mar 20, 8:47 pm, "user923005 " <dcor...@connx. comwrote:
      On Mar 20, 8:32 pm, "user923005 " <dcor...@connx. comwrote:
      >
      /*
      Here's my version of your 1/e program:
      */
      >
      I call it a 1/e program be cause the divided difference for one unit
      step is A(n)/A(n+1) = 1/e (approximately)
      >
      You could also call it an e program, because you can get the same
      series (asymptotically ) by multiplying the previous term by e.
      >
      e.g.
      ...
      9.0000000000000 00000 27145.247361213 536000000
      10.000000000000 000000 73788.778437947 738000000
      >
      27145.247361213 536 * e =73788.43263101 260340026529804 9315
      >
      e.g.
      ...
      99.000000000000 000000
      331282515698122 690000000000000 00000000000000. 000000000000000 000
      99.500000000000 000000
      546192530242544 100000000000000 00000000000000. 000000000000000 000
      100.00000000000 0000000
      900519242508405 510000000000000 00000000000000. 000000000000000 000
      >
      331282515698122 690000000000000 00000000000000 * e =
      900519242508405 302330870179174 11
      >
      Seems to answer pretty nearly.
      Since there are two calls to exp() in there with different args, I
      guess it won't be a good way to calculate e, but I hope it has some
      interesting properties that you are looking for.
      A bit of thought shows why it converges to e per unit step.
      exp(x) is [by far] the fastest growing term.
      It could be used as an explanation why O(f(n)) needs (primarily) the
      dominant term to explain the nature of the algorithm for big
      arguments.

      Comment

      • Dave Vandervies

        #33
        Re: Infinite loop [OT]

        In article <1174448304.561 462.223800@o5g2 000hsb.googlegr oups.com>,
        user923005 <dcorbit@connx. comwrote:
        >On Mar 19, 6:23 pm, dj3va...@caffei ne.csclub.uwate rloo.ca (Dave
        >Vandervies) wrote:
        >[snip]
        >Exercise for the reader: Does a finitely describable uncountable set
        >of discrete elements exist?
        >(V guvax gur cbjre frg bs gur frg bs vagrtref dhnyvsvrf.)
        >
        >Vf gurer n sbezny cebbs gung gur frg bs nyy fhofrgf bs gur vagrtref vf
        >hapbhagnoyr?
        Yes.
        Vg'f npghnyyl fyvtugyl zber trareny; nal frg bs nal pneqvanyvgl unf n
        fznyyre pneqvanyvgl guna vgf cbjre frg.
        I can dig the proof out of my algebra notes from a year or two ago
        if you're interested; this is getting rather far OT, so it's probably
        better to email me if you want it. (Using dj3vande at eskimo.com[1]
        will make it rather less likely that I'll delete your email without
        noticing it while clearing the spam out from the address I post with.)


        dave

        [1] Protected from Google, not from spammers.

        --
        Dave Vandervies dj3vande@csclub .uwaterloo.ca
        If only... there were people unburdened by the Hippocratic Oath on
        ambulances, so they could usefully be fitted with rocket launchers.
        --Maarten Wiltink in the scary devil monastery

        Comment

        • Army1987

          #34
          Re: Infinite loop

          you_idiot_one:
          printf("Enter the non-negative starting value\n");
          converted = scanf("%lf", &start);
          if (converted != 1 || start < 0.0) goto you_idiot_one;
          Apart that if, I input some non-numerical data, scanf will try to read it as
          a double over and over again, have you ever heard about "while"? C ain't
          Commodore BASIC...
          I am not one of those structured-programming worshippers who consider it
          immoral to ever write "goto", "break", or "return" anywhere else than as the
          last statement of a function, but here I just can't see how goto helps...

          do {
          printf("Enter the non-negative starting value\n");
          /* You don't even need printf here, */
          /* puts("Enter the non-negative starting value"); would do the job */
          converted = scanf("%lf", &start);
          } while (converted != 1 || start < 0.0)


          Comment

          Working...