# Functions with x in different base.

1. May 8, 2006

### heartless

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. May 8, 2006

### Zurtex

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.

3. May 8, 2006

### heartless

Thanks, and can you show my some examples of such functions, and possible input into mathematica?

4. May 8, 2006

### chroot

Staff Emeritus
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

5. May 8, 2006

### chroot

Staff Emeritus
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

6. May 8, 2006

### heartless

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

7. May 9, 2006

### Zurtex

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.

8. May 10, 2006

### AlphaNumeric

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.

9. May 10, 2006

### GregA

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
10. May 10, 2006

### chroot

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

- Warren

11. May 10, 2006

### heartless

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.

12. May 11, 2006

### GregA

I know ...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!

Last edited: May 11, 2006
13. May 25, 2006

### dorky

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?

14. May 25, 2006

### chroot

Staff Emeritus
You can do Sin[16^^12a5f]

- Warren

15. May 25, 2006

### dorky

warren
Sin[16^^12a5f] works

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

16. May 25, 2006

### chroot

Staff Emeritus
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