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

Functions with x in different base.

  1. May 8, 2006 #1
    How can I do functions in different bases, other than 10?
    Like for example, f(x) where x is in base 7.
    I'd also like to know how to input such functions into mathematica
    For example lets say, f(x) = log x but x must be only in base 7.
    Thanks,
     
  2. jcsd
  3. May 8, 2006 #2

    Zurtex

    User Avatar
    Science Advisor
    Homework Helper

    Just because you are changing the numeral system does not mean you are changing the function.

    The function is exactly the same, the only difference is how you display numbers.
     
  4. May 8, 2006 #3
    Thanks, and can you show my some examples of such functions, and possible input into mathematica?
     
  5. May 8, 2006 #4

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    The functions wouldn't be input into Mathematica any differently. All you'd do is express the inputs and final answers in a different base.

    Functions don't have bases; only the place-notation representations of numbers have bases.

    - Warren
     
  6. May 8, 2006 #5

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    In Mathematica, use the notation B^^xxxxx to enter numbers in bases other than 10.

    For example, enter

    2^^100000000

    to enter 256 in base 2.

    To display a number in another base, use BaseForm[], like this:

    BaseForm[256, 2]

    - Warren
     
  7. May 8, 2006 #6
    thanks chroot, that is pretty obvious. Can you also show me
    how to graph f(x)=log x where both x's are in base 7 (actually can be any base except for 10)?
    I'd really appreciate
     
  8. May 9, 2006 #7

    Zurtex

    User Avatar
    Science Advisor
    Homework Helper

    You seem to be missing the point.

    You graph the function f(x) = log x independently of what numeral system you are working in. The only difference is if you were to put numbers on the graph, they would just look different, but they would still be the same numbers.

    So in your case with f(x) = log x, you draw exactly the same graph, except where you might have put the number 7 on the graph, you replace it with 10. But they are still the equivalent number, they just look different.
     
  9. May 10, 2006 #8
    Would using the Roman symbols for numbers (ie I, II, III, IV, V, VI, VII etc) mean you plot the graph y = log(x) differently? No, of course not. Writing numbers in a different base is exactly the same principle, you're just writing them down in a different way, not changing them.
     
  10. May 10, 2006 #9
    I'm probably being mighty stupid here but lets say I do a plot of log2(x)
    so using x as the argument, when x is 2, y is 1...when x is 4, y=2, and so on...
    now lets try base 10...
    using x as the argument, when x is 10, y is 1...when x is 100, y=2, and so on...

    such that the same y's are obtained from different x's...ie; two different graphs.

    I really don't want to question the wisdom of far wiser and intelligent people but the idea that for any base the function loga(x) yields the same graph would confuse the hell out of me!

    I suspect that what heartless really wants to know (but didn't ask for it properly)... is how to construct graphs in mathematica using the same argument 'x' to different bases such that x maps to y differently, not how to express the argument x in base a or base b etc...I cannot offer any suggestions with that though.

    (apologies if my terminology is incorrect in places)
     
    Last edited: May 10, 2006
  11. May 10, 2006 #10

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    The "base" of a logarithm and the "base" of numeral representation are not the same thing, GregA.

    - Warren
     
  12. May 10, 2006 #11
    ok, thanks. Let me ask you the very last question. How can I prompt mathematica to display numbers in different bases on the graph? For example normally it would count numbers consecutively 1.....8, 9, 10, 11... and so on,
    but I'd like it to graph it the way given base goes, for example, 1....6, 10, 11 and so on.
     
  13. May 11, 2006 #12
    I know :wink: ...It just seemed more likely from the posts and replies that heartless wanted to do plots of say log2(x) and log8(x) etc...as opposed to numbering x as 00,01,10,11 etc... or 0,1,2....,7,10,11 etc... I still believe it was worth raising the possibility...even though I was completely wrong! :redface:
     
    Last edited: May 11, 2006
  14. May 25, 2006 #13
    similar question

    if you would like to convert a number from binary to decimal, you can say
    decimal=2^^binary

    but
    f[binary_]:=2^^binary will not do this

    the function is assuming a decimal input and so things like
    binary=5 lead to 2^^5 which doesnt make sense

    so i guess in this way, functions (in mathematica) which are representations of functions *do* care about the base
    you certainly can't ask it to evaluate Sin[12a5f]

    how can we fix this? do we have to resort to making the variables strings etc?
     
  15. May 25, 2006 #14

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    You can do Sin[16^^12a5f]

    - Warren
     
  16. May 25, 2006 #15
    warren
    Sin[16^^12a5f] works

    f[x_]:=Sin[16^^x] does not
     
  17. May 25, 2006 #16

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    dorky,

    I know. The second statement,

    f[x_]:=Sin[16^^x]

    makes no sense. The sine function doesn't care at all what base you use to express your numbers. If you declared the function like this:

    f[x_]:=Sin[x]

    then you could use it with decimal, f[9], or hexadecimal, f[16^^12a5f], or any other base you want.

    The point remains: NUMERALS HAVE BASES, NUMBERS AND FUNCTIONS DO NOT.

    - Warren
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?