As I mentioned before, one of the areas of OneNote I took when I came to the team was what we call "Napkin Math." This the ability to type equations like

8-4= And getting a "4" when you press Enter or the spacebar.

It also works for basic trigonometric functions like

Sin(45)=0.707106781186547 (note this is based on 90 degrees)

So far, so good. But I hit a snag with logarithms.

Try this:

Case 1: Type

Ln(2.718)=

And hit enter. You get 0.999896315728952, right?

Great. This is the natural log of 2.718.

Case 2:

Now try:

Log10(100)=

And hit enter (or space). You get 2, right? This is the base 10 log of 100, and again, OneNote gets it right.

Case 3:

Now try this:

Log(10)=

And you get 2.302585092994046. Hmm. What number raised to 2.302585092994046 results in 10? The answer is e, the natural log. OK, mathematically, this makes sense, but every textbook I've used in school would say log(10)=1.

All of my textbooks, and the Windows & Macintosh calculators, Excel and probably every physical calculator would evaluate log(10) as being base 10. So here OneNote is in seeming disagreement with the rest of the (English speaking) world. Based on this unexpected behavior, I entered a bug in our database. My next task was to help figure out where things went wrong and help develop a plan to fix the problem.

As it turns out, nothing is wrong. Here's why.

As I typically do when OneNote does something I do not understand, I went to talk with Irina, another tester on our team. She has a Master's degree in Math, and since I only have a BA in Math, she automatically knows more than me. She said it's only in America that log(x) has any meaning, as most math books in the rest of the world use lg(x) to denote base 10 logs. Hmm, and an interesting clue. What to do?

I turned next to the fountain of all human knowledge: the internet. And buried in the National Institute of Standards and Technology documentation about how to represent just about any mathematical expression in typography , I found exactly how logarithms are expected to be typeset [in section 10.1.2]. Here's the link, and what follows is the gist of it as it relates to logs:

ln x |
(ln x = loge x) |

lg x |
(lg x = log10 x) |

And to specify base 10?

loga x |
(logarithm to the base a of x) |

And here is where OneNote is right, and most other math apps get it wrong. To get a base 10 log, we expect you to tell us the base 'a' by typing log10(1000) to compute "3". Instead of assuming you mean "10" if you do not specify a base, we use "e" - the gels with behavior seen in the real world. Now that I understand it's going to use "e" as the base, I'm happy with the behavior.

By the NIST guidelines, an equation like log(8) has no meaning since the base is not specified. The behavior we show, which returns a natural log in this case, sort of makes sense now. Since we do not know the base, we default to using natural logs. This is the same behavior as MATLAB, by the way.

Since OneNote obeys the NIST standards, my bug report came back as "Won't Fix," and Dan Escapa suggested I blog about why. This is why.

Questions, comments, concerns and criticisms always welcome,

John

PingBack from http://www.artofbam.com/wordpress/?p=7414

I would make the use of Log and Ln consistent with Excel.

Seems inconsistent that OneNote outputs:

-1^2 = 1

but

0-1^2 = -1

I would think that -1^2 = -1 and (-1)^2 = 1.

Excel does the same thing, though.

Yep, that order of precedence bug you mention is logged already. As part of our automation push this week, I added a new formula to test for exactly that. Try this:

1/2*2=0.25 but that is wrong by the order of precedence of arithmetic. ON should evaluate the operations from left to right, since divide and multiply are at the same level.

It should have been parsed as

(1/2)*2=1

As far ON doing what Excel does… I’m not 100% sold. The specification is vague as to what the expected result is – literally, it gives no guidance whatsoever. Excel defaults to doing what the US default is, and ON defaults to what Europeans and Russia textbooks use. Different behavior for different markets, I suppose. And FWIW, the spec should really define what to do for undefined cases (such as always return an error or the like).

John

Napkin Math is nifty, but what about more?

I haven’t looked into the OneNote XML and object model interfaces, yet. Do you think it might be possible to write a backend for a remote server program, like Maple? That would be *killer* for me, to be able to run maple commands right in OneNote and have the results there in my notes, instead of in Maple’s crappy, fragmentary notebook files.

I assume what this would entail would be the ability to receive change notifications for newly entered lines of text (or, *gag*, perhaps polling, if the text processing could be done fast enough — or *barf* keyboard hooking plus querying the insertion caret position), parse out lines and then insert new content immediately after them. Connecting to the backend server itself should be straightforward and independent of OneNote. If this sounds practical, I’ll see about learning the APIs and coding it up.

Other applications could be exciting, too. E.g. command prompt or SSH sessions logged inside OneNote, or even a "OneNote command line" — enter textual commands into direcly OneNote to perform scripted manipulations on the notebook.

–Micah

I looked at Maple just a little bit. I know they have a way of hooking into Excel, but Excel has a much richer OM than OneNote. Mycopy of Maple is old enough, though, that they may have changed enough to get something reasonable working.

There are no polling events in the OneNote API. The only event is a navigation event. On the other hand, I was thinking about polling a page for text in Maple’s format (maybe ask the user to tag it with a "Maple" tag) and send that to Maple. Take the Maple output (hoping it is in HTML form) and add it back to the page. I have NO idea if the Maple API supports that.

There is a PowerShell powertoy available at http://www.bdewey.com/?p=182 if you really want to have a command line interface to OneNote.

And check out http://www.codeplex.com/onom and see if our open source Object Model would be a help. Feel free to add to it ðŸ™‚ !

John

Oh, and check out this addin Stephen Lawrence created for Matlab to OneNote (it’s only a few lines, if I remember correctly): http://www.onenotepowertoys.com/2007/06/21/matlab-to-onenote/

I just ran across this blog after debugging an Excel spreadsheet. Although Excel’s log function wants to take two arguments, if you only give it one it happily defaults to base 10. This threw me for a bit since I didn’t check one particular calculation for a while. Many other programming languages like C, Perl, Python, and so on use log to mean natural log. So I think OneNote’s interpretation is most in sync with common usage. The other option (perhaps less dangerous?) is to make it undefined or complain if only one argument is given. IMO, Excel is a poor model to go by.

thanks i dont get why it puts an E in the answer