4

Following examples from here, and here I tried this:

log2(x) := log(x) / log(2);
log2(8), float;

But this doesn't give 3, instead I get log(8)/log(2).

Adam
  • 1,254
  • 12
  • 25
wvxvw
  • 8,089
  • 10
  • 32
  • 61

3 Answers3

6

You have to simplify radicals:

(%i1) log2(x) := log(x) / log(2);
                                          log(x)
(%o1)                          log2(x) := ------
                                          log(2)
(%i2) radcan(log2(8));
(%o2) 

                             3
kalix
  • 210
  • 1
  • 6
1

or use float :

float(log(8)/log(2));

gives:

2.999999999999999
Adam
  • 1,254
  • 12
  • 25
0

Another way to calculate logarithms in base 10:

You can also write in the command line: load(log10);(enter)

Then for the calculation of the decimal logarithm: log10(100);(Enter) the result is 2, and so on. To exemplify I did some calculations with log10. These results are shown in the picture below

enter image description here

Time Step
  • 45
  • 4