The Spectre of Math

February 3, 2014

New computer, still with MATE …

Filed under: LaTeX,Technology — jlebl @ 7:53 pm

I just got a new work laptop, the Dell XPS 13 developer edition.  Even for a day installed GNOME 3 on it.  Then I realized that I can’t work with two different desktops at the same time, so I went back to MATE.  I can’t change my work computer to GNOME because the dual-monitor support is terrible in GNOME shell.  Oddly it seems that dual monitor is a corner case for GNOME devs now.  Strange as Linux is more used in the “workstation” market than “home desktop” market, and if I look around the offices here, whoever can (has funding) does have a dual monitor setup on their workstation.  GNOME sucks as a workstation.  It might be fine as a place to launch a web browser, email, chat, whatever it is that kids do nowdays.

The other thing is that this has a pretty high DPI, and EVERY desktop kind of sucks at this.  I don’t think that mid 30’s is too old to use computers, but there are things which are definitely harder on this thing and require squinting.  My eyesight is not what it used to be, but it’s not that bad.  I can get most (but not all) fonts to be bigger.  But for example chrome I can’t get to be bigger everywhere, that is, yes on the webpages, but no on the tab headers.  Also UI elements in other things are tiny, like scrollbars are suddenly hard to hit because they are tiny.  Why don’t these things also scale?  That’s annoying.  Smaller resolution is OK, but blurry and sucky.

Another annoying thing is this really godawful thing called a click-pad.  It makes the assumption that just because you can do something, you should.  So the top of the “buttons” are now also place where the “mouse” moves.  So by pressing the button I am also moving the mouse, often clicking somewhere else.  So now if I want to click on something two things happen: 1) the mouse jumps somewhere completely different 2) or I can’t hit it.  Put that together with the small controls and you have a recipe for disaster.  I continually click on things I don’t want to.

Ahh well … There are nice things about the laptop too, like the size, and the case.  Though it doesn’t have a lock hole, which is really anoying … in a coffee shop, am I supposed to take the laptop to the bathroom with me?  I know it’s small, but taking your laptop with you to pee is kind of weird.  Oh yeah … ended on another complaint …

July 12, 2013

MAA reviews, HTML versions, new sections in RA book …

Filed under: LaTeX,Mathematics,Teaching — jlebl @ 7:54 pm

Reviews

MAA has done reviews of both of my books: see here and here.  By the way, now they have been downloaded (at least the PDF) each from over 40k distinct addresses (approximately 83k together now).  Since it seems the web version of the diffyqs book is probably more popular than the PDF, there is probably another as many people who’ve used that.

HTML version of the DiffyQs book

Speaking of the HTML version.  After last release of the diffyqs book, I’ve worked a bit on the HTML conversion.  The result is using tex4ht for conversion and then a Perl script to clean up the HTML.  This is very very hacky, but of course the main point is to make it work rather than do it cleanly.  One of the things I’ve done was to render all math at double the resolution and let the browser scale it down.  Then to make things go a bit faster I’ve made the code detect duplicate images of which there are quite a few.  I’ve also been testing with data URIs for very small images, but they don’t quite work right everywhere yet.  They would cut down on the number of requests needed per page and surely eventually I’ll do that.

The supersampling has both positive and negative effects.  Printed version of the HTML now looks a lot better.  Not totally great since I currently have things render at around 200dpi rather than perhaps 300dpi, but it’s a reasonable compromise.  Also high resolution displays give nicer rendering.  The downside is that on a regular display the equations are fuzzier due to lack of hinting.

Of course MathJax would be the ultimate answer to the math display and that’s the ultimate goal, but I can’t make it work with tex4ht reasonably nice.  I am very picky about the display being 100% correct even if uglier, over being 90% correct and pretty.  Every suggestion I’ve tried so far was very subpar on output.  I can’t make tex4ht not touch all math.  Even then MathJax does choke on a few expressions I have in the file so things would require more tweaking to make it all work.

The requirements for math display I have is 1) I want to make sure that the same font is used on all math (that’s why I render all math as images).  2) I want the output to be correct and readable (which totally disqualifies MathML since even newest versions of all browsers do terrible jobs on all but the simplest equations, and even there).  3) I want the thing to be usable on as many browsers as possible.

I think eventually the solution would be to write my own tex parser that can read the subset of latex I use for the book and output HTML pages using MathJax.  This sounds simpler than it is.  That is, getting this to work on 90% of the input is easy, then things like figures, and certain math constructions get in the way.

Another possibility is to output svg instead of png for math using dvisvgm.  This keeps the problem of fuzziness on standard displays, but is really pretty when printed or on high resolution displays .  The downside is bad support (only very new chrome and firefox support this somewhat and even they have issues, and it crashes my android phone).  I think MathJax is a better long term solution, but it will take some work and probably a move away from tex4ht.

New sections in the analysis book

Something I have not mentioned here when it happened is that the analysis book got a bunch of new sections recently (the May 29th version).  These are all extra optional sections to fill up a longer version of the course (dependencies if any are marked in the notes at the beginning of each section).  There is a section on

  • Diagonalization argument and decimal representation of real numbers (1.5)
  • More topics on series (2.5)
  • Limits at infinity and infinite limits (3.5)
  • Monotone functions and continuity (3.6)
  • Inverse function theorem in one variable (4.4)
  • The log and exp functions (5.4)
  • Improper integrals (5.5)

I am currently working on multivariable chapter(s) that would come after chapter 7.  This will take some time still, I have about half of the material in a very rough draft, having massaged bits of my Math 522 notes into something that more fits this book.  My plan is for the book to be usable for a standard one year course on real analysis.

November 27, 2012

Frobenius method and Bessel functions

Filed under: Hacking,LaTeX,Mathematics,Teaching — jlebl @ 6:57 pm

I had occasion to talk about Bessel functions and mention the Frobenius method in my PDE class and I realized that I do not have any mention of this in the book. This was the section I did not quite get to when teaching at UCSD, so it never got written. Well, worry no more. I’ve written up a draft version of the section. This will appear in the next version of the book whenever I make it, though if you do have comments, do let me know. It’s good to catch typos or make changes now.

This brings the number of pages to 307 together with new delta function section and the number of exercises to 521. Yay!

This also made me realize that Genius did not have Bessel functions implemented. They were actually easy to implement as MPFR has them done. At least for integer orders and real values anyway. Then as my current working directory of genius was such a mess with trying to include LAPACK, I decided to remove LAPACK for now from the genius git. I think what I will do is link to the fortran version at some later point. It seems like the fortran LAPACK is available almost everywhere, so it should not be a bad new dependency. Much easier than trying to make the beast compile cleanly inside genius. Anyway, so Bessel functions will be in Genius, which I think I ought to make a release of soon as there are a bunch of other small changes to set upon the world.

November 15, 2012

New section in differential equations book

Filed under: LaTeX,Mathematics,Teaching — jlebl @ 7:44 pm

I have recently finally finished a new section on the Dirac delta function for the differential equations textbook. Take a look at the draft version. Note that this is a draft, so it could have typos and could still change. If you have any comments, let me know. Especially if you want to teach with it and would like to mention some detail I don’t mention right now. I will make a new version of the book including this section sometime in December, after semester ends.

In other news, the differential equations textbook is now apparently the standard book for Math 3D at University of California at Irvine. It’s nice if people pick the book to teach out of for their class, but it’s even nicer if a department decides to standardize on the book. The real analysis book is for example the standard book at University of Pittsburgh, and they even made their own changes (adding some extra material), which is a really nice example of what can be done with free textbooks.

I also added Google Analytics to the pages so I can see where the traffic is coming from. If someone uses the books by printing out a copy for students or putting a PDF on their site, I can’t quite see it, but if they simply link to my site it’s fun to watch the traffic. As the differential equations book has an HTML version, a lot of students seem to use that rather than the PDF. I assume the PDF is just downloaded and I don’t see traffic afterwards, but when they are using the HTML version, then of course they keep hitting my site. So currently there are several classes at Irvine and two classes at University of British Columbia that simply link to my site and I get lots of traffic on the HTML version of the book. These students using the HTML version takes up a large proportion of hits to my site. If you look on the map of which cities hits are coming from, there are two big circles, one over Irvine and one over Vancouver, and then lots of other smaller circles mostly distributed all over, mostly over english speaking coutries.

I am thinking I should make an HTML version of the real analysis textbook, but it’s quite a bit of work to set things up for tex4ht, and always quite a bit of work when making a new version so I have not yet gotten around to do it. Also I am more worried about formulas coming out correctly. It would be nice to get something like mathjax working with tex4ht. Or some other solution, but I don’t want to maintain two versions so it would have to take the LaTeX source and produce the HTML perhaps with a different style file. Anyway, for now it is images for equations, which do look bad when printed, but look OK on screen.

January 13, 2011

Vim, Evince and forward and backward LaTeX synctex search

Filed under: Hacking,LaTeX — jlebl @ 11:35 pm

I was finally fed up with not having forward and backward search in vim so I hacked up the python script that was in the gedit synctex package to do what I needed. The result is evince_vim_dbus.py (GNOME 2.32 version) or evince_vim_dbus.py (GNOME 3 version old LaTeX) or evince_vim_dbus.py (GNOME 3 version that works with TexLive 2011). Copy it somewhere into your PATH (say ~/bin or /usr/local/bin). The first argument is EVINCE or GVIM. If it is EVINCE then it works just like the evince_dbus.py from the gedit synctex package. So to do forward search you add something like the following to your .vimrc file. This uses the LatexBox set of vim macros, which is pretty unobtrusive and kind of useful

function! LatexEvinceSearch()
execute "!cd " . LatexBox_GetTexRoot() . '; evince_vim_dbus.py EVINCE "`basename ' . LatexBox_GetOutputFile(). '`" ' . line('.') . ' "%:p"'
endfun
command! LatexEvinceSearch call LatexEvinceSearch()
au FileType tex map ls :silent LatexEvinceSearch

Make sure to compile your latex file with pdflatex –synctex=1 thefile. Now to jump to the right place in evince just type \ls in vim at the right spot. For vim-latex I assume something like the following would work though I have not tried so this may not actually work:

let g:Tex_ViewRule_pdf = 'evince_vim_dbus.py EVINCE'
let g:Tex_DefaultTargetFormat = 'pdf'
let g:Tex_CompileRule_pdf = 'pdflatex --synctex=1 -interaction=nonstopmode $*'

Now to do inverse search, what you want to do is open up evince with the .pdf file, open gvim with the file with something like: gvim –servername foo thefile.tex. The –servername argument will let us communicate with that instance of gvim. Now run

evince_vim_dbus.py GVIM foo thefile.pdf thefile.tex

This will keep running and will talk to evince and when you control-click somewhere the script will call the “foo” instance of gvim and tell it to go to the right line. You have to kill this script once you are done. Yeah I know this is kind of ugly, but the way synctex is done in evince is kind of moronic. The idea is I think to make the thing as complicated as possible to satisfy someone’s CS design fetish rather than to make the thing simple and easily usable (such as doing it by calling evince with the right arguments and giving evince a command to execute) … but then no script like this would be needed.

I also have a modified whaw: whaw-jiri-0.1.2.tar.gz. When you run whaw –htile you will get a different cursor, you can left click bunch of windows and then right click and whaw will put the windows side by side. The standard whaw works as well, but the –htile is usable from scripts.

Finally to put it all together I have a script that runs everything for me called buildpdftexwatch (slightly modified version of the script from my homepage) which works as follows (by the way you need zsh installed for the script). You run buildpdftexwatch thefile where thefile doesn’t have any extension. The script will open thefile.tex in gvim and thefile.pdf in evince. If you have the modified whaw it will run it with –htile (otherwise it won’t run whaw). The script watches the .tex file and whenever you save in vim it will rerun pdflatex. (it also runs pdflatex in interactive mode when first invoked before it runs evince actually). It runs pdflatex in noninteractive mode afterwards so that it doesn’t hang. It will notify you of errors by barking (that is if you have ogg123 and the default gnome sound /usr/share/sounds/gnome/default/alerts/bark.ogg installed.

This setup is not perfect. Yeah I know I should probably rewrite the shell script to work in python so that the dbus thing can be done from the script itself. However, evince also sucks so I’d rather just use xpdf, but that does not yet have synctex support. At some point I may be enough annoyed with evince that I will hack xpdf to do synctex (and do it in the simple nondbusy way that will make it easy to work with all kinds of editors). For now … this works good enough.

Update: Make sure to use the latest evince (at least 2.32.0) as older versions do not have synctex support.

Update: GNOME 3 evince breaks the dbus interface and the above python code. (So what’s the advantage of using dbus here? It is total overkill, isn’t documented well (as far as I can find), and breaks from release to release anyway). The least that evince could do is to have command line options so that one does not need to do dbus black magic to make it work. Anyway I had to fix it up and now there are two versions, one for GNOME 3 and one for GNOME 2.32. I also integrated the below comment from Simon.

Update: New braindamage coming (this time) from TexLive 2011 synctex. Apparently we must now insert /./ into the path or synctex will refuse to work. This is wrong on so many levels it is not even funny. That means there are 3 distinct versions of this code with just slightly different semantics. Somebody somewhere should get a smack over the head when a new feature that most people likely won’t ever use will break all existing usage. Certain people should not be allowed to design public facing APIs. Also there might be some change in the way vim does the current filename thing because the script was now getting full path name for the input file, so I had to fix that too. I am not quite sure what happened there though so I am not ready to blame vim. I can’t understand however how else could have the old version have worked before.

Update: New changes in GNOME.  So apparently the API changed again.  Where we got a filename before apparently we now get a uri (which I suppose is more consistent but a break in the API again).  So I updated the code to strip “file://” if it finds it.  Should still work with older evinces, and with new.  I have now tested it with evince 3.8 and TexLive 2012.

October 4, 2010

Damn Murphy!

Filed under: LaTeX,Mathematics,Teaching,Technology — jlebl @ 7:45 pm

Murphy’s law strikes again. The moment you publish something (be it a textbook or a software), you find a bug. Yesterday I put on the web new versions of both my diffyqs notes and my real analysis notes. Already yesterday I found that when I posted the real anal notes on lulu, I forgot to update the book cover to state that I’m now at UCSD. OK, that’s a minor thing, who cares.

Today I was preparing for my diffy qs class and found an error in the notes. Actually I think I spotted this error in the spring when I taught at UIUC, but somehow forgot to fix it. So I find the first significant typo in the notes the day after posting new versions of the notes. And putting up new versions of the diffy qs notes is not as trivial as it may seem. It takes about 2 hours just to build the HTML version. This is because I have tex4ht do all math as images. Doing some of the math using CSS is faster, but then you get different font for some equations (as some are done using images and some using CSS).

If jsmath actually worked right, I would use that. But since I generally have a hard time making jsmath display things correctly on my own system, I assume that it doesn’t work right for a lot of people. Also jsmath seems to break for me for the pages as large as the notes. Mathml would be the perfect solution if it would work properly and consistently on all browsers. Right now for mathml and tex4ht you have to first decide on a browser to support, which beats the whole idea.

Browser developers are generally interested in floating 3d fish rather than actually useful stuff like supporting mathml properly. One of the reasons I am sticking to firefox is because the fact that they do support mathml reasonably, and have for a while, is an indication of sanity on the part of the developers.

July 14, 2010

Microtypography

Filed under: LaTeX,Mathematics,Teaching,Technology — jlebl @ 5:38 pm

I have been playing around with the microtype package for PdfLaTeX. The results are really nice. Using the font expansion does increase the size of pdf a tiny bit, but not much. It is definitely worth it I think. Overall using the microtype package, I seem to be getting better line breaks, especially in tight places where there are floating figures (where text flows around them). To use simply add
\usepackage{microtype}
to your file, and make sure to use pdflatex rather than latex and dvipdf.

What it does is two things. Firstly it will add protruding punctuation (say periods actually hanging off sides of your paragraphs) to make a more straight looking justification. Furthermore, it may “stretch” the font by a tiny bit on certain lines to get a more even “greyness” of the text (for example, getting more uniform inter-word spacing). It also gives the justification algorithm more freedom in finding better line-breaking points, so you generally get better line-breaking (less hyphenation, etc…). It is the font stretching that adds a bit to your files since you need more copies of the font in the file, but the size increase is not terribly big on large files in relative terms. Still with microtype and PDF1.5, the 2MB differential equations pdf goes down by about 200k compared to no microtype and PDF1.4.

I want to do a bit more cleaning up and perhaps some more fixes before I post updates to the Notes on Diffy Qs, Basic Analysis, and the SCV minicourse. Probably within a few days.

Speaking of the notes, it is interesting that the real analysis notes are now downloaded more frequently by new unique IPs than the differential equations. On average about 30%-40% more. That is surprising, I would have thought that real analysis (taken almost exclusively by math majors) would be less interesting to “the masses,” rather than differential equations on the level of calculus (taken by almost any technical major).

October 27, 2009

Notes, tex4ht, adsense, literate programming

Filed under: LaTeX,Linux,Mathematics,Technology — jlebl @ 3:50 pm

I’ve spent all yesterday playing around with tex4ht. I wanted to find out how hard it is to produce PDF and web documents from one LaTeX source without sacrificing quality of the PDF. So I worked on converting the diffy qs notes into HTML. The result is
here. I don’t agree with several default decisions that tex4ht makes so it took a while to get it right. For example, tex4ht does some equations (mostly inline ones) as regular html and some as pictures. The problem is complete lack of consistency. For example the Laplace transform symbol {\mathcal L} looked different, so the student would have to figure it out. Plus the html equations are hard to read sometimes if they are complicated.

Unfortunately tex4ht is another example of literate programming effort, which is a wonderful idea which in my opinion does not work. All the literate programming projects I have seen have terrible documentation. The problem is nonlinearity of the documentation and many times circular logic. Terms are not defined before they are used, plus there is no obvious starting place. The right information is hard to find. This is a problem with all things LaTeX related. Getting started is very hard because you have no clue where to find the right info. All documents seem to assume you know everything in all the other documents and you know where to find all those other documents.

That is not to say that traditionally documented things are better. That is mostly because traditionally documented things are undocumented. And many times traditional documentation suffers from the same nonlinearity and circularity. For example, trying to implement adsense was also a pain for lack of good documentation. The documentation is a series of FAQs essentially. Each answer is vague and refers to language defined somewhere else which is not linked. And even if linked, the structure is hardly linear. There is no one place to start which defines all concepts and then goes into detail in a tree like manner. Instead the overall document is missing, and you have a spaghetti of a not simply connected graph.

On the plus side I have made $1.59 on adsense since saturday. While that may not seem like much (it is not) it is the first kind of monetary support for the notes. Actually over $1 was from the genius page which is not related to the notes and is far less visited. But apparently it has more relevant ads, or the visitors are less stingy with clicking ads. There’s about 500-1000 hits a day on the diffy qs notes webpage, though on average only 20-25 new people per day download the PDF. Still it says something about how the server is nonbusy that my notes account for about 30% of the traffic.

There have been over 3000 unique IP addresses that downloaded the notes so far. 3000 copies for a math textbook is not bad I guess. Obviously, it cannot compete with porn in the number of hits. But it seems that I am only getting cheap-o visitors. Not a single person bought the paperback even though it’s very reasonably priced. I get $2.50 from that. So thus far, adsense is getting me the equivalent of a little bit over half a copy sold. Outside of time, I have spent about $20 putting the notes together. So I guess I am still way underwater.

So … BUY THE BOOK!

September 10, 2009

More sketch fun and more textbook fun

Filed under: Hacking,LaTeX,Mathematics,Teaching,Technology — jlebl @ 10:33 pm

I have to brag. Here are some more fun sketch pics. These are probably very close to what we’ll actually put into the paper. Marketa said that the second one looks like bublanina.

more sample sketch pics

On not really related note the rate of downloads for my diffyqs notes is rising in the last week. I think I’m detecting the start of semester for many US colleges. I bet it will increase even more once the fall semester/quarter starts everywhere.

Now on related note, I’m typing up my notes for math 444 here, which is basic real analysis. So I’m writing another textbook: really baby analysis. Take baby Rudin and make it a lot less ambitious. If I were really crazy I could also take my sort of typed notes from last semester’s basic linear algebra and make those into a textbook … some other time I think, I didn’t really like the syllabus for that course, so if I were to make a textbook there it would differ more from the course here at UIUC.

September 9, 2009

Playing around with sketch 3D

Filed under: Hacking,LaTeX,Technology — jlebl @ 10:36 pm

We need figures for our latest paper. And the figures have to be of 3D things. So I’ve been playing around with sketch 3D, and so far it is working pretty well. It’s a 3D modeling language that compiles into latex.

sample figure

Cool huh?

The Rubric Theme. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.