MathML Blogs: Mathematics
Showing posts with label Mathematics. Show all posts
Showing posts with label Mathematics. Show all posts

Saturday, November 15, 2008

No conversion for Internet Explorer

I modified the convert routine to keep the MathML code as it is if the browser does not support certain XML document object interface call. Internet Explorer is known not to support that call. So, the convert routine will not do anything if the browser is Internet Explorer.

This is because IE can already render MathML with the aid of Mathplayer. We only need to convert (actually recreate) MathML code for Firefox. This has a certain amount of performance issue. So, why penalize IE users when it can be avoided.

Friday, November 14, 2008

Observation in torture test

There is a slight delay as the convert function works on dozens of "math" tags. While it is not finished, the default and incorrect rendering is shown. After the conversion, the correct rendering is shown.

Currently, conversion is made for both IE and Firefox. The conversion function can be slightly modified to prevent conversion for IE as it already can render MathML with the help of Mathplayer.

Torture test for convert function

D(p) = 7400 2p+3 =7400 (2p+3 ) 1

dD dp =7400 (2p+3 ) 2 (2) (Chain Rule)

=14800 (2p+ 3) 2

p(t) =5 t 1 2 +7

dp dt = 5 2 t 1 2

dD dt = dD dp dp dt (Chain Rule)

We want to find the rate of change of demand with respect to time when time t=4 .

When t=4  , p(4) =5 (4) 1 2 +7=5( 2)+7= 17  , and D(17)= 7400 2(17)+3 = 7400 37 =200

Also, dp dt | t=4 = 5 2 (4) 1 2 =1.25  and dD dp | t=4 = dD dp | p=17 =14800 (37) 2 =10.81

So, the rate of change of demand with respect to time at time t=4  is given by

dD dt | t=4 = dD dp | t=4 dp dt | t=4

=(10.81 )(1.25 )=13.51

Now, the % rate of change of demand when time t=4   will be given by

(100)( dD dt | t=4 ) D(p) | t=4 = 100(13.51 ) 200 =6.76

MathML works in blogger blog finally for both IE and Firefox

I took a good look at the source code of David Carlisle's blogger blog again. It contained a pair of functions that would convert the MathML code and just fix it up a bit like adding namespace to make it work with Firefox or to add the 'm' prefix to the mathml tags to make it work with Internet Explorer+Mathplayer.

As explained in previous posts, with the right code in the header and the valid mathml code with 'm' prefix, it works just fine without the use of any scripting functions. But, even with the correct the right code, it won't work with Firefox. So the key is to generate the new MathML code specifically for Firefox using the XML document object interface functions calls. For some reason, Firefox sees the newly generated MathML code as XML code and starts rendering it as it should natively.

I have modified one of the helper function to remove the included stylesheet. For some reason it was causing an error in saving the template. Probably some syntax error somewhere.

Should work in both IE and FF

f(x)=a x 2 +bx+c

Check out what it says at the footer of the post

It says posted by D 3 P    . That is D raised to the power 3 followed by P or D cubed P which happens to be the initial of my full name Dr. Dayal D. Purohit with the added title of doctor. Yup, I received my Ph.D. in mathematics in 1983 from State University of New York at Stony Brook, Long Island, New York. My thesis advisor was Dr. Ronald G. Douglas. Initially, I was working on Toeplitz Operators. My professor Dr. Swadheen Pattanaik received his Ph.D. under Dr. Douglas and his research work was around Toeplitz Operators. As a matter of fact, Dr. Pattanaik did the writting of much of the chapter on Toeplitz Operators in Dr. Douglas' book "Banach Algebra Techniques in Operator Theory" published by Academic Press. Dr. Pattanaik recomended me that I come to SUNY at Stony Brook and do my Ph.D. under Dr. Douglas.

How to render MathML in blogs hosted by Blogger

Many years ago when I came to know about blogs hosted by Blogger, I took great interests to find out if it was possible to post MathML in blog posts. And I tried. But I did not succeed. Not because it was not possible, but because I did not try enough.

I am very convinced now that it would have been possible if I had tried harder. I think I was discouraged after reading many articles and blog posts that it was not possible. I believe that it was probably because most were trying it with the newer templates as opposed to the classic templates. In the newer templates, even though the blog pages are served as HTML, the templates are scanned as strict XML pages and a lot of errors are thrown for use of certain characters or for not closing certain tags.

Also for some reason in the newer templates, some of what one wants to include in the header section are automaticaly scraped and not saved in the templates. I found this out after experimenting with the old classic templates and became successful in displaying MathML. Its so much easier to implement MathML in classics templates. All one has to do include the following in the header section of the template.

<OBJECT ID="MathPlayer" CLASSID="clsid:32F66A20-7614-11D4-BD11-00104BD3F987"> </OBJECT>

<?IMPORT NAMESPACE="m" IMPLEMENTATION="#MathPlayer" ?>

The above code allows Mathplayer to kick in when the blog pages are viewed.

This works great in Internet Explorer with Mathplayer installed.

However, this does not work in Firefox. I have noticed that Firefox is very strict in adhering to rules and standards. But thats too bad. Because a vast majority of web sites fail to meet any html or XML standards.

In order for Firefox to display MathML, the pages must be delivered as XML/XHTML pages and must have specified XSL stylesheets to display any XML content. MathML is an XML application and it must come with XSL stylesheets to display it in some browsers including Firefox.

And unfortunately, the blogs hosted at Blogger are served as HTML pages only and that can not be changed even when the content type in the header is changed to XML. Aparently, the page has already been preprocessed as HTML. I suppose some web servers do not care about the content type mentioned in the headers. They probably associate the content type with file name extension.

But, hey, atleast we can have Internet Explorer display MathML with the help of Mathplayer.

Now, coming to the newer blogger templates where it is so much easy to design the layout, it becomes frustrating to see that the template is not saved with the 'import' directive for the Mathplayer. So, what do you do???

Well I found a little trick by coming across a blog by David Carlisle. He was using a different technique to publish math content in his blogger blog. The technique involves translating plain simple ASCII to MathML by creating the XML doc (math node) the most painful way creating each node, adding each attribute and style and appending to parent node and all that by making calls like createelement, setattributes and all that.

What piqued my interest in David's blog was whether it was using the classical blogger template or the newer 'beta' blogger template. They both look the same till you look at the source code of the page. When I did look at the source code of the page, I found out that it was using the newer beta blogger template and there was no sign of the above mathplayer needed code in the header in a discernable way. So I digged further into the source code and found that the javascript employed by David Carlisle was putting that mathplayer needed code in a 'document.write' statement.

So I tried the document.write technique to insert the 'import' directive which was not getting saved in the new beta blogger template. And, lo and behold, the new beta blogger template comes live with MathML with the aid of Mathplayer.

The javascript that David Carlisle had used is authored by Peter Jipsen. This ASCII to MathML script comes with its own stylesheet to render the MathML. So, it is no surprise that it works with Firefox and probably other browsers too.

It is a nice achievement for Peter Jipsen. However, I find some drawbacks. First of all, the stylesheet is limited compared to David Carlisle's XSL stylesheets. The stylesheet is used by any browser where Mathplayer support is not there like in Firefox. No wonder, it works with Firefox. Secondly and perhaps more importantly, the ASCII to MathML must translate and convert each ASCII mathcode and then it must recreate the XML mathnode for each such instances. For a page with tons of mathcodes, it can significantly slowdown the rendering.

Thus we have two solutions to render MathML in blogs hosted by Blogger.

One is using Peter Jipsen's ASCII to MathML script and posting ascii math code. And, this method works for Internet Explorer and Firefox and probably other browsers too.

And the other is simply posting MathML directly and let Mathplayer take care of the rendering. And Mathplayer does a super job of that. Unfortunately, it works only Internet Explorer only and not with Firefox or Gecko based browsers.

I had been running a BBS (Bulletin Board System) since 1985 and it was called "Mathematics Online" using PCBoard running on original IBM PC with a 4.77MHz Intel 8086 processor with a giant 10MB hard drive. I believe it was in the early 1990's when I switched over to a Windows based BBS software called Excalibur BBS software that had graphical windows interface. The makers of the software never upgraded their Windows 3.1 based software to the 32 bit Windows 95 system and it basically died after folks stopped using BBSes in favor of Internet starting in 1995. There was a nice API for Excalibur BBS software to create addons and I created a ton of it for use in my "Mathematics Online" BBS and also for other BBSes and I made a ton of money selling those addons. Now they are all free to all those who are still using Excalibur BBS software and there are quite a few of them.

I have ported some of my Excalibur math plugins to ActiveX plugins in the past.

A few years ago, I created some server side math plugins to generate MathML documents on the fly. You can check them out at JDS Math Plugins. It works in both Internet Explorer and Firefox. If using Internet Explorer, you must have installed Mathplayer.

Wednesday, November 12, 2008

Quadratic Formula

If a x 2 +bx+c= 0,a 0  , then x= b± b 2 4ac 2a