<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title></title>
	<atom:link href="http://ardoris.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://ardoris.wordpress.com</link>
	<description></description>
	<lastBuildDate>Sun, 06 Nov 2011 14:57:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='ardoris.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title></title>
		<link>http://ardoris.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://ardoris.wordpress.com/osd.xml" title="" />
	<atom:link rel='hub' href='http://ardoris.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Linux Keylogger Proof of Concept</title>
		<link>http://ardoris.wordpress.com/2011/04/24/linux-keylogger-proof-of-concept/</link>
		<comments>http://ardoris.wordpress.com/2011/04/24/linux-keylogger-proof-of-concept/#comments</comments>
		<pubDate>Sun, 24 Apr 2011 00:29:19 +0000</pubDate>
		<dc:creator>jebavarde</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[keylogger]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[proof of concept]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[xlib]]></category>

		<guid isPermaLink="false">http://ardoris.wordpress.com/?p=470</guid>
		<description><![CDATA[I&#8217;ve just read &#8216;The Linux Security Circus: On GUI isolation&#8217; It struck me that a linux keylogger is perfectly easy to write &#8211; I had previously (naïvely) thought such a program would only work given root permissions. Alas! It&#8217;s stupidly &#8230; <a href="http://ardoris.wordpress.com/2011/04/24/linux-keylogger-proof-of-concept/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ardoris.wordpress.com&amp;blog=4109393&amp;post=470&amp;subd=ardoris&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just read <a href="http://theinvisiblethings.blogspot.com/2011/04/linux-security-circus-on-gui-isolation.html">&#8216;The Linux Security Circus: On GUI isolation&#8217;</a></p>
<p>It struck me that a linux keylogger is perfectly easy to write &#8211; I had previously (naïvely) thought such a program would only work given root permissions.</p>
<p>Alas! It&#8217;s stupidly easy.</p>
<p><a href="https://gist.github.com/939140">see result of 30 minutes of hacking</a></p>
<p>The code simply calls <code>xinput test <i>[id of keyboard device]</i></code> and parses out the keycodes. The id of your keyboard device can be found from the device listing given by <code>xinput list</code>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ardoris.wordpress.com/470/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ardoris.wordpress.com/470/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ardoris.wordpress.com/470/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ardoris.wordpress.com/470/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ardoris.wordpress.com/470/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ardoris.wordpress.com/470/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ardoris.wordpress.com/470/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ardoris.wordpress.com/470/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ardoris.wordpress.com/470/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ardoris.wordpress.com/470/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ardoris.wordpress.com/470/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ardoris.wordpress.com/470/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ardoris.wordpress.com/470/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ardoris.wordpress.com/470/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ardoris.wordpress.com&amp;blog=4109393&amp;post=470&amp;subd=ardoris&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ardoris.wordpress.com/2011/04/24/linux-keylogger-proof-of-concept/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/53b7018a0bf92b1f9cb0b08a8a45e4ff?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bavardage</media:title>
		</media:content>
	</item>
		<item>
		<title>GrouPAY</title>
		<link>http://ardoris.wordpress.com/2011/03/23/groupay/</link>
		<comments>http://ardoris.wordpress.com/2011/03/23/groupay/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 20:23:07 +0000</pubDate>
		<dc:creator>jebavarde</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[groupay]]></category>
		<category><![CDATA[intern]]></category>
		<category><![CDATA[online payment]]></category>
		<category><![CDATA[start-up]]></category>

		<guid isPermaLink="false">http://ardoris.wordpress.com/?p=466</guid>
		<description><![CDATA[I&#8217;m currently interning at this new exciting startup in London &#8211; www.groupay.co.uk &#8211; check it out!<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ardoris.wordpress.com&amp;blog=4109393&amp;post=466&amp;subd=ardoris&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently interning at this new exciting startup in London &#8211; <a href="http://www.groupay.co.uk">www.groupay.co.uk</a> &#8211; check it out!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ardoris.wordpress.com/466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ardoris.wordpress.com/466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ardoris.wordpress.com/466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ardoris.wordpress.com/466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ardoris.wordpress.com/466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ardoris.wordpress.com/466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ardoris.wordpress.com/466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ardoris.wordpress.com/466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ardoris.wordpress.com/466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ardoris.wordpress.com/466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ardoris.wordpress.com/466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ardoris.wordpress.com/466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ardoris.wordpress.com/466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ardoris.wordpress.com/466/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ardoris.wordpress.com&amp;blog=4109393&amp;post=466&amp;subd=ardoris&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ardoris.wordpress.com/2011/03/23/groupay/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/53b7018a0bf92b1f9cb0b08a8a45e4ff?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bavardage</media:title>
		</media:content>
	</item>
		<item>
		<title>Haskell, Cellular Automata and Sierpinski Rule 90</title>
		<link>http://ardoris.wordpress.com/2011/01/08/haskell-cellular-automata-and-sierpinski-rule-90/</link>
		<comments>http://ardoris.wordpress.com/2011/01/08/haskell-cellular-automata-and-sierpinski-rule-90/#comments</comments>
		<pubDate>Sat, 08 Jan 2011 22:23:05 +0000</pubDate>
		<dc:creator>jebavarde</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[automata]]></category>
		<category><![CDATA[cellular]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[sierpinski]]></category>

		<guid isPermaLink="false">http://ardoris.wordpress.com/?p=460</guid>
		<description><![CDATA[I&#8217;ve just finished writing an article for The Invariant Magazine (the annual Oxford Maths Society magazine which tends to actually get published once a decade) about cellular automata. Whilst writing, I became a bit distracted, and decided to write some &#8230; <a href="http://ardoris.wordpress.com/2011/01/08/haskell-cellular-automata-and-sierpinski-rule-90/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ardoris.wordpress.com&amp;blog=4109393&amp;post=460&amp;subd=ardoris&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just finished writing an article for The Invariant Magazine (the annual Oxford Maths Society magazine which tends to actually get published once a decade) about cellular automata.</p>
<p>Whilst writing, I became a bit distracted, and decided to write some haskell to print 1D automata. After replacing most variables with single letters, and manually inlining some things, behold:<br />
<code><br />
import Data.Bits<br />
ns xs = zip3 (drop (l-1) xs') xs (tail xs') where xs' = cycle xs; l = length xs<br />
s ru xs = map (\(l,c,r) -&gt; if (2^(l*4 + c*2 + r) .&amp;. ru) == 0 then 0 else 1) $ ns xs<br />
ss = map (\c -&gt; if c == 0 then ' ' else '#')<br />
printAutomata :: Int -&gt; Int -&gt; [Int] -&gt; IO () --one type sig needed<br />
printAutomata n r xs = mapM_ putStrLn $ map ss $ take n $ iterate (s r) xs<br />
</code></p>
<p>Then in GHCI, let&#8217;s try to simulate <a href="http://en.wikipedia.org/wiki/Rule_90">Rule 90</a> starting with a single cell of state 1.</p>
<pre>
Prelude&gt; :l ca.hs
[1 of 1] Compiling Main             ( ca.hs, interpreted )
Ok, modules loaded: Main.
*Main&gt; printAutomata 20 90 $ (replicate 20 0) ++ [1] ++ (replicate 20 0)
                    #
                   # #
                  #   #
                 # # # #
                #       #
               # #     # #
              #   #   #   #
             # # # # # # # #
            #               #
           # #             # #
          #   #           #   #
         # # # #         # # # #
        #       #       #       #
       # #     # #     # #     # #
      #   #   #   #   #   #   #   #
     # # # # # # # # # # # # # # # #
    #                               #
   # #                             # #
  #   #                           #   #
 # # # #                         # # # #
</pre>
<p>Yay Sierpinski!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ardoris.wordpress.com/460/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ardoris.wordpress.com/460/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ardoris.wordpress.com/460/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ardoris.wordpress.com/460/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ardoris.wordpress.com/460/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ardoris.wordpress.com/460/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ardoris.wordpress.com/460/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ardoris.wordpress.com/460/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ardoris.wordpress.com/460/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ardoris.wordpress.com/460/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ardoris.wordpress.com/460/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ardoris.wordpress.com/460/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ardoris.wordpress.com/460/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ardoris.wordpress.com/460/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ardoris.wordpress.com&amp;blog=4109393&amp;post=460&amp;subd=ardoris&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ardoris.wordpress.com/2011/01/08/haskell-cellular-automata-and-sierpinski-rule-90/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/53b7018a0bf92b1f9cb0b08a8a45e4ff?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bavardage</media:title>
		</media:content>
	</item>
		<item>
		<title>Fantastic HTTP Console</title>
		<link>http://ardoris.wordpress.com/2010/12/24/fantastic-http-console/</link>
		<comments>http://ardoris.wordpress.com/2010/12/24/fantastic-http-console/#comments</comments>
		<pubDate>Fri, 24 Dec 2010 22:06:09 +0000</pubDate>
		<dc:creator>jebavarde</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[google app engine]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[htty]]></category>

		<guid isPermaLink="false">http://ardoris.wordpress.com/?p=454</guid>
		<description><![CDATA[I&#8217;ve just started coding something for Google App Engine (which I&#8217;ll publish if it gets anywhere) and after reading First we built an API, then we built a CMS on Hacker News I decided to design the API first. I &#8230; <a href="http://ardoris.wordpress.com/2010/12/24/fantastic-http-console/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ardoris.wordpress.com&amp;blog=4109393&amp;post=454&amp;subd=ardoris&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just started coding something for Google App Engine (which I&#8217;ll publish if it gets anywhere) and after reading <a href="http://www.gethifi.com/blog/first-we-built-an-api-then-we-built-a-cms">First we built an API, then we built a CMS</a> on <a href="http://news.ycombinator.com/">Hacker News</a> I decided to design the API first.</p>
<p>I wanted a way to test and play with this API from the console. A search threw up <a href="https://github.com/htty/htty">HTTY</a>: the HTTP TTY, which is a fantastic HTTP console and makes testing a breeze.</p>
<p>One can <code>cd</code> between urls, build and clear query string with <code>query-set</code> and <code>query-clear</code> and use the HTTP verbs.</p>
<h3>An example session</h3>
<p><code><br />
http://localhost:8080/api&gt; query-set key aglib29rbWFya3NyDgsSCEJvb2ttYXJrGAMM<br />
http://localhost:8080/api?key=aglib29rbWFya3NyDgsSCEJvb2ttYXJrGAMM&gt; get<br />
 200  OK -- 6 headers -- 328-character body<br />
http://localhost:8080/api?key=aglib29rbWFya3NyDgsSCEJvb2ttYXJrGAMM&gt; body<br />
[{"user_tags": ["omg", "lol", "google", "123"], "created": "Fri Dec 24 18:42:42 2010", "_key": "aglib29rbWFya3NyDgsSCEJvb2ttYXJrGAMM", "title": "lol", "access": "public", "link": {"_key": "aglib29rbWFya3NyCgsSBExpbmsYAgw", "url": "http:\/\/www.lol.com\/"}, "user": {"nickname": "test@example.com", "email": "test@example.com"}}]<br />
</code></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ardoris.wordpress.com/454/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ardoris.wordpress.com/454/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ardoris.wordpress.com/454/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ardoris.wordpress.com/454/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ardoris.wordpress.com/454/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ardoris.wordpress.com/454/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ardoris.wordpress.com/454/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ardoris.wordpress.com/454/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ardoris.wordpress.com/454/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ardoris.wordpress.com/454/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ardoris.wordpress.com/454/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ardoris.wordpress.com/454/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ardoris.wordpress.com/454/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ardoris.wordpress.com/454/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ardoris.wordpress.com&amp;blog=4109393&amp;post=454&amp;subd=ardoris&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ardoris.wordpress.com/2010/12/24/fantastic-http-console/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/53b7018a0bf92b1f9cb0b08a8a45e4ff?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bavardage</media:title>
		</media:content>
	</item>
		<item>
		<title>Simple Quine in Python</title>
		<link>http://ardoris.wordpress.com/2010/12/20/simple-quine-in-python/</link>
		<comments>http://ardoris.wordpress.com/2010/12/20/simple-quine-in-python/#comments</comments>
		<pubDate>Mon, 20 Dec 2010 18:47:06 +0000</pubDate>
		<dc:creator>jebavarde</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[quine]]></category>

		<guid isPermaLink="false">http://ardoris.wordpress.com/?p=450</guid>
		<description><![CDATA[I recently saw this blogpost &#8211; http://philipsung.blogspot.com/2010/12/people-who-are-not-in-our-league-v.html &#8211; which gives a quine in ruby with a twist (read the post). It struck me that somehow I&#8217;ve never tried at writing a quine. Turns out a very simple quine (no attempt &#8230; <a href="http://ardoris.wordpress.com/2010/12/20/simple-quine-in-python/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ardoris.wordpress.com&amp;blog=4109393&amp;post=450&amp;subd=ardoris&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I recently saw this blogpost &#8211; http://philipsung.blogspot.com/2010/12/people-who-are-not-in-our-league-v.html &#8211; which gives a quine in ruby with a twist (read the post). It struck me that somehow I&#8217;ve never tried at writing a quine.</p>
<p>Turns out a very simple quine (no attempt be concise) is.. very simple.</p>
<pre class="brush: python;">
import zlib
data = b'x\x9c\xcb\xcc-\xc8/*Q\xa8\xca\xc9L\xe2JI,IT\xb0U\xa86\xa8\xe5*(\xca\xcc+\xd1\x00\x89\xea\xa5\xa4&amp;\xe7\xe7\x16\x14\xa5\x16\x17k\x80\x14h\x82\x05RR5\xd4KK\xd2t-\xd45\xf5\xd2\xf2\x8br\x13K \x92\x9a\x00\x82\x1e\x1b\xc4'
print(zlib.decompress(data).decode('utf-8').format(data))
</pre>
<p>The <code>data</code> section is result of compressing the string:</p>
<pre class="brush: python;">
import zlib
data = {0}
print(zlib.decompress(data).decode('utf-8').format(data))
</pre>
<p>and so we decompress the data and replace <code>{0}</code> with what the data is.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ardoris.wordpress.com/450/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ardoris.wordpress.com/450/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ardoris.wordpress.com/450/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ardoris.wordpress.com/450/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ardoris.wordpress.com/450/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ardoris.wordpress.com/450/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ardoris.wordpress.com/450/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ardoris.wordpress.com/450/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ardoris.wordpress.com/450/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ardoris.wordpress.com/450/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ardoris.wordpress.com/450/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ardoris.wordpress.com/450/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ardoris.wordpress.com/450/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ardoris.wordpress.com/450/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ardoris.wordpress.com&amp;blog=4109393&amp;post=450&amp;subd=ardoris&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ardoris.wordpress.com/2010/12/20/simple-quine-in-python/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/53b7018a0bf92b1f9cb0b08a8a45e4ff?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bavardage</media:title>
		</media:content>
	</item>
		<item>
		<title>Annihilators, Perpendicular Spaces, A Connection</title>
		<link>http://ardoris.wordpress.com/2010/12/15/annihilators-perpendicular-spaces/</link>
		<comments>http://ardoris.wordpress.com/2010/12/15/annihilators-perpendicular-spaces/#comments</comments>
		<pubDate>Wed, 15 Dec 2010 14:24:25 +0000</pubDate>
		<dc:creator>jebavarde</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[annihilators]]></category>
		<category><![CDATA[inner product space]]></category>
		<category><![CDATA[isomorphism]]></category>
		<category><![CDATA[linear algebra]]></category>
		<category><![CDATA[perpendicular]]></category>
		<category><![CDATA[real inner product space]]></category>
		<category><![CDATA[representation theorem]]></category>
		<category><![CDATA[riesz]]></category>
		<category><![CDATA[vector space]]></category>

		<guid isPermaLink="false">http://ardoris.wordpress.com/?p=413</guid>
		<description><![CDATA[Whilst writing out revision notes, something struck me! let be a finite dimensional real inner product space. let be a subspace of V. Definition The annihilator of , denoted where is the dual space of V. Definition The perpendicular space &#8230; <a href="http://ardoris.wordpress.com/2010/12/15/annihilators-perpendicular-spaces/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ardoris.wordpress.com&amp;blog=4109393&amp;post=413&amp;subd=ardoris&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Whilst writing out revision notes, something struck me!</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Chuge+X%5E%7B%5Ccirc%7D+%3D+%5Cvarphi%28X%5E%7B%5Cbot%7D%29+&amp;bg=ffffff&amp;fg=000&amp;s=4' alt='&#92;huge X^{&#92;circ} = &#92;varphi(X^{&#92;bot}) ' title='&#92;huge X^{&#92;circ} = &#92;varphi(X^{&#92;bot}) ' class='latex' /></p>
<p>let <img src='http://s0.wp.com/latex.php?latex=V&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='V' title='V' class='latex' /> be a <strong>finite dimensional</strong> real inner product space.<br />
let <img src='http://s0.wp.com/latex.php?latex=X+%5Cleqslant+V&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='X &#92;leqslant V' title='X &#92;leqslant V' class='latex' /> be a subspace of V.</p>
<h4>Definition</h4>
<p>The <strong>annihilator</strong> of <img src='http://s0.wp.com/latex.php?latex=X&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='X' title='X' class='latex' />, denoted <img src='http://s0.wp.com/latex.php?latex=X%5E%7B%5Ccirc%7D+%3A%3D+%5C%7B+f+%5Cin+V%27+%5Cmid+f%28x%29+%3D+0+%5C%2C+%5Cforall+x+%5Cin+X%5C%7D&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='X^{&#92;circ} := &#92;{ f &#92;in V&#039; &#92;mid f(x) = 0 &#92;, &#92;forall x &#92;in X&#92;}' title='X^{&#92;circ} := &#92;{ f &#92;in V&#039; &#92;mid f(x) = 0 &#92;, &#92;forall x &#92;in X&#92;}' class='latex' /> where <img src='http://s0.wp.com/latex.php?latex=V%27&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='V&#039;' title='V&#039;' class='latex' /> is the dual space of V.</p>
<h4>Definition</h4>
<p>The <strong>perpendicular space</strong> of <img src='http://s0.wp.com/latex.php?latex=X&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='X' title='X' class='latex' />, denoted <img src='http://s0.wp.com/latex.php?latex=X%5E%7B%5Cbot%7D+%3A%3D+%5C%7B+v+%5Cin+V+%5Cmid+%5Clangle+x%2Cv+%5Crangle+%3D+0+%5C%2C+%5Cforall+x+%5Cin+X+%5C%7D&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='X^{&#92;bot} := &#92;{ v &#92;in V &#92;mid &#92;langle x,v &#92;rangle = 0 &#92;, &#92;forall x &#92;in X &#92;}' title='X^{&#92;bot} := &#92;{ v &#92;in V &#92;mid &#92;langle x,v &#92;rangle = 0 &#92;, &#92;forall x &#92;in X &#92;}' class='latex' /></p>
<p>It might already be apparent that there is some connection between these two &#8211; both involve things going to zero, whenever something is done to everything in <img src='http://s0.wp.com/latex.php?latex=X&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='X' title='X' class='latex' />.</p>
<p>To make this more explicit, first we need a theorem.</p>
<h4>Theorem: <strong>(weaker version of) Riesz Representation Theorem</strong></h4>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cvarphi+%5Ccolon+V+%5Crightarrow+V%27+%5Ccolon+w+%5Cmapsto+%28v+%5Cmapsto+%5Clangle+v+%2C+w+%5Crangle%29&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='&#92;varphi &#92;colon V &#92;rightarrow V&#039; &#92;colon w &#92;mapsto (v &#92;mapsto &#92;langle v , w &#92;rangle)' title='&#92;varphi &#92;colon V &#92;rightarrow V&#039; &#92;colon w &#92;mapsto (v &#92;mapsto &#92;langle v , w &#92;rangle)' class='latex' /> is an isomorphism of vector spaces. Restated, we can associate each linear map uniquely <img src='http://s0.wp.com/latex.php?latex=f+%5Ccolon+V+%5Crightarrow+%5Cmathbb%7BR%7D&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='f &#92;colon V &#92;rightarrow &#92;mathbb{R}' title='f &#92;colon V &#92;rightarrow &#92;mathbb{R}' class='latex' /> with a vector <img src='http://s0.wp.com/latex.php?latex=w+%5Cin+V&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='w &#92;in V' title='w &#92;in V' class='latex' /> such that <img src='http://s0.wp.com/latex.php?latex=f%28x%29+%3A%3D+%5Clangle+x%2Cw+%5Crangle&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='f(x) := &#92;langle x,w &#92;rangle' title='f(x) := &#92;langle x,w &#92;rangle' class='latex' />. </p>
<h4>Proof:</h4>
<h5>Linearity:</h5>
<p>let <img src='http://s0.wp.com/latex.php?latex=u%2Cv+%5Cin+V%2C+%5Clambda%2C+%5Cmu+%5Cin+%5Cmathbb%7BR%7D&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='u,v &#92;in V, &#92;lambda, &#92;mu &#92;in &#92;mathbb{R}' title='u,v &#92;in V, &#92;lambda, &#92;mu &#92;in &#92;mathbb{R}' class='latex' /><br />
<img src='http://s0.wp.com/latex.php?latex=%5Cvarphi%28%5Clambda+u+%2B+%5Cmu+v%29%28x%29&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='&#92;varphi(&#92;lambda u + &#92;mu v)(x)' title='&#92;varphi(&#92;lambda u + &#92;mu v)(x)' class='latex' /><br />
<img src='http://s0.wp.com/latex.php?latex=%3D+%5Clangle+x%2C+%5Clambda+u+%2B+%5Cmu+v+%5Crangle&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='= &#92;langle x, &#92;lambda u + &#92;mu v &#92;rangle' title='= &#92;langle x, &#92;lambda u + &#92;mu v &#92;rangle' class='latex' /><br />
<img src='http://s0.wp.com/latex.php?latex=%3D+%5Clambda+%5Clangle+x%2C+u+%5Crangle+%2B+%5Cmu+%5Clangle+x+%2C+v+%5Crangle&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='= &#92;lambda &#92;langle x, u &#92;rangle + &#92;mu &#92;langle x , v &#92;rangle' title='= &#92;lambda &#92;langle x, u &#92;rangle + &#92;mu &#92;langle x , v &#92;rangle' class='latex' /><br />
<img src='http://s0.wp.com/latex.php?latex=%3D+%5Cleft+%28+%5Clambda+%5Cvarphi%28u%29+%2B+%5Cmu+%5Cvarphi%28v%29+%5Cright+%29%28x%29&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='= &#92;left ( &#92;lambda &#92;varphi(u) + &#92;mu &#92;varphi(v) &#92;right )(x)' title='= &#92;left ( &#92;lambda &#92;varphi(u) + &#92;mu &#92;varphi(v) &#92;right )(x)' class='latex' /><br />
and hence we see this is a linear map.</p>
<h5>Injectivity:</h5>
<p>Suppose <img src='http://s0.wp.com/latex.php?latex=%5Clangle+v+%2C+w+%5Crangle+%3D+%5Clangle+v+%2C+w%27+%5Crangle+%5C%2C+%5Cforall+v+%5Cin+V&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='&#92;langle v , w &#92;rangle = &#92;langle v , w&#039; &#92;rangle &#92;, &#92;forall v &#92;in V' title='&#92;langle v , w &#92;rangle = &#92;langle v , w&#039; &#92;rangle &#92;, &#92;forall v &#92;in V' class='latex' /><br />
then <img src='http://s0.wp.com/latex.php?latex=%5Clangle+v%2C+w+-+w%27+%5Crangle++%3D+0+%5C%2C+%5Cforall+v+%5Cin+V&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='&#92;langle v, w - w&#039; &#92;rangle  = 0 &#92;, &#92;forall v &#92;in V' title='&#92;langle v, w - w&#039; &#92;rangle  = 0 &#92;, &#92;forall v &#92;in V' class='latex' /><br />
so specifically <img src='http://s0.wp.com/latex.php?latex=%5Clangle+w-w%27%2C+w+-+w%27+%5Crangle+%3D+0&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='&#92;langle w-w&#039;, w - w&#039; &#92;rangle = 0' title='&#92;langle w-w&#039;, w - w&#039; &#92;rangle = 0' class='latex' /><br />
thus by positive definiteness, <img src='http://s0.wp.com/latex.php?latex=w+%3D+w%27&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='w = w&#039;' title='w = w&#039;' class='latex' /> hence <img src='http://s0.wp.com/latex.php?latex=%5Cvarphi&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='&#92;varphi' title='&#92;varphi' class='latex' /> is injective.</p>
<h5>Surjectivity:</h5>
<p>Since we have that this is an injective linear map between spaces of the same dimension, this follows by Rank Nullity. Alternatively:<br />
let <img src='http://s0.wp.com/latex.php?latex=f+%5Cin+V%27&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='f &#92;in V&#039;' title='f &#92;in V&#039;' class='latex' /><br />
take a basis <img src='http://s0.wp.com/latex.php?latex=%5Cvarepsilon+%3D+%5C%7Be_1%2C+%5Cldots%2C+e_n%5C%7D&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='&#92;varepsilon = &#92;{e_1, &#92;ldots, e_n&#92;}' title='&#92;varepsilon = &#92;{e_1, &#92;ldots, e_n&#92;}' class='latex' /><br />
then define <img src='http://s0.wp.com/latex.php?latex=w+%3A%3D+%5Csum_%7Bi%3D1%7D%5En+%5Clangle+f%28e_i%29%2Ce_i+%5Crangle+e_i&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='w := &#92;sum_{i=1}^n &#92;langle f(e_i),e_i &#92;rangle e_i' title='w := &#92;sum_{i=1}^n &#92;langle f(e_i),e_i &#92;rangle e_i' class='latex' /><br />
and we can check that this works.</p>
<p>Now to use this theorem to show the connection.</p>
<p><img src='http://s0.wp.com/latex.php?latex=X%5E%7B%5Ccirc%7D+%3A%3D+%5C%7B+f+%5Cin+V%27+%5Cmid+f%28x%29+%3D+0+%5C%2C+%5Cforall+x+%5Cin+X+%5C%7D&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='X^{&#92;circ} := &#92;{ f &#92;in V&#039; &#92;mid f(x) = 0 &#92;, &#92;forall x &#92;in X &#92;}' title='X^{&#92;circ} := &#92;{ f &#92;in V&#039; &#92;mid f(x) = 0 &#92;, &#92;forall x &#92;in X &#92;}' class='latex' /><br />
but <img src='http://s0.wp.com/latex.php?latex=%5Cforall+f+%5Cin+V%27%2C+f+%3D+%5Cvarphi%28w%29&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='&#92;forall f &#92;in V&#039;, f = &#92;varphi(w)' title='&#92;forall f &#92;in V&#039;, f = &#92;varphi(w)' class='latex' /> for some <img src='http://s0.wp.com/latex.php?latex=w+%5Cin+V&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='w &#92;in V' title='w &#92;in V' class='latex' />.<br />
thus <img src='http://s0.wp.com/latex.php?latex=X%5E%7B%5Ccirc%7D+%3D+%5C%7B%5Cvarphi%28w%29+%5Cmid+%5Cvarphi%28w%29%28x%29+%3D+%5Clangle+x+%2C+w+%5Crangle+%3D+0+%5C%2C+%5Cforall+x+%5Cin+X+%5C%7D+%3D+%5Cvarphi%28X%5E%7B%5Cbot%7D%29&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='X^{&#92;circ} = &#92;{&#92;varphi(w) &#92;mid &#92;varphi(w)(x) = &#92;langle x , w &#92;rangle = 0 &#92;, &#92;forall x &#92;in X &#92;} = &#92;varphi(X^{&#92;bot})' title='X^{&#92;circ} = &#92;{&#92;varphi(w) &#92;mid &#92;varphi(w)(x) = &#92;langle x , w &#92;rangle = 0 &#92;, &#92;forall x &#92;in X &#92;} = &#92;varphi(X^{&#92;bot})' class='latex' /></p>
<p>So we have the result we wanted:<br />
<img src='http://s0.wp.com/latex.php?latex=%5Chuge+X%5E%7B%5Ccirc%7D+%3D+%5Cvarphi%28X%5E%7B%5Cbot%7D%29+&amp;bg=ffffff&amp;fg=000&amp;s=4' alt='&#92;huge X^{&#92;circ} = &#92;varphi(X^{&#92;bot}) ' title='&#92;huge X^{&#92;circ} = &#92;varphi(X^{&#92;bot}) ' class='latex' /></p>
<h2>Applications</h2>
<p><strong>This means all of those oh-so-fun identities one derives for annihilator subspace structure can be passed over to perpendicular subspace structure!</strong></p>
<h4>Example:</h4>
<p>Given the identity <img src='http://s0.wp.com/latex.php?latex=X_1%5E%7B%5Ccirc%7D+%2B+X_2%5E%7B%5Ccirc%7D+%3D+%28X_1+%5Ccap+X_2%29%5E%7B%5Ccirc%7D&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='X_1^{&#92;circ} + X_2^{&#92;circ} = (X_1 &#92;cap X_2)^{&#92;circ}' title='X_1^{&#92;circ} + X_2^{&#92;circ} = (X_1 &#92;cap X_2)^{&#92;circ}' class='latex' /><br />
we can deduce <img src='http://s0.wp.com/latex.php?latex=%5Cvarphi+%5Cleft+%28+%28X_1+%5Ccap+X_2+%29%5E%7B%5Cbot%7D+%5Cright+%29+%3D+%28X_1+%5Ccap+X_2%29%5E%7B%5Ccirc%7D+%3D+X_1%5E%7B%5Ccirc%7D+%2B+X_2%5E%7B%5Ccirc%7D+%3D+%5Cvarphi%28X_1%5E%7B%5Cbot%7D%29+%2B+%5Cvarphi%28X_2%5E%7B%5Cbot%7D%29&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='&#92;varphi &#92;left ( (X_1 &#92;cap X_2 )^{&#92;bot} &#92;right ) = (X_1 &#92;cap X_2)^{&#92;circ} = X_1^{&#92;circ} + X_2^{&#92;circ} = &#92;varphi(X_1^{&#92;bot}) + &#92;varphi(X_2^{&#92;bot})' title='&#92;varphi &#92;left ( (X_1 &#92;cap X_2 )^{&#92;bot} &#92;right ) = (X_1 &#92;cap X_2)^{&#92;circ} = X_1^{&#92;circ} + X_2^{&#92;circ} = &#92;varphi(X_1^{&#92;bot}) + &#92;varphi(X_2^{&#92;bot})' class='latex' /><br />
linearity of <img src='http://s0.wp.com/latex.php?latex=%5Cvarphi&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='&#92;varphi' title='&#92;varphi' class='latex' /> gives us <img src='http://s0.wp.com/latex.php?latex=%5Cvarphi%28X_1%5E%7B%5Cbot%7D%29+%2B+%5Cvarphi%28X_2%5E%7B%5Cbot%7D%29%3D+%5Cvarphi%28X_1%5E%7B%5Cbot%7D+%2B+X_2%5E%7B%5Cbot%7D%29&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='&#92;varphi(X_1^{&#92;bot}) + &#92;varphi(X_2^{&#92;bot})= &#92;varphi(X_1^{&#92;bot} + X_2^{&#92;bot})' title='&#92;varphi(X_1^{&#92;bot}) + &#92;varphi(X_2^{&#92;bot})= &#92;varphi(X_1^{&#92;bot} + X_2^{&#92;bot})' class='latex' /><br />
so by injectivity of <img src='http://s0.wp.com/latex.php?latex=%5Cvarphi+&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='&#92;varphi ' title='&#92;varphi ' class='latex' /> we have <img src='http://s0.wp.com/latex.php?latex=%28X_1+%5Ccap+X_2%29%5E%7B%5Cbot%7D+%3D+X_1%5E%7B%5Cbot%7D+%2B+X_2%5E%7B%5Cbot%7D&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='(X_1 &#92;cap X_2)^{&#92;bot} = X_1^{&#92;bot} + X_2^{&#92;bot}' title='(X_1 &#92;cap X_2)^{&#92;bot} = X_1^{&#92;bot} + X_2^{&#92;bot}' class='latex' /></p>
<p>i.e. compare<br />
<img src='http://s0.wp.com/latex.php?latex=X_1%5E%7B%5Ccirc%7D+%2B+X_2%5E%7B%5Ccirc%7D+%3D+%28X_1+%5Ccap+X_2%29%5E%7B%5Ccirc%7D+&amp;bg=ffffff&amp;fg=000&amp;s=3' alt='X_1^{&#92;circ} + X_2^{&#92;circ} = (X_1 &#92;cap X_2)^{&#92;circ} ' title='X_1^{&#92;circ} + X_2^{&#92;circ} = (X_1 &#92;cap X_2)^{&#92;circ} ' class='latex' /><br />
to<br />
<img src='http://s0.wp.com/latex.php?latex=X_1%5E%7B%5Cbot%7D+%2B+X_2%5E%7B%5Cbot%7D+%3D+%28X_1+%5Ccap+X_2%29%5E%7B%5Cbot%7D+&amp;bg=ffffff&amp;fg=000&amp;s=3' alt='X_1^{&#92;bot} + X_2^{&#92;bot} = (X_1 &#92;cap X_2)^{&#92;bot} ' title='X_1^{&#92;bot} + X_2^{&#92;bot} = (X_1 &#92;cap X_2)^{&#92;bot} ' class='latex' /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ardoris.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ardoris.wordpress.com/413/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ardoris.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ardoris.wordpress.com/413/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ardoris.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ardoris.wordpress.com/413/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ardoris.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ardoris.wordpress.com/413/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ardoris.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ardoris.wordpress.com/413/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ardoris.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ardoris.wordpress.com/413/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ardoris.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ardoris.wordpress.com/413/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ardoris.wordpress.com&amp;blog=4109393&amp;post=413&amp;subd=ardoris&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ardoris.wordpress.com/2010/12/15/annihilators-perpendicular-spaces/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/53b7018a0bf92b1f9cb0b08a8a45e4ff?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bavardage</media:title>
		</media:content>
	</item>
		<item>
		<title>Dual Numbers, Automatic Differentiation, Haskell</title>
		<link>http://ardoris.wordpress.com/2010/12/10/dual-numbers-automatic-differentiation-haskell/</link>
		<comments>http://ardoris.wordpress.com/2010/12/10/dual-numbers-automatic-differentiation-haskell/#comments</comments>
		<pubDate>Fri, 10 Dec 2010 23:37:57 +0000</pubDate>
		<dc:creator>jebavarde</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[complex numbers]]></category>
		<category><![CDATA[differentiation]]></category>
		<category><![CDATA[dual numbers]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[quotient]]></category>

		<guid isPermaLink="false">http://ardoris.wordpress.com/?p=383</guid>
		<description><![CDATA[Duals are an extension to a number system such that has a non-zero solution. We could consider them as a quotient: &#8211; take a ring &#8211; quotient by the ideal Since we can keep things general in the theory, I&#8217;m &#8230; <a href="http://ardoris.wordpress.com/2010/12/10/dual-numbers-automatic-differentiation-haskell/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ardoris.wordpress.com&amp;blog=4109393&amp;post=383&amp;subd=ardoris&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Duals are an extension to a number system such that <img src='http://s0.wp.com/latex.php?latex=x%5E2+%3D+0&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='x^2 = 0' title='x^2 = 0' class='latex' /> has a non-zero solution.<br />
We could consider them as a quotient:<br />
 &#8211; take a ring <img src='http://s0.wp.com/latex.php?latex=R&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='R' title='R' class='latex' /><br />
 &#8211; quotient <img src='http://s0.wp.com/latex.php?latex=R%5BX%5D&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='R[X]' title='R[X]' class='latex' /> by the ideal <img src='http://s0.wp.com/latex.php?latex=%3C+X%5E2+%3E&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='&lt; X^2 &gt;' title='&lt; X^2 &gt;' class='latex' /></p>
<p>Since we can keep things general in the theory, I&#8217;m going to take<br />
duals over a general type a. Maybe I should look into the mathematical<br />
prelude so that I will be able to specify a to be a ring, but that&#8217;s<br />
for another day.</p>
<p>&gt; data Dual a = D a a deriving Show</p>
<h4>Some Notation</h4>
<p>I shall also slip in and out of the notation <img src='http://s0.wp.com/latex.php?latex=a+%2B+b%5Cmathrm%7Bj%7D&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='a + b&#92;mathrm{j}' title='a + b&#92;mathrm{j}' class='latex' /> to represent the Dual (D a b).</p>
<p>We could maybe use some utility functions to give us the &#8216;real&#8217; and &#8216;dual&#8217; parts</p>
<p>&gt; real, dual :: Dual a -&gt; a<br />
&gt; real (D a _) = a<br />
&gt; dual (D _ b) = b</p>
<p>In some ways, we can consider these as an analogue of the complex numbers,<br />
but instead with <img src='http://s0.wp.com/latex.php?latex=j%5E2+%3D+0&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='j^2 = 0' title='j^2 = 0' class='latex' />. Anyhow, equality comes naturally as follows.<br />
(We could get this from the polynomial definition using the coset definition of<br />
equality)</p>
<p>&gt; instance Eq a =&gt; Eq (Dual a) where<br />
&gt;   (D a b) == (D c d) = (a == c) &amp;&amp; (b == d)</p>
<p>Now, we want to treat this as a number.<br />
Since things commute, addition and multiplication come naturally.</p>
<p>&gt; instance Num a =&gt; Num (Dual a) where<br />
&gt;    (D a b) + (D c d) = D (a+c) (b+d)<br />
&gt;    (D a b) * (D c d) = D (a*c) (b*c + a*d)</p>
<p>Again, negation is fairly obvious</p>
<p>&gt;    negate (D a b) = D (-a) (-b)</p>
<p>Now Haskell wants us to give a definition for signum &#8211; i.e. give<br />
some kind of subset of &#8216;positive&#8217; duals.<br />
Not sure that this really makes much sense. I&#8217;ll leave it undefined for now.</p>
<p>&gt;    signum (D a b) = undefined</p>
<p><del datetime="2010-12-11T12:12:34+00:00">We also need to give an &#8216;abs&#8217;. Taking inspiration from complex numbers,<br />
if we were to define abs (D a b) to be  (D a b)*(D a -b) we end up with</del></p>
<p><del datetime="2010-12-11T12:12:34+00:00">&gt;    abs (D a b) = D (abs a) 0</del></p>
<p>This is all kind of crazy! The complex numbers modulus maps from <img src='http://s0.wp.com/latex.php?latex=%5Cmathbb%7BC%7D+%5Crightarrow+%5Cmathbb%7BR%7D&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='&#92;mathbb{C} &#92;rightarrow &#92;mathbb{R}' title='&#92;mathbb{C} &#92;rightarrow &#92;mathbb{R}' class='latex' /> whereas Haskell requires us to give a function from Duals to Duals. I can&#8217;t seem to see anywhere what properties such an abs function should have.</p>
<p>Haskell&#8217;s implementation of complex numbers does seem to give something similar to my implementation.<br />
<img src='http://s0.wp.com/latex.php?latex=%5Cmathrm%7Babs+%7D+z+%5Cmapsto+%7Cz%7C+%2B+0i&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='&#92;mathrm{abs } z &#92;mapsto |z| + 0i' title='&#92;mathrm{abs } z &#92;mapsto |z| + 0i' class='latex' /></p>
<p>For now then, I&#8217;ll just use the definition given here: http://en.wikipedia.org/wiki/Automatic_differentiation#Automatic_differentiation_using_dual_numbers</p>
<p>Finally we need to give a way of converting from integrals to duals &#8211; just<br />
take the &#8216;dual&#8217; part to be 0</p>
<p>&gt;    fromInteger n = D (fromIntegral n) 0</p>
<p>Now since Dual numbers are PRETTY MAGIC<br />
 &#8211; f(D a 1) = D f(a) f&#8217;(a)<br />
we can automagically differentiate functions of type Num a =&gt; a -&gt; a</p>
<p>&gt; deriv :: Num a =&gt; (Dual a -&gt; Dual b) -&gt; a -&gt; b<br />
&gt; deriv f x = dual $ f (D x 1)</p>
<p>Now we could probably do with some notion of division!</p>
<p>but how?!</p>
<p>(D a b) / (D c d) = (D a b) * (D c -d) / c² ?!?!</p>
<p>let&#8217;s try and see if crazy happens.</p>
<p>&gt; instance Fractional a =&gt; Fractional (Dual a) where<br />
&gt;     (D a b) / (D c d) = D (real x / (c*c)) (dual x / (c*c))<br />
&gt;         where<br />
&gt;           x = (D a b) * (D c (-d))<br />
&gt;     fromRational r = D (fromRational r) 0</p>
<p>Everything seems fine!</p>
<p>Now for maybe the more interesting bit, I&#8217;d like to implement Duals for<br />
standard functions &#8211; sin, cos, &#8230; etc<br />
In haskell, this means implementing the Floating class.</p>
<p>&gt; instance Floating a =&gt; Floating (Dual a) where</p>
<p>Taking pi to be the Dual with &#8216;real&#8217; part of pi seems sensible,<br />
though maybe we should ensure that this is still twice the first<br />
&#8216;positive&#8217; root of cos, though quite what positive means.<br />
Since it seems good to have that <img src='http://s0.wp.com/latex.php?latex=cos%28%5Cpi%2F2%29+%3D+0&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='cos(&#92;pi/2) = 0' title='cos(&#92;pi/2) = 0' class='latex' />,<br />
let us take pi to be <img src='http://s0.wp.com/latex.php?latex=%5Cpi+%2B+2%5Cpi%5Cmathrm%7Bj%7D&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='&#92;pi + 2&#92;pi&#92;mathrm{j}' title='&#92;pi + 2&#92;pi&#92;mathrm{j}' class='latex' /></p>
<p>&gt;     pi = D pi (2*pi)</p>
<p>Next thing to define is exp. Taking the power series definition,<br />
and noting that</p>
<p><img src='http://s0.wp.com/latex.php?latex=%28a%2Bb%5Cmathrm%7Bj%7D%29%5En+%3D+a%5En+%2B+n+b+a%5E%7Bn-1%7D%5Cmathrm%7Bj%7D&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='(a+b&#92;mathrm{j})^n = a^n + n b a^{n-1}&#92;mathrm{j}' title='(a+b&#92;mathrm{j})^n = a^n + n b a^{n-1}&#92;mathrm{j}' class='latex' /><br />
(which follows from binomially expanding <img src='http://s0.wp.com/latex.php?latex=%28a%2Bb%5Cmathrm%7Bj%7D%29%5En&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='(a+b&#92;mathrm{j})^n' title='(a+b&#92;mathrm{j})^n' class='latex' /> and then noting that all other terms contain a <img src='http://s0.wp.com/latex.php?latex=j%5E2&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='j^2' title='j^2' class='latex' />.</p>
<p>it follows trivially that</p>
<p>&gt;     exp (D a b) = D (exp a) (b*(exp a))</p>
<p>Ok, so maybe something better is happening here.<br />
Why not try a general power series. If we have:<br />
<img src='http://s0.wp.com/latex.php?latex=f%28x%29+%3D+%5Csum_0%5E%5Cinfty+a_n+x%5En+&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='f(x) = &#92;sum_0^&#92;infty a_n x^n ' title='f(x) = &#92;sum_0^&#92;infty a_n x^n ' class='latex' /><br />
Then we can try sticking in the dual <img src='http://s0.wp.com/latex.php?latex=x+%2B+y%5Cmathrm%7Bj%7D&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='x + y&#92;mathrm{j}' title='x + y&#92;mathrm{j}' class='latex' /><br />
<img src='http://s0.wp.com/latex.php?latex=f%28x+%2B+y%5Cmathrm%7Bj%7D%29+%3D+%5Csum_0%5E%5Cinfty+a_n+x%5En+nyx%5E%7Bn-1%7D%5Cmathrm%7Bj%7D+&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='f(x + y&#92;mathrm{j}) = &#92;sum_0^&#92;infty a_n x^n nyx^{n-1}&#92;mathrm{j} ' title='f(x + y&#92;mathrm{j}) = &#92;sum_0^&#92;infty a_n x^n nyx^{n-1}&#92;mathrm{j} ' class='latex' /><br />
<img src='http://s0.wp.com/latex.php?latex=%3D+%5Csum_0%5E%5Cinfty+a_n+x%5En+%2B+%5Cleft+%28y%5Csum_1%5E%5Cinfty+a_n+n+x%5E%7Bn-1%7D+%5Cright+%29+%5Cmathrm%7Bj%7D+&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='= &#92;sum_0^&#92;infty a_n x^n + &#92;left (y&#92;sum_1^&#92;infty a_n n x^{n-1} &#92;right ) &#92;mathrm{j} ' title='= &#92;sum_0^&#92;infty a_n x^n + &#92;left (y&#92;sum_1^&#92;infty a_n n x^{n-1} &#92;right ) &#92;mathrm{j} ' class='latex' /></p>
<p>where we see the dual part is the termwise derivative! Woooop!<br />
so, taking what we already &#8216;know&#8217; of the derivatives of these functions<br />
(though quite how this is applicable when our underlying Num type isn&#8217;t sane)<br />
we get</p>
<p><img src='http://s0.wp.com/latex.php?latex=f%28a+%2B+b%5Cmathrm%7Bj%7D%29+%3D+f%28a%29+%2B+bf%27%28a%29+&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='f(a + b&#92;mathrm{j}) = f(a) + bf&#039;(a) ' title='f(a + b&#92;mathrm{j}) = f(a) + bf&#039;(a) ' class='latex' /></p>
<p>though, there is a problem in that, since haskell doesn&#8217;t &#8216;know&#8217;<br />
these functions are defined in terms of power series, we can&#8217;t use<br />
our existing deriv function to produce <img src='http://s0.wp.com/latex.php?latex=f%27+&amp;bg=ffffff&amp;fg=000&amp;s=0' alt='f&#039; ' title='f&#039; ' class='latex' /> :(<br />
Lets get cracking then&#8230;</p>
<p>&gt;     log (D a b) = D (log a) (b*(1/a))<br />
&gt;     sin (D a b) = D (sin a) (b*(cos a))<br />
&gt;     cos (D a b) = D (cos a) (b*(- sin a))<br />
&gt;     sinh (D a b) = D (sinh a) (b*(cosh a))<br />
&gt;     cosh (D a b) = D (cosh a) (b*(sinh a))</p>
<p>&#8211;leave the inverse trigometric and hyperbolics for now, I&#8217;m lazy :D</p>
<p>We can even do crazy things now by taking duals over complex numbers, though<br />
what this &#8216;means&#8217; I&#8217;m not yet sure.</p>
<p>I shall have to think on this.</p>
<p>On the other hand, we are now able to differentiate fairly complicated functions.</p>
<p>&gt; g x = (sin (x * cos (log (1 / (x**2 &#8211; 2*x + 3)))))**3<br />
&gt; g&#8217; = deriv g</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ardoris.wordpress.com/383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ardoris.wordpress.com/383/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ardoris.wordpress.com/383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ardoris.wordpress.com/383/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ardoris.wordpress.com/383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ardoris.wordpress.com/383/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ardoris.wordpress.com/383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ardoris.wordpress.com/383/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ardoris.wordpress.com/383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ardoris.wordpress.com/383/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ardoris.wordpress.com/383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ardoris.wordpress.com/383/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ardoris.wordpress.com/383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ardoris.wordpress.com/383/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ardoris.wordpress.com&amp;blog=4109393&amp;post=383&amp;subd=ardoris&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ardoris.wordpress.com/2010/12/10/dual-numbers-automatic-differentiation-haskell/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/53b7018a0bf92b1f9cb0b08a8a45e4ff?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bavardage</media:title>
		</media:content>
	</item>
		<item>
		<title>Idoru ~ William Gibson</title>
		<link>http://ardoris.wordpress.com/2010/09/20/idoru-william-gibson/</link>
		<comments>http://ardoris.wordpress.com/2010/09/20/idoru-william-gibson/#comments</comments>
		<pubDate>Mon, 20 Sep 2010 19:50:22 +0000</pubDate>
		<dc:creator>jebavarde</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[gibson]]></category>
		<category><![CDATA[idoru]]></category>
		<category><![CDATA[japan]]></category>
		<category><![CDATA[neuromancer]]></category>
		<category><![CDATA[sprawl]]></category>
		<category><![CDATA[the bridge]]></category>

		<guid isPermaLink="false">http://ardoris.wordpress.com/?p=374</guid>
		<description><![CDATA[Book Two of the &#8216;Bridge Trilogy&#8217; Published 1996 He sifts through vistas of data and from the chaos identifies nodal points: places where data from various media come together, hinting at the near future. No. Not Gibson himself, but Laney, &#8230; <a href="http://ardoris.wordpress.com/2010/09/20/idoru-william-gibson/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ardoris.wordpress.com&amp;blog=4109393&amp;post=374&amp;subd=ardoris&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h4>Book Two of the &#8216;Bridge Trilogy&#8217;</h4>
<h5>Published 1996</h5>
<p>He sifts through vistas of data and from the chaos identifies nodal points: places where data from various media come together, hinting at the near future.<br />
No. Not Gibson himself, but Laney, a &#8216;quantitative-analyst&#8217; and one of the protagonists of the novel.</p>
<p>Maybe it&#8217;s slightly strange coming to this after reading Gibson&#8217;s later work &#8211; this book feels almost like a stepping stone between the dark, grittyness of Neuromancer (published 1984) and the fast-paced but somehow much lighter Pattern Recognition (published 2003).</p>
<p>The vision of cyberspace in <em>Idoru</em> is much more concrete, visual than that in <em>The Sprawl</em> trilogy &#8211; nearer <em>Snowcrash</em> (Neal Stephenson, 1992) than the neon data-vistas of Neuromancer. Not that this book isn&#8217;t Gibson through and through. The focus on the minutae, the tech-heavy slang-heavy vocabulary and the seperate-yet-linked viewpoints.</p>
<p>It will be interesting to see how this fits in with the rest of the Bridge books &#8211; I&#8217;ve yet to read <em>All Tomorrow&#8217;s Parties</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ardoris.wordpress.com/374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ardoris.wordpress.com/374/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ardoris.wordpress.com/374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ardoris.wordpress.com/374/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ardoris.wordpress.com/374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ardoris.wordpress.com/374/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ardoris.wordpress.com/374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ardoris.wordpress.com/374/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ardoris.wordpress.com/374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ardoris.wordpress.com/374/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ardoris.wordpress.com/374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ardoris.wordpress.com/374/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ardoris.wordpress.com/374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ardoris.wordpress.com/374/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ardoris.wordpress.com&amp;blog=4109393&amp;post=374&amp;subd=ardoris&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ardoris.wordpress.com/2010/09/20/idoru-william-gibson/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/53b7018a0bf92b1f9cb0b08a8a45e4ff?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bavardage</media:title>
		</media:content>
	</item>
		<item>
		<title>Converting Inline Latex to Images with Javascript and Google Chart API</title>
		<link>http://ardoris.wordpress.com/2010/06/27/converting-inline-latex-to-images-with-javascript-and-google-chart-api/</link>
		<comments>http://ardoris.wordpress.com/2010/06/27/converting-inline-latex-to-images-with-javascript-and-google-chart-api/#comments</comments>
		<pubDate>Sun, 27 Jun 2010 21:10:50 +0000</pubDate>
		<dc:creator>jebavarde</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[google chart api]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[latex]]></category>
		<category><![CDATA[maths]]></category>
		<category><![CDATA[tex]]></category>

		<guid isPermaLink="false">http://ardoris.wordpress.com/?p=368</guid>
		<description><![CDATA[So, you&#8217;d like to be able to display inline latex in your pages, but setting up jsLatex is a hassle. Why not abuse what&#8217;s already there? Google Chart API supports the creation of images of latex code via urls: http://chart.apis.google.com/chart?cht=tx&#038;chl=\displaystyle%20exp(x)%20%3D%20\sum_{n%3D0}^{\infty}\frac{x^n}{n!} &#8230; <a href="http://ardoris.wordpress.com/2010/06/27/converting-inline-latex-to-images-with-javascript-and-google-chart-api/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ardoris.wordpress.com&amp;blog=4109393&amp;post=368&amp;subd=ardoris&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So, you&#8217;d like to be able to display inline latex in your pages, but setting up jsLatex is a hassle. Why not <del datetime="2010-06-27T20:47:58+00:00">ab</del>use what&#8217;s already there?</p>
<p>Google Chart API supports the creation of images of latex code via urls:</p>
<p>http://chart.apis.google.com/chart?cht=tx&#038;chl=\displaystyle%20exp(x)%20%3D%20\sum_{n%3D0}^{\infty}\frac{x^n}{n!}</p>
<p>kinda messy, right?</p>
<p>It wouldn&#8217;t be so good to hardcode this url each time, but using jquery, we can automate this process fairly well.</p>
<h3>The Script</h3>
<p>Put this somewhere in your page, probably within  tags in the head.</p>
<pre class="brush: jscript;">
function process_latex() {
    $('pre.latex').each(function(e) {
      var tex = $(this).text();
      var url = &quot;http://chart.apis.google.com/chart?cht=tx&amp;chl=&quot; + encodeURIComponent(tex);
      var cls = $(this).attr('class');
      var img = '&lt;img src=&quot;' + url + '&quot; alt=&quot;' + tex + '&quot; class=&quot;' + cls + '&quot;/&gt;';
      $(img).css('display', 'block').insertBefore($(this));
      $(this).hide();
    });
  }
</pre>
<p>Then make sure the function is called on page load, i.e. add to your $(document).ready handler</p>
<pre class="brush: jscript;">
$(document).ready(function() {process_latex();});
</pre>
<h3>Usage</h3>
<p>Type the latex within <code>&lt;pre class="latex"&gt;&lt;/pre&gt;</code> tags.<br />
To give more control over styling the resulting images, the images will have whatever classes the <code>
<pre></pre>
<p></code>s also have.</p>
<h3>Example Usage</h3>
<p><a href="http://ardoris.files.wordpress.com/2010/06/2010-06-27-220756_509x155_scrot.png"><img src="http://ardoris.files.wordpress.com/2010/06/2010-06-27-220756_509x155_scrot.png?w=490&#038;h=149" alt="Three formulae rendered with Google Chart API" title="Example Usage" width="490" height="149" class="aligncenter size-full wp-image-371" /></a></p>
<pre class="brush: xml;">
&lt;html&gt;
  &lt;head&gt;
    &lt;script src=&quot;script/jquery-1.4.2.js&quot;&gt;&lt;/script&gt;
    &lt;style&gt;
      .latex { vertical-align: middle;} /*default styling for latex imgs */
      .bordered { border: 1px solid red;}
      .block { display: block; }
    &lt;/style&gt;

    &lt;script&gt;
      function process_latex() {
        $('pre.latex').each(function(e) {
          var tex = $(this).text();
          var url = &quot;http://chart.apis.google.com/chart?cht=tx&amp;chl=&quot; + encodeURIComponent(tex);
          var cls = $(this).attr('class');
          var img = '&lt;img src=&quot;' + url + '&quot; alt=&quot;' + tex + '&quot; class=&quot;' + cls + '&quot;/&gt;';
          $(img).insertBefore($(this));
          $(this).hide();
        });
      }
      $(document).ready(function() {process_latex();});
    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    Default look:
    &lt;pre class=&quot;latex&quot;&gt;
      \sin(x)
    &lt;/pre&gt;
    how about an inlined, red bordered formula?
    &lt;pre class=&quot;latex bordered&quot;&gt;
      \sum_0^\infty \frac{x^n}{n!}
    &lt;/pre&gt;
    Very nice! And if we give it the block class?
    &lt;pre class=&quot;latex block&quot;&gt;
      \int \int_{\mathbb{R}^2} \exp(-x^2 - y^2) dx dy
    &lt;/pre&gt;
    See, it went on its own line. Magic!
  &lt;/body&gt;
&lt;/html&gt;
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ardoris.wordpress.com/368/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ardoris.wordpress.com/368/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ardoris.wordpress.com/368/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ardoris.wordpress.com/368/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ardoris.wordpress.com/368/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ardoris.wordpress.com/368/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ardoris.wordpress.com/368/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ardoris.wordpress.com/368/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ardoris.wordpress.com/368/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ardoris.wordpress.com/368/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ardoris.wordpress.com/368/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ardoris.wordpress.com/368/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ardoris.wordpress.com/368/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ardoris.wordpress.com/368/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ardoris.wordpress.com&amp;blog=4109393&amp;post=368&amp;subd=ardoris&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ardoris.wordpress.com/2010/06/27/converting-inline-latex-to-images-with-javascript-and-google-chart-api/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/53b7018a0bf92b1f9cb0b08a8a45e4ff?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bavardage</media:title>
		</media:content>

		<media:content url="http://ardoris.files.wordpress.com/2010/06/2010-06-27-220756_509x155_scrot.png" medium="image">
			<media:title type="html">Example Usage</media:title>
		</media:content>
	</item>
		<item>
		<title>Processing an RSS Feed with Javascript using Google Reader + JSON + jQuery</title>
		<link>http://ardoris.wordpress.com/2009/09/12/processing-an-rss-feed-with-javascript-using-google-reader-json-jquery/</link>
		<comments>http://ardoris.wordpress.com/2009/09/12/processing-an-rss-feed-with-javascript-using-google-reader-json-jquery/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 22:37:03 +0000</pubDate>
		<dc:creator>jebavarde</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[atom]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[google reader]]></category>
		<category><![CDATA[javascript rss]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[json]]></category>

		<guid isPermaLink="false">http://ardoris.wordpress.com/?p=357</guid>
		<description><![CDATA[Instead of having to use one of the various javascript rss libraries, one can take advantage of google reader&#8217;s (undocumented) api. note: the following assumes that the jQuery library is being used Google Reader gives any rss/atom feed in JSON &#8230; <a href="http://ardoris.wordpress.com/2009/09/12/processing-an-rss-feed-with-javascript-using-google-reader-json-jquery/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ardoris.wordpress.com&amp;blog=4109393&amp;post=357&amp;subd=ardoris&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Instead of having to use one of the various javascript rss libraries, one can take advantage of google reader&#8217;s (undocumented) api.</p>
<p><em>note: the following assumes that the jQuery library is being used</em><br />
<span id="more-357"></span><br />
Google Reader gives any rss/atom feed in JSON format, by visiting the url <a href="http://www.google.com/reader/public/javascript/feed/http://www.example.com/feed.rss">http://www.google.com/reader/public/javascript/feed/http://www.example.com/feed.rss</a> where <a href="http://www.example.com/feed.rss">http://www.example.com/feed.rss</a> is the url of the feed required as JSON.</p>
<p>An example of the JSON returned for this site&#8217;s feed &#8211; http://ardoris.wordpress.com/feed/</p>
<pre class="brush: jscript;">
{&quot;id&quot;:&quot;feed/http://ardoris.wordpress.com/feed/&quot;,
 &quot;title&quot;:&quot;feed/http://ardoris.wordpress.com/feed/&quot;,
 &quot;continuation&quot;:&quot;CJPduLTt45YC&quot;,
 &quot;alternate&quot;:{&quot;href&quot;:&quot;http://ardoris.wordpress.com&quot;,&quot;type&quot;:&quot;text/html&quot;},
 &quot;updated&quot;:1243372714,
 &quot;items&quot;:[
   {&quot;id&quot;:&quot;tag:google.com,2005:reader/item/be67929ea636a7ad&quot;,
     &quot;categories&quot;:[&quot;General&quot;],&quot;title&quot;:&quot;Haskell Snippet – Summing Series #2&quot;,
     &quot;published&quot;:1243369571,
     &quot;updated&quot;:1243369571,
     &quot;alternate&quot;:{&quot;href&quot;:&quot;http://ardoris.wordpress.com/2009/05/26/haskell-snippet-summing-series-2/&quot;,
                      &quot;type&quot;:&quot;text/html&quot;},
     &quot;content&quot;:&quot;\n\nJust a little hack using show to make the earlier summing series examplelook a bit nicer.\n\nStart with what I had before:\n\nsumseries a b f \u003d sum[f n|n\u003c-[a..b]]\n\nI have swapped around and renamed the arguments a little, just to tidy it up \na tad.\nSumming ...&quot;,&quot;author&quot;:&quot;jebavarde&quot;,&quot;likingUsers&quot;:[],&quot;comments&quot;:[],&quot;annotations&quot;:[],&quot;origin&quot;:{&quot;streamId&quot;:&quot;feed/http://ardoris.wordpress.com/feed/&quot;,&quot;htmlUrl&quot;:&quot;http://ardoris.wordpress.com&quot;}},
  &lt; ...more entries here ...&gt;
]};
</pre>
<p>Processing the feed is therefore as simple as iterating over the items.</p>
<h2>Example: listing the titles of all items in the feed in an <em>unordered list</em> of id <em>feed</em></h2>
<p>Put the following somewhere in the  of the page</p>
<pre class="brush: xml;">
&lt;ul id=&quot;feed&quot;&gt;
</pre>
<p>Then in the head, add something like the following:</p>
<pre class="brush: xml;">
&lt;script type=&quot;text/javascript&quot;&gt;
$(document).ready(function() {
  var url = &quot;http://www.google.com/reader/public/javascript/feed/http://ardoris.wordpress.com/feed/?callback=?&quot;;
  $.getJSON(url,
                 function(data) {
                   for(var i = 0; i &lt; data.items.length; i += 1)
                     $('#feed').append('&lt;li&gt;' + data.items[i].title + '');
                 });
});
&lt;/script&gt;
</pre>
<p>This can of course be extended by
</ul>
<ul>
<li>adding links to the feed items (to the url found at <code>data.items[i].alternate.href</code>) </li>
<li>following each title with a content summary (<code>data.items[i].content)</code></li>
<li>only processing the first so many entries in the feed (<code>for(var i = 0; i &lt; data.items.length &amp;&amp; i &lt; 3; i += 1)</code>)</li>
</ul>
<p><strong>n.b. This can also be used with atom feeds &#8211; just pass an atom feed in the url instead</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ardoris.wordpress.com/357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ardoris.wordpress.com/357/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ardoris.wordpress.com/357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ardoris.wordpress.com/357/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ardoris.wordpress.com/357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ardoris.wordpress.com/357/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ardoris.wordpress.com/357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ardoris.wordpress.com/357/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ardoris.wordpress.com/357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ardoris.wordpress.com/357/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ardoris.wordpress.com/357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ardoris.wordpress.com/357/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ardoris.wordpress.com/357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ardoris.wordpress.com/357/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ardoris.wordpress.com&amp;blog=4109393&amp;post=357&amp;subd=ardoris&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ardoris.wordpress.com/2009/09/12/processing-an-rss-feed-with-javascript-using-google-reader-json-jquery/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/53b7018a0bf92b1f9cb0b08a8a45e4ff?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bavardage</media:title>
		</media:content>
	</item>
	</channel>
</rss>
