<?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>Lost among notes</title>
	<atom:link href="http://lostamongnotes.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostamongnotes.wordpress.com</link>
	<description>geeky musings</description>
	<lastBuildDate>Sun, 19 Sep 2010 06:07:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='lostamongnotes.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Lost among notes</title>
		<link>http://lostamongnotes.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://lostamongnotes.wordpress.com/osd.xml" title="Lost among notes" />
	<atom:link rel='hub' href='http://lostamongnotes.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Xmonad + GNOME</title>
		<link>http://lostamongnotes.wordpress.com/2010/09/19/xmonad-gnome/</link>
		<comments>http://lostamongnotes.wordpress.com/2010/09/19/xmonad-gnome/#comments</comments>
		<pubDate>Sun, 19 Sep 2010 06:07:06 +0000</pubDate>
		<dc:creator>Jaime Silvela</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://lostamongnotes.wordpress.com/?p=93</guid>
		<description><![CDATA[I&#8217;m positively impressed with Linux lately, as I learn more. By combining the tiling window manager Xmonad with the GNOME environment, I&#8217;ve found my favorite windowing system on any platform. I used these basic instructions, but configured Xmonad to use &#8230; <a href="http://lostamongnotes.wordpress.com/2010/09/19/xmonad-gnome/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lostamongnotes.wordpress.com&amp;blog=5544941&amp;post=93&amp;subd=lostamongnotes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m positively impressed with Linux lately, as I learn more.<br />
By combining the tiling window manager Xmonad with the GNOME environment, I&#8217;ve found my favorite windowing system on any platform.</p>
<p>I used these <a href="http://markhansen.co.nz/xmonad-ubuntu-lucid">basic instructions</a>, but configured Xmonad to use the Window key (aka. Super key) as modifier instead of Alt, so that it doesn&#8217;t interfere with the Emacs keybindings. This is how it looks.<br />
<code><br />
import XMonad<br />
import XMonad.Config.Gnome</p>
<p>main = xmonad gnomeConfig<br />
              {<br />
                modMask = mod4Mask<br />
              }<br />
</code></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lostamongnotes.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lostamongnotes.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lostamongnotes.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lostamongnotes.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lostamongnotes.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lostamongnotes.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lostamongnotes.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lostamongnotes.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lostamongnotes.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lostamongnotes.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lostamongnotes.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lostamongnotes.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lostamongnotes.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lostamongnotes.wordpress.com/93/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lostamongnotes.wordpress.com&amp;blog=5544941&amp;post=93&amp;subd=lostamongnotes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lostamongnotes.wordpress.com/2010/09/19/xmonad-gnome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/da2573ea7ded6fa06b1e8f7dd293f680?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jsilvela</media:title>
		</media:content>
	</item>
		<item>
		<title>Recording from vinyl with Inspire and Cubase</title>
		<link>http://lostamongnotes.wordpress.com/2009/09/03/recording-from-vinyl-with-inspire-and-cubase/</link>
		<comments>http://lostamongnotes.wordpress.com/2009/09/03/recording-from-vinyl-with-inspire-and-cubase/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 16:36:27 +0000</pubDate>
		<dc:creator>Jaime Silvela</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://lostamongnotes.wordpress.com/?p=89</guid>
		<description><![CDATA[Connect the Inspire to the computer and the phono pre-amp Start the Inspire software and make sure channels 3-4 are unmuted and the volume is OK Start Cubase, do File =&#62; New Project, and Project =&#62; Add Track =&#62; Audio &#8230; <a href="http://lostamongnotes.wordpress.com/2009/09/03/recording-from-vinyl-with-inspire-and-cubase/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lostamongnotes.wordpress.com&amp;blog=5544941&amp;post=89&amp;subd=lostamongnotes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<ol>
<li>Connect the Inspire to the computer and the phono pre-amp</li>
<li>Start the Inspire software and make sure channels 3-4 are unmuted and the volume is OK </li>
<li>Start Cubase, do File =&gt; New Project, and Project =&gt; Add Track =&gt; Audio</li>
<li>Go to Devices =&gt; Device Setup</li>
<li>In the VST Audio System, choose the Inspire and hit OK</li>
<li>Go to Devices =&gt; VST Connections</li>
<li>In the Input tab, choose channels 3 and 4 for input</li>
<li>In the Output tab, choose channels 1 and 2 for output (connect your headphones to the Inspire, not the computer)</li>
</ol>
<p>You will need to keep the Inspire connected at all times, even if you&#8217;re exporting a pre-recorded track to  AIFF!<br />
With this you should be able to start recording.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lostamongnotes.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lostamongnotes.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lostamongnotes.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lostamongnotes.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lostamongnotes.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lostamongnotes.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lostamongnotes.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lostamongnotes.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lostamongnotes.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lostamongnotes.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lostamongnotes.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lostamongnotes.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lostamongnotes.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lostamongnotes.wordpress.com/89/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lostamongnotes.wordpress.com&amp;blog=5544941&amp;post=89&amp;subd=lostamongnotes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lostamongnotes.wordpress.com/2009/09/03/recording-from-vinyl-with-inspire-and-cubase/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/da2573ea7ded6fa06b1e8f7dd293f680?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jsilvela</media:title>
		</media:content>
	</item>
		<item>
		<title>Xmonad</title>
		<link>http://lostamongnotes.wordpress.com/2009/08/25/xmonad/</link>
		<comments>http://lostamongnotes.wordpress.com/2009/08/25/xmonad/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 06:00:14 +0000</pubDate>
		<dc:creator>Jaime Silvela</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://lostamongnotes.wordpress.com/?p=83</guid>
		<description><![CDATA[I like Xmonad much better than any other window manager (on any platform), but the default mod key is Alt, which interferes with Emacs and Conkeror. Here is how to remap the mod key in Xmonad Or, locally copied on &#8230; <a href="http://lostamongnotes.wordpress.com/2009/08/25/xmonad/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lostamongnotes.wordpress.com&amp;blog=5544941&amp;post=83&amp;subd=lostamongnotes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I like <a href="http://xmonad.org/">Xmonad</a> much better than any other window manager (on any platform), but the default mod key is Alt, which interferes with Emacs and Conkeror.</p>
<p>Here is how to <a href="http://haskell.org/haskellwiki/Xmonad/Frequently%5Fasked%5Fquestions#Rebinding%5Fthe%5Fmod%5Fkey%5F.28Alt%5Fconflicts%5Fwith%5Fother%5Fapps.3B%5FI%5Fwant%5Fthe%5F%5F%5F%5F%5Fkey.21.29">remap the mod key in Xmonad</a></p>
<p>Or, locally copied on Aug 09:</p>
<blockquote><p>
Binding to the mod4 (often &#8216;Win&#8217;) key. Put this in yout xmonad.hs:</p>
<p>import XMonad</p>
<p>main = xmonad defaultConfig<br />
         {<br />
           modMask = mod4Mask<br />
         }
</p></blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lostamongnotes.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lostamongnotes.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lostamongnotes.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lostamongnotes.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lostamongnotes.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lostamongnotes.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lostamongnotes.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lostamongnotes.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lostamongnotes.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lostamongnotes.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lostamongnotes.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lostamongnotes.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lostamongnotes.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lostamongnotes.wordpress.com/83/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lostamongnotes.wordpress.com&amp;blog=5544941&amp;post=83&amp;subd=lostamongnotes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lostamongnotes.wordpress.com/2009/08/25/xmonad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/da2573ea7ded6fa06b1e8f7dd293f680?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jsilvela</media:title>
		</media:content>
	</item>
		<item>
		<title>Scalar product and direction cosines</title>
		<link>http://lostamongnotes.wordpress.com/2008/12/08/scalar-product-and-direction-cosines/</link>
		<comments>http://lostamongnotes.wordpress.com/2008/12/08/scalar-product-and-direction-cosines/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 09:12:17 +0000</pubDate>
		<dc:creator>Jaime Silvela</dc:creator>
				<category><![CDATA[vectors]]></category>

		<guid isPermaLink="false">http://lostamongnotes.wordpress.com/?p=17</guid>
		<description><![CDATA[When I learned about the scalar product in high school, I was somewhat surprised by how lucky its properties are. The treatment is usually this: define , where is the angle between and . Then deduce that is linear on &#8230; <a href="http://lostamongnotes.wordpress.com/2008/12/08/scalar-product-and-direction-cosines/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lostamongnotes.wordpress.com&amp;blog=5544941&amp;post=17&amp;subd=lostamongnotes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When I learned about the scalar product in high school, I was somewhat surprised by how lucky its properties are.<br />
The treatment is usually this: define <img src='http://s0.wp.com/latex.php?latex=x+%5Ccdot+y+%3D+%7Cx%7C+%7Cy%7C+%5Ccos+%5Ctheta+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x &#92;cdot y = |x| |y| &#92;cos &#92;theta ' title='x &#92;cdot y = |x| |y| &#92;cos &#92;theta ' class='latex' />, where <img src='http://s0.wp.com/latex.php?latex=%5Ctheta+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;theta ' title='&#92;theta ' class='latex' /> is the angle between <img src='http://s0.wp.com/latex.php?latex=x+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x ' title='x ' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=y+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='y ' title='y ' class='latex' />. Then deduce that <img src='http://s0.wp.com/latex.php?latex=x+%5Ccdot+y+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x &#92;cdot y ' title='x &#92;cdot y ' class='latex' /> is linear on the left and right arguments. Then, deduce that <img src='http://s0.wp.com/latex.php?latex=%28x_1+%5Cvec+i+%2B+x_2+%5Cvec+j+%2B+x_3+%5Cvec+k%29+%5Ccdot+%28y_1+%5Cvec+i+%2B+y_2+%5Cvec+j+%2B+y_3+%5Cvec+k%29++%3D+x_1+y_1+%2B+x_2+y_2+%2B+x_3+y_3+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='(x_1 &#92;vec i + x_2 &#92;vec j + x_3 &#92;vec k) &#92;cdot (y_1 &#92;vec i + y_2 &#92;vec j + y_3 &#92;vec k)  = x_1 y_1 + x_2 y_2 + x_3 y_3 ' title='(x_1 &#92;vec i + x_2 &#92;vec j + x_3 &#92;vec k) &#92;cdot (y_1 &#92;vec i + y_2 &#92;vec j + y_3 &#92;vec k)  = x_1 y_1 + x_2 y_2 + x_3 y_3 ' class='latex' /></p>
<p>Now, define the direction cosines of a vector <img src='http://s0.wp.com/latex.php?latex=x+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x ' title='x ' class='latex' /> as the cosines of the angles the vector forms with the basis vectors. By definition: <img src='http://s0.wp.com/latex.php?latex=x+%3D+%7Cx%7C+%28%5Ccos+%5Cphi_1%2C+%5Ccos+%5Cphi_2%2C+%5Ccos+%5Cphi_3%29+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x = |x| (&#92;cos &#92;phi_1, &#92;cos &#92;phi_2, &#92;cos &#92;phi_3) ' title='x = |x| (&#92;cos &#92;phi_1, &#92;cos &#92;phi_2, &#92;cos &#92;phi_3) ' class='latex' />.<br />
If we define <img src='http://s0.wp.com/latex.php?latex=%5Ctheta+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;theta ' title='&#92;theta ' class='latex' /> as the angle between <img src='http://s0.wp.com/latex.php?latex=x+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x ' title='x ' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=y+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='y ' title='y ' class='latex' />, <img src='http://s0.wp.com/latex.php?latex=%5Calpha_i+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;alpha_i ' title='&#92;alpha_i ' class='latex' /> as the angles between <img src='http://s0.wp.com/latex.php?latex=x+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x ' title='x ' class='latex' /> and the axis, and <img src='http://s0.wp.com/latex.php?latex=%5Cbeta_i+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;beta_i ' title='&#92;beta_i ' class='latex' /> as the angles between <img src='http://s0.wp.com/latex.php?latex=y+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='y ' title='y ' class='latex' /> and the axis, we have: <img src='http://s0.wp.com/latex.php?latex=%5Ccos+%5Ctheta+%3D+%5Csum_i+%5Ccos+%5Calpha_i+%5Ccos+%5Cbeta_i+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;cos &#92;theta = &#92;sum_i &#92;cos &#92;alpha_i &#92;cos &#92;beta_i ' title='&#92;cos &#92;theta = &#92;sum_i &#92;cos &#92;alpha_i &#92;cos &#92;beta_i ' class='latex' />.</p>
<p>This last formula mystified me. The deduction was so purely algebraic that I found it unsatisfactory. I wanted to see the geometric meaning.</p>
<p>A more geometric deduction follows: <img src='http://s0.wp.com/latex.php?latex=%28%5Ccos+%5Calpha_1%2C+%5Ccos+%5Calpha_2%2C+%5Ccos+%5Calpha_3%29+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='(&#92;cos &#92;alpha_1, &#92;cos &#92;alpha_2, &#92;cos &#92;alpha_3) ' title='(&#92;cos &#92;alpha_1, &#92;cos &#92;alpha_2, &#92;cos &#92;alpha_3) ' class='latex' /> is a point <img src='http://s0.wp.com/latex.php?latex=a+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a ' title='a ' class='latex' /> on the unit sphere. If we take another point <img src='http://s0.wp.com/latex.php?latex=b+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='b ' title='b ' class='latex' /> on the unit sphere, the subtend an angle <img src='http://s0.wp.com/latex.php?latex=%5Ctheta+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;theta ' title='&#92;theta ' class='latex' />:<br />
<img src="http://jsilvela.smugmug.com/photos/432576072_eyeTJ-S.jpg" alt="On the unit sphere" /></p>
<p>On the unit sphere, we can find the angle <img src='http://s0.wp.com/latex.php?latex=%5Ctheta+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;theta ' title='&#92;theta ' class='latex' /> subtended by <img src='http://s0.wp.com/latex.php?latex=a+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a ' title='a ' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=b+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='b ' title='b ' class='latex' />, by calculating the distance <img src='http://s0.wp.com/latex.php?latex=l+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='l ' title='l ' class='latex' /> between them:<br />
<img src="http://jsilvela.smugmug.com/photos/432576073_8QviV-S.jpg" alt="Calculating the angle" /></p>
<p>As you can see in the picture, <img src='http://s0.wp.com/latex.php?latex=l+%3D+2+%5Csin+%5Cfrac%7B%5Ctheta%7D%7B2%7D+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='l = 2 &#92;sin &#92;frac{&#92;theta}{2} ' title='l = 2 &#92;sin &#92;frac{&#92;theta}{2} ' class='latex' />. Therefore: <img src='http://s0.wp.com/latex.php?latex=2+%5Csin+%5Cfrac%7B%5Ctheta%7D%7B2%7D+%3D+%5Csqrt+%28%5Csum+%28%5Ccos+%5Calpha_i+-+%5Ccos+%5Cbeta_i%29%5E2+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='2 &#92;sin &#92;frac{&#92;theta}{2} = &#92;sqrt (&#92;sum (&#92;cos &#92;alpha_i - &#92;cos &#92;beta_i)^2 ' title='2 &#92;sin &#92;frac{&#92;theta}{2} = &#92;sqrt (&#92;sum (&#92;cos &#92;alpha_i - &#92;cos &#92;beta_i)^2 ' class='latex' /><br />
By basic trigonometry: <img src='http://s0.wp.com/latex.php?latex=%5Csin+%5Cfrac%7B%5Ctheta%7D%7B2%7D+%3D+%5Csqrt+%5Cfrac%7B1+-+%5Ccos+%5Ctheta%7D%7B2%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;sin &#92;frac{&#92;theta}{2} = &#92;sqrt &#92;frac{1 - &#92;cos &#92;theta}{2}' title='&#92;sin &#92;frac{&#92;theta}{2} = &#92;sqrt &#92;frac{1 - &#92;cos &#92;theta}{2}' class='latex' /></p>
<p>Putting the above two together: <img src='http://s0.wp.com/latex.php?latex=4+%5Cfrac%7B1+-+%5Ccos+%5Ctheta%7D%7B2%7D+%3D+%5Csum+%28%5Ccos+%5Calpha_i+-+%5Ccos+%5Cbeta_i%29%5E2++%3D+%5Csum+%28%5Ccos%5E2+%5Calpha_i+-+2+%5Ccos+%5Calpha_i+%5Ccos+%5Cbeta_i+%2B+%5Ccos%5E2+%5Cbeta_i%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='4 &#92;frac{1 - &#92;cos &#92;theta}{2} = &#92;sum (&#92;cos &#92;alpha_i - &#92;cos &#92;beta_i)^2  = &#92;sum (&#92;cos^2 &#92;alpha_i - 2 &#92;cos &#92;alpha_i &#92;cos &#92;beta_i + &#92;cos^2 &#92;beta_i)' title='4 &#92;frac{1 - &#92;cos &#92;theta}{2} = &#92;sum (&#92;cos &#92;alpha_i - &#92;cos &#92;beta_i)^2  = &#92;sum (&#92;cos^2 &#92;alpha_i - 2 &#92;cos &#92;alpha_i &#92;cos &#92;beta_i + &#92;cos^2 &#92;beta_i)' class='latex' /><br />
Since <img src='http://s0.wp.com/latex.php?latex=a+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a ' title='a ' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=b+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='b ' title='b ' class='latex' /> are both on the unit sphere: <img src='http://s0.wp.com/latex.php?latex=4+%5Cfrac%7B1+-+%5Ccos+%5Ctheta%7D%7B2%7D+%3D+2+-+%5Csum+2+%5Ccos+%5Calpha_i+%5Ccos+%5Cbeta_i+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='4 &#92;frac{1 - &#92;cos &#92;theta}{2} = 2 - &#92;sum 2 &#92;cos &#92;alpha_i &#92;cos &#92;beta_i ' title='4 &#92;frac{1 - &#92;cos &#92;theta}{2} = 2 - &#92;sum 2 &#92;cos &#92;alpha_i &#92;cos &#92;beta_i ' class='latex' />,<br />
and <img src='http://s0.wp.com/latex.php?latex=%5Ccos+%5Ctheta+%3D+%5Csum+%5Ccos+%5Calpha_i+%5Ccos+%5Cbeta_i&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;cos &#92;theta = &#92;sum &#92;cos &#92;alpha_i &#92;cos &#92;beta_i' title='&#92;cos &#92;theta = &#92;sum &#92;cos &#92;alpha_i &#92;cos &#92;beta_i' class='latex' /></p>
<p>In this deduction of <img src='http://s0.wp.com/latex.php?latex=%5Ccos+%5Ctheta+&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;cos &#92;theta ' title='&#92;cos &#92;theta ' class='latex' />, we didn&#8217;t assume any knowledge of the scalar product. In fact, we could have used it as a basis for the definition of the scalar product.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lostamongnotes.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lostamongnotes.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lostamongnotes.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lostamongnotes.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lostamongnotes.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lostamongnotes.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lostamongnotes.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lostamongnotes.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lostamongnotes.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lostamongnotes.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lostamongnotes.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lostamongnotes.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lostamongnotes.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lostamongnotes.wordpress.com/17/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lostamongnotes.wordpress.com&amp;blog=5544941&amp;post=17&amp;subd=lostamongnotes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lostamongnotes.wordpress.com/2008/12/08/scalar-product-and-direction-cosines/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/da2573ea7ded6fa06b1e8f7dd293f680?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jsilvela</media:title>
		</media:content>

		<media:content url="http://jsilvela.smugmug.com/photos/432576072_eyeTJ-S.jpg" medium="image">
			<media:title type="html">On the unit sphere</media:title>
		</media:content>

		<media:content url="http://jsilvela.smugmug.com/photos/432576073_8QviV-S.jpg" medium="image">
			<media:title type="html">Calculating the angle</media:title>
		</media:content>
	</item>
		<item>
		<title>Number of trailing zeros in n factorial</title>
		<link>http://lostamongnotes.wordpress.com/2008/11/17/number-of-trailing-zeros-in-n-factorial/</link>
		<comments>http://lostamongnotes.wordpress.com/2008/11/17/number-of-trailing-zeros-in-n-factorial/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 06:52:29 +0000</pubDate>
		<dc:creator>Jaime Silvela</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://lostamongnotes.wordpress.com/?p=6</guid>
		<description><![CDATA[I was asked this question in my first job interview in this country. I was completely unprepared for this type of interview, and I did badly. But it&#8217;s a nice problem to think about and it&#8217;s easy to solve. In &#8230; <a href="http://lostamongnotes.wordpress.com/2008/11/17/number-of-trailing-zeros-in-n-factorial/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lostamongnotes.wordpress.com&amp;blog=5544941&amp;post=6&amp;subd=lostamongnotes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was asked this question in my first job interview in this country. I was completely unprepared for this type of interview, and I did badly. But it&#8217;s a nice problem to think about and it&#8217;s easy to solve.</p>
<p>In case you don&#8217;t know, n factorial is the multiplication of all positive integers less than or equal to n. By convention, 0 factorial is taken as 1. The factorial is typically represented with &#8220;!&#8217;.</p>
<p>So:</p>
<pre>0! = 1
1! = 1
2! = 2 1 = 2
3! = 3 2 1 = 6</pre>
<p>And so on. You may have noted the following pattern: n! = n (n-1)! This leads to the following recursive function in the Scheme language (you can get Scheme system <a href="http://download.plt-scheme.org/">here</a>)</p>
<pre>(define (factorial n)
  (if (= n 0)
      1
      (* n (factorial (- n 1)))))</pre>
<p>You can feed this to the Scheme system, and start getting numbers.</p>
<pre>(factorial 0)  --&gt; 1
(factorial 3)  --&gt; 6
(factorial 32) --&gt; 263130836933693530167218012160000000</pre>
<p>So, we want to be able to compute that 32! has 7 trailing zeros, but we don&#8217;t want to have to compute 32!</p>
<p>The key observation is this: the number of zeros equals the number of times 10 is a factor in 32! (or n!). 10 = 2 5, and since 2 appears more often than 5 in n!, we can say that the number of trailing zeros is the same as the number of times 5 is a factor in n!</p>
<p>Now, how do we count the number of times 5 is a factor? We can begin by observing that 32! = 32 31 30 .. 25 .. 20 .. 15 .. 10 .. 5 .. 1 (the .. stand for omitted numbers). So, we can see 6 of the factors in 32! are multiples of 5. And we can compute this number simply by diving by 5: 32 / 5 = 6 (assuming we discard the decimal part). That&#8217;s a start.</p>
<p>Now, we also have 25 in there, and it has two factors of 5; we need to account for the extra five. So, there are 6 + 1 = 7 factors of 5 in 32!, and 7 trailing zeros, which you can verify above. Nice. We could have started the opposite way, counting the number of &#8220;double fives&#8221; first, multiplying them by 2, then adding the &#8220;single fives&#8221;. But if we did that, we would have  to throw away the 25 when progressing toward the single fives, and that would be more baggage to keep track of. This way, also, we count for the &#8220;double five&#8221; only once, because 25 had been counted once as a &#8220;single five&#8221;.</p>
<p>So, number of fives in 32! = 32 / 5 + 32 / 25 = 6 + 1 = 7</p>
<p>We can formulate an algorithm informally: Number of fives in n! = n / 5 + n / 25 + n / 125 &#8230; (/ is assumed to be integer division ie. it discards decimals). Let&#8217;s give this function a name: fives-in-factorial(n). By the way, the &#8216;&#8230;&#8217; means &#8216;and so on&#8217;, but it would not make sense to go on forever, once one of the summands reaches 0.</p>
<p>Maybe you can see a pattern here: fives-in-factorial(n) = n / 5 + (n / 5) / 5 + (n / (5 * 5)) / 5 &#8230;</p>
<p>This suggests a recursive definition:</p>
<pre>fives-in-factorial(n) = n/5 + fives-in-factorial(n/5)</pre>
<p>The base of the recursion is that for n &lt; 5, there are no fives in n!, hence fives-in-factorial(n) = 0</p>
<p>Translated into code:</p>
<pre>(define (fives-in-factorial n)
  (if (&lt; n 5)
      0
      (+ (floor (/ n 5))
         (fives-in-factorial (/ n 5)))))</pre>
<p>(In case you&#8217;re wondering about &#8220;floor&#8221;: given a number, it discards its decimal part). You can again introduce this code in a Scheme system and start getting some answers. We already know 32.</p>
<pre>(factorial 32)           --&gt; 263130836933693530167218012160000000
(fives-in-factorial 32)  --&gt; 7

(factorial 6)            --&gt; 720
(fives-in-factorial 6)   --&gt; 1

(factorial 46)           --&gt; 5502622159812088949850305428800254892961651752960000000000
(fives-in-factorial 46)  --&gt; 10</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lostamongnotes.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lostamongnotes.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lostamongnotes.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lostamongnotes.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lostamongnotes.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lostamongnotes.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lostamongnotes.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lostamongnotes.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lostamongnotes.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lostamongnotes.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lostamongnotes.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lostamongnotes.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lostamongnotes.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lostamongnotes.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lostamongnotes.wordpress.com&amp;blog=5544941&amp;post=6&amp;subd=lostamongnotes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lostamongnotes.wordpress.com/2008/11/17/number-of-trailing-zeros-in-n-factorial/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/da2573ea7ded6fa06b1e8f7dd293f680?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jsilvela</media:title>
		</media:content>
	</item>
	</channel>
</rss>
