问题
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)
.
回答1:
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
回答2:
or use float :
float(log(8)/log(2));
gives:
2.999999999999999
来源:https://stackoverflow.com/questions/36271504/how-to-evaluate-logarithms-in-maxima