<?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/"
	>

<channel>
	<title>nklein software &#187; domain-specific languages</title>
	<atom:link href="http://nklein.com/tags/domain-specific-languages/feed/" rel="self" type="application/rss+xml" />
	<link>http://nklein.com</link>
	<description>software development and consulting</description>
	<lastBuildDate>Wed, 30 Jun 2010 14:00:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Lisp Patterns Question W.R.T. Clifford Algebras</title>
		<link>http://nklein.com/2009/05/lisp-patterns-question-wrt-clifford-algebras/</link>
		<comments>http://nklein.com/2009/05/lisp-patterns-question-wrt-clifford-algebras/#comments</comments>
		<pubDate>Wed, 20 May 2009 20:07:03 +0000</pubDate>
		<dc:creator>pat</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Clifford Algebras]]></category>
		<category><![CDATA[Math]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[domain-specific languages]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[patterns]]></category>

		<guid isPermaLink="false">http://nklein.com/?p=399</guid>
		<description><![CDATA[Since I moved my website to Wordpress, I have been watching what search-engine searches land people on my page.
Sadly, two of the things that get people to my page most often still have not been moved over to the new site from the old.  One of those things is a C++ template library for [...]]]></description>
			<content:encoded><![CDATA[<p>Since I moved my website to <a href="http://wordpress.org/">Wordpress</a>, I have been watching what search-engine searches land people on my page.</p>
<p>Sadly, two of the things that get people to my page most often still have not been moved over to the new site from <a href="http://old.nklein.com/">the old</a>.  One of those things is a C++ template library for Clifford algebras.  I am going to move that stuff over this week, I promise.  But, I thought I might also make a Lisp library for Clifford algebras, too.</p>
<p>An example Clifford algebra might be <img src="http://nklein.com/wp-content/plugins/easy-latex/cache/tex_831cf499b3d1348025a0b041556dba53.png" title="C_{3,0}" style="vertical-align:-20%;" class="tex" alt="C_{3,0}" />.  A generic element in this algebra is of the form:<br />
<center><img src="http://nklein.com/wp-content/plugins/easy-latex/cache/tex_4364cd217c74bd9a4b8208da1ff15007.png" title="a_0 + a_1 e_1 + a_2 e_2 + a_3 e_3 + a_{1,2} e_{1,2} + a_{1,3} e_{1,3} + a_{2,3} e_{2,3} + a_{1,2,3} e_{1,2,3}" style="vertical-align:-20%;" class="tex" alt="a_0 + a_1 e_1 + a_2 e_2 + a_3 e_3 + a_{1,2} e_{1,2} + a_{1,3} e_{1,3} + a_{2,3} e_{2,3} + a_{1,2,3} e_{1,2,3}" /></center><br />
where the <img src="http://nklein.com/wp-content/plugins/easy-latex/cache/tex_08c6fa8efe4c47cbbdfb20cbc36006e3.png" title="a_*" style="vertical-align:-20%;" class="tex" alt="a_*" /> are coefficients.  For ease in dealing with these items, I will probably store that in a vector that looks something like this:<br />
<center>#(<img src="http://nklein.com/wp-content/plugins/easy-latex/cache/tex_68e97f9899a45c2ef63d1d486b523827.png" title="a_0" style="vertical-align:-20%;" class="tex" alt="a_0" /> #(<img src="http://nklein.com/wp-content/plugins/easy-latex/cache/tex_2028c58b1756381efb66cd2ca9ae9c69.png" title="a_1" style="vertical-align:-20%;" class="tex" alt="a_1" /> <img src="http://nklein.com/wp-content/plugins/easy-latex/cache/tex_9ff693167d454c907a6c4430d1af2afe.png" title="a_2" style="vertical-align:-20%;" class="tex" alt="a_2" /> <img src="http://nklein.com/wp-content/plugins/easy-latex/cache/tex_3ff077cf8331764ea4d093cf9a57f8a2.png" title="a_3" style="vertical-align:-20%;" class="tex" alt="a_3" />) #(<img src="http://nklein.com/wp-content/plugins/easy-latex/cache/tex_a1880757779020fa878faeb76bb0eb22.png" title="a_{1,2}" style="vertical-align:-20%;" class="tex" alt="a_{1,2}" /> <img src="http://nklein.com/wp-content/plugins/easy-latex/cache/tex_e8c5851192864ac75ecb00a7476ab90f.png" title="a_{1,3}" style="vertical-align:-20%;" class="tex" alt="a_{1,3}" /> <img src="http://nklein.com/wp-content/plugins/easy-latex/cache/tex_31175b4dff3c30ce0aa0dc8910165ccd.png" title="a_{2,3}" style="vertical-align:-20%;" class="tex" alt="a_{2,3}" />) <img src="http://nklein.com/wp-content/plugins/easy-latex/cache/tex_00f3e4fbf4438505c2b0482604c180a1.png" title="a_{1,2,3}" style="vertical-align:-20%;" class="tex" alt="a_{1,2,3}" />)</center></p>
<p>If you want a simple element though (where most of the coefficients are zero), you shouldn&#8217;t have to stare down all of that stuff or remember that <img src="http://nklein.com/wp-content/plugins/easy-latex/cache/tex_e8c5851192864ac75ecb00a7476ab90f.png" title="a_{1,3}" style="vertical-align:-20%;" class="tex" alt="a_{1,3}" /> comes before <img src="http://nklein.com/wp-content/plugins/easy-latex/cache/tex_31175b4dff3c30ce0aa0dc8910165ccd.png" title="a_{2,3}" style="vertical-align:-20%;" class="tex" alt="a_{2,3}" />.  I want you to be able to make <img src="http://nklein.com/wp-content/plugins/easy-latex/cache/tex_f5e1d7d8031d0112ab5f6f87544e3b69.png" title="3 + 4 e_1 + 5 e_{1,2,3}" style="vertical-align:-20%;" class="tex" alt="3 + 4 e_1 + 5 e_{1,2,3}" /> more simply.  Something like one of the following:</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span>defvar *a* <span style="color: #66cc66;">&#40;</span>ca-element '<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">3</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">4</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">5</span> <span style="color: #cc66cc;">1</span> <span style="color: #cc66cc;">2</span> <span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">:</span><span style="color: #555;">p</span> <span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#40;</span>defvar *a* <span style="color: #66cc66;">&#40;</span>ca-element '<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">3</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">4</span> <span style="color: #66cc66;">.</span> <span style="color: #66cc66;">:</span><span style="color: #555;">e1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">5</span> <span style="color: #66cc66;">.</span> <span style="color: #66cc66;">:</span><span style="color: #555;">e1-</span><span style="color: #cc66cc;">2</span>-<span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">:</span><span style="color: #555;">p</span> <span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#40;</span>defvar *a* <span style="color: #66cc66;">&#40;</span>ca-element <span style="color: #66cc66;">:</span><span style="color: #555;">s</span> <span style="color: #cc66cc;">3</span> <span style="color: #66cc66;">:</span><span style="color: #555;">e1</span> <span style="color: #cc66cc;">4</span> <span style="color: #66cc66;">:</span><span style="color: #555;">e1-</span><span style="color: #cc66cc;">2</span>-<span style="color: #cc66cc;">3</span> <span style="color: #cc66cc;">5</span> <span style="color: #66cc66;">:</span><span style="color: #555;">p</span> <span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></div></div>
<p>Similarly, I will define something akin to <strong>(aref &#8230;)</strong> so that one can check or change <img src="http://nklein.com/wp-content/plugins/easy-latex/cache/tex_a1880757779020fa878faeb76bb0eb22.png" title="a_{1,2}" style="vertical-align:-20%;" class="tex" alt="a_{1,2}" /> like one of the following:</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span>caref *a* <span style="color: #cc66cc;">1</span> <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#40;</span>caref *a* <span style="color: #66cc66;">:</span><span style="color: #555;">e1-</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span></div></div>
<p>By analogy with the complex numbers, I should instead have:</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span>e1-<span style="color: #cc66cc;">2</span> *a*<span style="color: #66cc66;">&#41;</span></div></div>
<p>But, that just doesn&#8217;t scale very well.</p>
<p>I am leaning toward using a list of numbers to tell which <img src="http://nklein.com/wp-content/plugins/easy-latex/cache/tex_08c6fa8efe4c47cbbdfb20cbc36006e3.png" title="a_*" style="vertical-align:-20%;" class="tex" alt="a_*" /> is being referenced.  This would allow greater flexibility in other functions.  But, it&#8217;s also less mathy.</p>
<p>Does anyone have any suggestions?  Should I really be supporting both?  Through the same function names or through <strong>(caref &#8230;)</strong> and <strong>(caref* &#8230;)</strong> or something?</p>
]]></content:encoded>
			<wfw:commentRss>http://nklein.com/2009/05/lisp-patterns-question-wrt-clifford-algebras/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Finding Better Polynomials</title>
		<link>http://nklein.com/2009/05/finding-better-polynomials/</link>
		<comments>http://nklein.com/2009/05/finding-better-polynomials/#comments</comments>
		<pubDate>Tue, 12 May 2009 18:03:56 +0000</pubDate>
		<dc:creator>pat</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Math]]></category>
		<category><![CDATA[domain-specific languages]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[polynomials]]></category>

		<guid isPermaLink="false">http://nklein.com/?p=354</guid>
		<description><![CDATA[Some time ago, I wrote a small domain-specific language for finding polynomials given their value or the value of their derivatives at particular points.
It occurred to me shortly after writing that code that I could easily extend it to include the value of its integral over a certain range.  I didn&#8217;t get to tackling [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago, I wrote a small domain-specific language for <a href="http://nklein.com/2009/04/find-the-polynomial-youve-been-looking-for/">finding polynomials</a> given their value or the value of their derivatives at particular points.</p>
<p>It occurred to me shortly after writing that code that I could easily extend it to include the value of its integral over a certain range.  I didn&#8217;t get to tackling that right away, and that was a Good Thing.  In the intervening time, it occurred to me that I could extend it to <a href="http://en.wikipedia.org/wiki/Moment_(mathematics)">moments</a> as well.</p>
<p>So, are you looking for a polynomial that is zero at both zero and one, has a derivative of zero at one, has a second derivative of negative one at one, whose integral from zero to one is one, and whose mean (first moment centered at zero) on the interval zero to one is one fourth?</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span>polynomial-to-string<br />
&nbsp; <span style="color: #66cc66;">&#40;</span>calculate-polynomial-subject-to<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">value</span> <span style="color: #66cc66;">:</span><span style="color: #555;">at</span> <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">:</span><span style="color: #555;">equals</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">value</span> <span style="color: #66cc66;">:</span><span style="color: #555;">at</span> <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">:</span><span style="color: #555;">equals</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span>derivative <span style="color: #66cc66;">:</span><span style="color: #555;">at</span> <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">:</span><span style="color: #555;">equals</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span>nth-derivative <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">:</span><span style="color: #555;">at</span> <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">:</span><span style="color: #555;">equals</span> -<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span>integral <span style="color: #66cc66;">:</span><span style="color: #555;">from</span> <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">:</span><span style="color: #555;">to</span> <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">:</span><span style="color: #555;">equals</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span>mean <span style="color: #66cc66;">:</span><span style="color: #555;">from</span> <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">:</span><span style="color: #555;">to</span> <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">:</span><span style="color: #555;">equals</span> <span style="color: #cc66cc;">1</span>/<span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></div></div>
<p>Well, that would be <img src="http://nklein.com/wp-content/plugins/easy-latex/cache/tex_c0126f8e80cc81bd9fe1d70b37272a64.png" title="f(x) = \frac{149}{4}x - 163x^2 + 265x^3 - 190x^4 + \frac{203}{4}x^5" style="vertical-align:-20%;" class="tex" alt="f(x) = \frac{149}{4}x - 163x^2 + 265x^3 - 190x^4 + \frac{203}{4}x^5" />.  (For some reason though, gnuplot thinks <img src="http://nklein.com/wp-content/plugins/easy-latex/cache/tex_3a0a2f2a9686309735f2f0213c2faef3.png" title="f(x) = -1" style="vertical-align:-20%;" class="tex" alt="f(x) = -1" />, so no graph for you&#8230;)</p>
<p>Here is the <a href='http://nklein.com/wp-content/uploads/2009/05/polynomials.lisp'>source file</a>.</p>
<p><a href="http://nklein.com/wp-content/uploads/2009/05/graph.png"><img src="http://nklein.com/wp-content/uploads/2009/05/graph-300x225.png" alt="graph" title="graph" width="300" height="225" class="alignright size-medium wp-image-363" /></a><br />
<strong>Edit:</strong> I realized that gnuplot was off by one because it was truncating the fractions.  So, I just changed the 4&#8217;s in the denominators to 4.0&#8217;s and Bob&#8217;s your uncle.</p>
<p class="clear">&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://nklein.com/2009/05/finding-better-polynomials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find the Polynomial You&#8217;ve Been Looking For</title>
		<link>http://nklein.com/2009/04/find-the-polynomial-youve-been-looking-for/</link>
		<comments>http://nklein.com/2009/04/find-the-polynomial-youve-been-looking-for/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 23:09:00 +0000</pubDate>
		<dc:creator>pat</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Math]]></category>
		<category><![CDATA[domain-specific languages]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[polynomials]]></category>

		<guid isPermaLink="false">http://nklein.com/?p=116</guid>
		<description><![CDATA[So, very often for things that I'm toying with, I want to have a polynomial that meets certain criteria.  For most applications in the past, I have sat down and figured it all out by hand.

Often, I want to have a polynomial that meets certain criteria.  For most applications in the past, I figured it all out by hand.

Today, I was having trouble getting the conditions specified enough to get the sort of polynomial that I was expecting.  After finding the coefficients for several sixth degree polynomials in a row, I figured I should instead be able to do something like this with the proper lisp:]]></description>
			<content:encoded><![CDATA[<p>Often, I want to have a polynomial that meets certain criteria.  For most applications in the past, I figured it all out by hand.</p>
<p>Today, I was having trouble getting the conditions specified enough to get the sort of polynomial that I was expecting.  After finding the coefficients for several sixth degree polynomials in a row, I figured I should instead be able to do something like this with the proper lisp:</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span>calculate-polynomial-subject-to<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">value</span> <span style="color: #66cc66;">:</span><span style="color: #555;">at</span> <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">:</span><span style="color: #555;">equals</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span>derivative <span style="color: #66cc66;">:</span><span style="color: #555;">at</span> <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">:</span><span style="color: #555;">equals</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span>nth-derivative <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">:</span><span style="color: #555;">at</span> <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">:</span><span style="color: #555;">equals</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">value</span> <span style="color: #66cc66;">:</span><span style="color: #555;">at</span> <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">:</span><span style="color: #555;">equals</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span>derivative <span style="color: #66cc66;">:</span><span style="color: #555;">at</span> <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">:</span><span style="color: #555;">equals</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span>nth-derivative <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">:</span><span style="color: #555;">at</span> <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">:</span><span style="color: #555;">equals</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">value</span> <span style="color: #66cc66;">:</span><span style="color: #555;">at</span> <span style="color: #cc66cc;">1</span>/<span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">:</span><span style="color: #555;">equals</span> <span style="color: #cc66cc;">3</span>/<span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></div></div>
<p>That&#8217;s all done now (<a href='http://nklein.com/2009/04/find-the-polynomial-youve-been-looking-for/polynomials/' rel='attachment wp-att-149'>polynomials.lisp</a>).  So, for the record, the above is:  <img src="http://nklein.com/wp-content/plugins/easy-latex/cache/tex_c08fc815e4f86686ef2843efd6ca32ae.png" title="26x^3 - 63x^4 + 54x^5 - 16x^6" style="vertical-align:-20%;" class="tex" alt="26x^3 - 63x^4 + 54x^5 - 16x^6" />.  That is still not quite the polynomial I want for this application, but it&#8217;s close.  A few minutes of Lisp saved me hours of whiteboard work.</p>
]]></content:encoded>
			<wfw:commentRss>http://nklein.com/2009/04/find-the-polynomial-youve-been-looking-for/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
