Results 1 to 16 of 16

Thread: [resolved] True False - Division by zero

  1. #1

    Thread Starter
    Fanatic Member WorkHorse's Avatar
    Join Date
    Jul 2002
    Location
    Where you live.
    Posts
    591

    [resolved] True False - Division by zero

    Is there such an equation where n=0 returns value t=0 or otherwise returns a constant, such as t=1? t = n/n works, but 0/0 results in a divsion by zero problem. Is there an equation to get the same result without division by zero?
    Last edited by WorkHorse; Dec 4th, 2003 at 02:15 AM.

  2. #2
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431
    y=x

    x=1; y=1
    x=0; y=0

    No division by zero needed

    Did you mean to return the same constant every time?
    Last edited by jemidiah; Dec 4th, 2003 at 12:12 AM.
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  3. #3

    Thread Starter
    Fanatic Member WorkHorse's Avatar
    Join Date
    Jul 2002
    Location
    Where you live.
    Posts
    591
    Return the same value for t no matter what n is, except when n is zero.

    t = the equation of n

    VB Code:
    1. n = 1                                t = 1
    2. n = 0.00000000000001   t = 1
    3. n = 958.54                       t = 1
    4. n = 65487                        t = 1
    5. n = -1                               t = 1
    6. n = -0.6598                      t = 1
    7. n = -9999                         t = 1
    8. n = -456.78                      t = 1
    9. n = 0                                t = 0
    (I can't get the spacing to match up, but you see the point.)
    Last edited by WorkHorse; Dec 4th, 2003 at 12:45 AM.

  4. #4
    Frenzied Member dis1411's Avatar
    Join Date
    Mar 2001
    Posts
    1,048
    i dont know y u dont want to use an if then statement but:

    VB Code:
    1. t = Abs(n <> 0)

  5. #5

    Thread Starter
    Fanatic Member WorkHorse's Avatar
    Join Date
    Jul 2002
    Location
    Where you live.
    Posts
    591
    Originally posted by dis1411
    i dont know y u dont want to use an if then statement but:

    VB Code:
    1. t = Abs(n <> 0)
    This begs the question. What is the mathematical equation to determine n <> 0?

  6. #6
    Frenzied Member dis1411's Avatar
    Join Date
    Mar 2001
    Posts
    1,048
    what exactly r u trying to do?

    youre not going to get it much simpler than what i gave

  7. #7

    Thread Starter
    Fanatic Member WorkHorse's Avatar
    Join Date
    Jul 2002
    Location
    Where you live.
    Posts
    591
    I guess I am asking for the mathematical equation for NOT. How can you manually calculate that something is NOT something? Specifically, that something is NOT zero? How can I take any n and trun it to 1, unless n = 0? Is there a formula for n <> 0. Or is there NOT?

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    WorkHorse: n <> 0 is a mathematical inequality, not an equality
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  9. #9
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Re: True False - Division by zero

    Originally posted by WorkHorse
    Is there such an equation where n=0 returns value t=0 or otherwise returns a constant, such as t=1? t = n/n works, but 0/0 results in a divsion by zero problem. Is there an equation to get the same result without division by zero?
    as for this: t=|sgn n|
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  10. #10

    Thread Starter
    Fanatic Member WorkHorse's Avatar
    Join Date
    Jul 2002
    Location
    Where you live.
    Posts
    591
    Originally posted by kedaman
    WorkHorse: n <> 0 is a mathematical inequality, not an equality
    Does that mean t = n <> 0 cannot be expessed more simplicity? The equation operator NOT is what it is by definition and cannot be difined by another equation?

  11. #11

    Thread Starter
    Fanatic Member WorkHorse's Avatar
    Join Date
    Jul 2002
    Location
    Where you live.
    Posts
    591

    Re: Re: True False - Division by zero

    Originally posted by kedaman
    as for this: t=|sgn n|
    Brilliant. That's the ticket. Thank you.

  12. #12
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    well, not is a boolean operator, and you should distinguish between boolean and aritmetic algebra
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  13. #13
    Frenzied Member dis1411's Avatar
    Join Date
    Mar 2001
    Posts
    1,048
    ooops i was thinking in VB

  14. #14
    Fanatic Member sql_lall's Avatar
    Join Date
    Jul 2002
    Location
    Up Above (i.e. AUS)
    Posts
    571

    Talking factorial

    Here's a little trick i used in something recently:
    Code:
    n*(n-1)!
    ----------
        n!
    Note that when n =0, fraction = 0*(-1)!/0! = 0
    and for all else the fraciton = 1;

    I think there may be a slight problem though, as factorials aren't defined for all numbers (n must be a non-negative integer or .5 less than a non-negative integer), but i believe there is a general factorial function, which would provide what is needed.
    sql_lall

  15. #15
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431
    For possibly simplifying n <> 0, the CPU's arithmetic and logic unit handles that by comparing the two numbers logically instead of using some arithmetic operations, so you'd have to find a function that happens to do what sql_lall's does to use the arithmetic method that you're after. BTW, that's pretty clever!
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  16. #16
    Hyperactive Member sw_is_great's Avatar
    Join Date
    Nov 2003
    Posts
    330
    There is a small problem
    n*(n-1)!
    ----------
    n!
    will fail if n or (n-1) is a negative number as factorial of negative number is not defined....

    -1! is not defined...

    so we can use abs for that....
    just a little modification :

    |n|*|(n-1)|!
    ----------
    |n|!
    Regards

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width