<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:iweb="http://www.apple.com/iweb" version="2.0">
  <channel>
    <title></title>
    <link>http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/SwimLanes.html</link>
    <description>Topics:&lt;br/&gt;    Mathematics&lt;br/&gt;    Computer Security &lt;br/&gt;    Cryptography&lt;br/&gt;    Software (esp. Mathematica)</description>
    <generator>iWeb 3.0</generator>
    <item>
      <title>SU vs TERMINAL</title>
      <link>http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2008/8/3_SU_vs_TERMINAL.html</link>
      <guid isPermaLink="false">d36267d5-5a05-45eb-aa2a-42a631912a10</guid>
      <pubDate>Sun, 3 Aug 2008 21:34:55 -0600</pubDate>
      <description>&lt;a href=&quot;http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2008/8/3_SU_vs_TERMINAL_files/images3Fq3Dtransformer2Boptimus2Bprime26um3D126hl3Den26client3Dsafari26rls3Den-us26sa3DG_1.jpg&quot;&gt;&lt;img src=&quot;http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Media/object038.jpg&quot; style=&quot;float:left; padding-right:10px; padding-bottom:10px; width:236px; height:274px;&quot;/&gt;&lt;/a&gt;&lt;br/&gt;There are questions raised on the Internet that never get a straight answer. One of them is: &amp;quot;How can I get around this error? : su: must be run from a terminal.”  This question triggers 2500 hits in Google and I’ve yet to find one straight answer. The question is an orphan.&lt;br/&gt;&lt;br/&gt;Now to be fair, those that shun it do so for good reasons: there are serious security concerns when su is called from a non-terminal, like from a file or pipe. When the input isn’t a tty, then the root password persists outside the security environment of the root login. The su programmers are trying hard to discourage this, but as I’ll argue later, there are good reasons to allow su from non-terminals.&lt;br/&gt;&lt;br/&gt;Speaking of terminals, some implementations of su complain differently:  “su: standard in must be a tty”. In either case the point is the same. &lt;br/&gt;&lt;br/&gt;&lt;a href=&quot;http://www.google.com/&quot;&gt;Here&lt;/a&gt; is what I mean by being an orphan question. Notice how all the responses avoid giving a direct answer? Its certainly not because a direct answer doesn’t exist. My criteria for being an orphan question is “does Experts-Exchange.com offer to answer it for $.” If they do, you can be sure there is a lot of confusion amongst the free postings. In this case the answer is yes (on Experts-Exchange.com) and the confusion resides there as well since the right answer isn’t there either.&lt;br/&gt;&lt;br/&gt;	•	&lt;a href=&quot;http://forums.fedoraforum.org/showthread.php?t=178464&quot;&gt;http://forums.fedoraforum.org/showthread.php?t=178464&lt;/a&gt;&lt;br/&gt;	•	&lt;a href=&quot;http://www.experts-exchange.com/Programming/Languages/CPP/Q_21104620.html&quot;&gt;http://www.experts-exchange.com/Programming/Languages/CPP/Q_21104620.html&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;Now in the case of su vs terminal, there are five typical non-answers. Here is they are:&lt;br/&gt;&lt;br/&gt;I have made a script with the su command:     echo -ne &amp;quot;password\n&amp;quot;|su - root  But it complains:     su : must be run from a terminal  Help!&lt;br/&gt;Reply1&gt; Works for me - OSX user&lt;br/&gt;Reply2&gt; I have the same problem - redhat, debian, vmware esx user&lt;br/&gt;Reply3&gt; Using su from a script is unsafe, use sudo&lt;br/&gt;Reply4&gt; Using su from a script is unsafe, use cron&lt;br/&gt;Reply5&gt; Using su from a script is unsafe, use a setuid program&lt;br/&gt;&lt;br/&gt;First, I have to scope the problem. I'm going to answer a common variation:&lt;br/&gt;. &amp;quot;I want to manage a machine using an ssh script, but I can't because it needs to be root and 'su: must be run from a terminal&amp;quot;&lt;br/&gt;&lt;br/&gt;This appears often because, as a best practice, direct login using ssh is disabled for root. This is even a Vmware guideline.&lt;br/&gt;. The usual solution for an interactive user is to login using ssh to account fred, then su -.&lt;br/&gt;. But if you try this from a script, say on Debian, it won't work:  echo password |  ssh -l fred 'su -'&lt;br/&gt;&lt;br/&gt;So inevitable the poor soul will post a question to some forum and get one of these run-around answers:&lt;br/&gt;. Works for me - OSX user&lt;br/&gt;. I have the same problem - Debian, Redhat, Solaris, HP/UX&lt;br/&gt;. Don't do that, its unsafe. Use sudo!&lt;br/&gt;. Don't do that, its unsafe. Use cron.&lt;br/&gt;. Don't do that, its unsafe. Use a setuid program.&lt;br/&gt;&lt;br/&gt;The first two answers show the inconsistency of su between *nix implementations. Usually a machine running a packaging of Linux will generate the su error. Not all other Unix variations will. OSX will accept the su just fine over a terminal.&lt;br/&gt;. XXX I need to try Solaris&lt;br/&gt;. XXX AIX&lt;br/&gt;. XXX HP/UX&lt;br/&gt;&lt;br/&gt;So, what exactly is the problem?&lt;br/&gt;. The problem is that Linux su is performing a safety check that the root password is originating from a user instead of a script.&lt;br/&gt;. If a script were accepted, that means the root password is persistently stored in a lower security ring than root, which is a problem.&lt;br/&gt;&lt;br/&gt;How about those solutions?&lt;br/&gt;. Obviously the first two aren't helping; we can't all be running OSX.&lt;br/&gt;. The next two answers are textbook. Unfortunately, they don't really solve the problem the user is having. Oh yes, they do solve the problem of loggin in using ssh and su'ing on an a _recurring_ basis, but the user here is often trying to set the configuration. Sometimes the user is setting the configuration of sudo itself. Obviously depending on an existing sudo config to create the sudo config is circular. This is why this question shows up in Experts Exchange.&lt;br/&gt;. Actually, the final answer, use a setuid program highlights the situation nicely. How did the setuid program get there and get configured in the first place? Recall that sudo and cron are setuid programs that require configuration.&lt;br/&gt;&lt;br/&gt;So all the solutions are wanting. Now what?&lt;br/&gt;. Well, I'm not going to make you wait any longer:&lt;br/&gt;echo password | ssh -t -t -l username 'su -'&lt;br/&gt;. If that's all you wanted to know, you can skip my explanation that follows.&lt;br/&gt;&lt;br/&gt;To understand why this works, I need to explain something about ssh. &lt;br/&gt;. Ssh is a client program that connects to a server program called sshd on *nix. &lt;br/&gt;. When you ssh to a remote host, ssh runs on your client and sshd runs on the remote - the host to which you are shelling.&lt;br/&gt;. Invoking ssh -c 'su -' results in ssh running on your client, sshd on the remote, and su as a subprocess of sshd.&lt;br/&gt;. The ssh reads characters from its standard input, send them to sshd through an encrypted tunnel, and sshd forwards them to su through a pipe.&lt;br/&gt;. Of course, what su is reading is a password and some commands.&lt;br/&gt;&lt;br/&gt;Try these examples:&lt;br/&gt;	echo password | ssh -t -t -l username 'ps'&lt;br/&gt;. Here you can see that in addition to ps running, sshd is also and is the parent of ps.&lt;br/&gt;&lt;br/&gt;Now the pipe from sshd to whatever command is running remotely is not a terminal. You can test this using the tty program. &lt;br/&gt;. Try running tty at your local host. It should return something like this:&lt;br/&gt;&lt;br/&gt;. Now try this:&lt;br/&gt;	echo password | ssh -c tty&lt;br/&gt;	echo password | ssh -t -c tty&lt;br/&gt;	echo password | ssh -t -t -c tty&lt;br/&gt;. Here the tty was run at the remote. Here you can see that in the first two cases tty was able to detect that the pipe was not a terminal.&lt;br/&gt;. But look at the third case, the double -t fooled sshd. What is going on?&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;Figure 1 ..&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;Ssh commands (using -t) the remote sshd to establish a 'pseudo-terminal' pipe to the worker process when -t is given.&lt;br/&gt;. ssh does this as long as its stdin is a terminal.&lt;br/&gt;. But if ssh's stdin is a non-terminal, ssh won't direct sshd to establish a pseudo-terminal unless TWO -t's are given:&lt;br/&gt;	echo password | ssh -t -t -l username remote_host&lt;br/&gt;. So with -t -t (from ssh) sshd sets up a pseudo-terminal to the client process.&lt;br/&gt;. The client, whether it be 'tty' or 'su' cannot tell it is connected to a ficticious terminal:&lt;br/&gt;	echo dummystr | ssh -t -t -l username host.com -c ''tty'&lt;br/&gt;	echo password | ssh -t -t -l username host.com -c 'su -'&lt;br/&gt;&lt;br/&gt;So there is the answer. Use double -t if you are 'su root'ing' on a linux box through an interactive client ssh like the one from OpenBSD.&lt;br/&gt;One more time, here are some examples:&lt;br/&gt;. echo password | ssh -t -t -l username -c 'su -'&lt;br/&gt;. echo password | ssh -t -t -l username -c 'su - \; id'&lt;br/&gt;. (echo password, cat file.sh) | ssh -t -t -l username &lt;br/&gt;&lt;br/&gt;&lt;br/&gt;And hopefully that answers one question that was sorely needing a direct answer.&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;</description>
      <enclosure url="http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2008/8/3_SU_vs_TERMINAL_files/images3Fq3Dtransformer2Boptimus2Bprime26um3D126hl3Den26client3Dsafari26rls3Den-us26sa3DG_1.jpg" length="8421" type="image/jpeg"/>
    </item>
    <item>
      <title>Correlation Graphs</title>
      <link>http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/12/27_Correlation_Graphs.html</link>
      <guid isPermaLink="false">c0298ba0-98b2-4805-9bf2-4696a231d58b</guid>
      <pubDate>Thu, 27 Dec 2007 22:05:13 -0700</pubDate>
      <description>&lt;a href=&quot;http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/12/27_Correlation_Graphs_files/droppedImage_1.jpg&quot;&gt;&lt;img src=&quot;http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Media/object039.jpg&quot; style=&quot;float:left; padding-right:10px; padding-bottom:10px; width:248px; height:244px;&quot;/&gt;&lt;/a&gt;Download &lt;a href=&quot;Entries/2007/12/27_Correlation_Graphs_files/CorrelationGraph.nb&quot;&gt;CorrelationGraph.nb&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;In a previous posting titled &lt;a href=&quot;Entries/2007/10/20_Visual_Solution_Contours.html&quot;&gt;Visual Solution Search&lt;/a&gt;, I described how to use domain coloring to scan for a solution to a system of equations or formulas. Essential to that technique was the coloring of the domain of a multidimensional function as a two dimensional plane. Since the goal was to discern solutions, the coloring worked by finding the best value of all the N dimensional points sharing each 2-D component and coloring the 2-D point the respective color. Here best means the value closest to the solution using an arbitrary metric.&lt;br/&gt;&lt;br/&gt;But into which two dimensions should the domain be projected?&lt;br/&gt;&lt;br/&gt;Into all of them. &lt;br/&gt;&lt;br/&gt;A correlation graph is a graphical device that places every possible 2-D view of a multidimensional object side-by-side organized in a matrix. In fact, another name for a correlation graph is a correlation matrix.&lt;br/&gt;&lt;br/&gt;Given a domain (x,y,z,t) there is one row and one column labelled each of x,y,z,t. At position (y,t) for example, appears the domain coloring of the multidimensional function projected into the (y,t)-plane. For a ten variable function, the matrix will be a 10 x 10 grid. The graphs on the diagonal is always empty as there is no point in plotting any variable y against itself.&lt;br/&gt;&lt;br/&gt;We can use a correlation graph to visually search for system solutions. Take the system’s domain as the multidimensional object. The set of all 2-D projections comprise the views.&lt;br/&gt;&lt;br/&gt;For example, reconsider this 4-D system:&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;</description>
      <enclosure url="http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/12/27_Correlation_Graphs_files/droppedImage_1.jpg" length="45005" type="image/jpeg"/>
    </item>
    <item>
      <title>Glimpsing Hammurabi’s Code (When Programs phone home)&#13;</title>
      <link>http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/11/28_Glimpsing_HammUrabi%E2%80%99s_Code_%28When_Programs_phone_home%29.html</link>
      <guid isPermaLink="false">19f1085e-54a2-4773-a508-bf5c379aa4b1</guid>
      <pubDate>Wed, 28 Nov 2007 06:53:19 -0700</pubDate>
      <description>&lt;a href=&quot;http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/11/28_Glimpsing_HammUrabi%E2%80%99s_Code_%28When_Programs_phone_home%29_files/droppedImage.jpg&quot;&gt;&lt;img src=&quot;http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Media/object040.jpg&quot; style=&quot;float:left; padding-right:10px; padding-bottom:10px; width:181px; height:282px;&quot;/&gt;&lt;/a&gt;By now, many of us are aware that our programs are sending unauthorized information back to the software manufacturer via the Internet. What is surprising is how pervasive this problem is becoming and how even legitimate software manufacturers are collecting personal information that they are neither validating, authenticating, or protecting against theft into perpetuity.&lt;br/&gt;&lt;br/&gt;What exactly are programs saying when they phone home? Here is one way to find out if you use Mac OS X. You will need a free tool called Little Snitch along with a quick command line that invokes tcpdump. &lt;br/&gt;&lt;br/&gt;Little Snitch is an Mac OS X program that tattles every time a program attempts a covert network connection. Snitch blocks the connection and gives you the opportunity to approve or disapprove the process. You can see which program is phoning ‘home’ and where it is calling. Unfortunately, Little Snitch doesn’t show you what the program is trying to say. For that you will need tcpdump.&lt;br/&gt;&lt;br/&gt;While Little Snitch is waiting for you to approve the covert network connection, the subject program is waiting and unaware that the delay is being caused by Little Snitch asking for your approval verses vanilla network latency. This time gives you the opportunity to take some action: start a tcpdump.&lt;br/&gt;&lt;br/&gt;Tcpdump is a command line program that prints network packets. It has options for filtering packets by source and destination, as well as providing hex and ASCII dumps, and other options. When Little Snitch suspends a program, it gives you just enough information to target an instance of tcpdump against the particular network connection.&lt;br/&gt;&lt;br/&gt;Here is an example tcpdump command you can use:&lt;br/&gt;&lt;br/&gt;   sudo tcpdump -s 1024 -i en1 -t -X port 80&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;I’m going to leave it to you to read the tcpdump man page to explain the command line switches. The point is that you invoke tcpdump after the Little Snitch warning, but before you ‘Allow’ the network connection. Use the ‘port’ in the Little Snitch warning dialog to filter the tcpdump as done above - you can also filter by the host.&lt;br/&gt;&lt;br/&gt;Now for an example of what you will see. This was captured from the network while I was reading some Mathematica documentation. The packet was sending my IP address, license, and mathid to Wolfram.com (Mathematica’s vendor) as well as what I was reading and a bonus timestamp. (I have anonimized these identifiers in the dump below). Take note that I wasn’t asking for any service from Wolfram.com and all this was happening quietly in the background. &lt;br/&gt;&lt;br/&gt;Worse, there is no way for Wolfram to authenticate or validate this information. Anyone can be submitting these requests using my license. &lt;br/&gt;&lt;br/&gt;These datagrams have probably been taking place for some time and by now Wolfram is aware that I’m a closet Homeomorphologist.&lt;br/&gt;&lt;br/&gt;$ sudo tcpdump -s 1024 -t -X -i en1&lt;br/&gt;&lt;br/&gt;IP 123.45.67.890.23456 &gt; search.wolfram.com.http: P 1:193(192) ack 1 win 12345 &amp;lt;nop,nop,timestamp 91234567 123456789&gt;&lt;br/&gt;...&lt;br/&gt;	0x0030:  0ba6 aec9 4745 5420 2f6c 7563 656e 652f  ....GET./lucene/&lt;br/&gt;	0x0040:  6e75 6d62 6572 6f66 6869 7473 2e6a 7370  numberofhits.jsp&lt;br/&gt;	0x0050:  3f71 7565 7279 3d48 6f6d 656f 6d6f 7068  ?query=Homeomorp&lt;br/&gt;	0x0060:  6f6c 6f67 7974 2663 6f6c 6c65 6374 696f  hology&amp;amp;collectio&lt;br/&gt;	0x0070:  6e3d 7472 796f 6e61 6c6c 266d 6174 6869  n=tryonall&amp;amp;mathi&lt;br/&gt;	0x0080:  643d 3131 3131 2d32 3232 3232 2d33 3333  d=1111-22222-333&lt;br/&gt;	0x0090:  3434 266c 6963 656e 7365 3d4c 3131 3131  44&amp;amp;license=L1111&lt;br/&gt;	0x00a0:  2d32 3232 3220 4854 5450 2f31 2e31 0d0a  -2222.HTTP/1.1..&lt;br/&gt;	0x00b0:  5573 6572 2d61 6765 6e74 3a20 4d61 7468  User-agent:.Math&lt;br/&gt;	0x00c0:  656d 6174 6963 612f 362e 302e 3120 504d  ematica/6.0.1.PM&lt;br/&gt;	0x00d0:  2f31 2e30 2e32 0d0a 486f 7374 3a20 7365  /1.0.2..Host:.se&lt;br/&gt;	0x00e0:  6172 6368 2e77 6f6c 6672 616d 2e63 6f6d  arch.wolfram.com&lt;br/&gt;	0x00f0:  0d0a 0d0a                                ....&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;Greg Frascadore @ Serranos, Monument CO, Nov 2007. Updated Dec 2007.&lt;br/&gt;&lt;br/&gt;</description>
      <enclosure url="http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/11/28_Glimpsing_HammUrabi%E2%80%99s_Code_%28When_Programs_phone_home%29_files/droppedImage.jpg" length="103285" type="image/jpeg"/>
    </item>
    <item>
      <title>Visual Solution Search</title>
      <link>http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/10/20_Visual_Solution_Contours.html</link>
      <guid isPermaLink="false">bb96c94c-ef46-4b95-9efa-ca53e7fafd61</guid>
      <pubDate>Sat, 20 Oct 2007 20:15:27 -0600</pubDate>
      <description>&lt;a href=&quot;http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/10/20_Visual_Solution_Contours_files/droppedImage_1.jpg&quot;&gt;&lt;img src=&quot;http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Media/object041.jpg&quot; style=&quot;float:left; padding-right:10px; padding-bottom:10px; width:248px; height:249px;&quot;/&gt;&lt;/a&gt;Download &lt;a href=&quot;Entries/2007/10/20_Visual_Solution_Contours_files/NetMethod.nb&quot;&gt;NetMethod.nb&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;Solving a system of equations is a common problem in game-theory and many other domains that use mathematical models. Computer mathematics systems like Maple and Mathematica can easily digest cryptic arrays of equations and put forth solutions or warnings of un-solvability, but I want to tell you about a visual way to detect a system solution.&lt;br/&gt;&lt;br/&gt;What motivated me to write about this was solving a problem in game theory after remembering a description of how World War II British cryptographers searched for keys to the German Enigma cipher visually. The British used perforated Zygalski sheets. Briefly, the method superimposed a stack of sheets, each containing a set of holes aligned on a grid, and overlaid the sheets while shining a light behind the stack. This eliminates a large number of non-solutions and flags a solution when light can shine through an aligned aperture in every sheet.&lt;br/&gt;&lt;br/&gt;This technique is called the Net Method. You can read more about Zygalski sheets and the Net Method at:&lt;br/&gt;&lt;br/&gt;&lt;a href=&quot;http://www.google.com/search?q=site:wikipedia.org+zygalski+perforated&quot;&gt;http://www.google.com/search?q=site:wikipedia.org+zygalski+perforated&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;My variation of the technique has a bias towards Mathematica, but it should be obvious how to apply the technique using Maple or other systems for doing mathematics by computer. I don’t consider it an anachronism to use a computer to enhance a technique developed prior to the Age of Information.&lt;br/&gt;&lt;br/&gt;Background&lt;br/&gt;&lt;br/&gt;A system of equations is a set of equations that share variables. A solution is a set of variable values that satisfy all the equations simultaneously. For this reason, a system of equations is sometimes called a set of simultaneous equations. Here is an a small homework example, we’ll solve some realistic ones shortly:&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;The general rule is that if we have N such equations in N unknown variables, then we can solve the system using substitution or matrix algebra - if the equations are linear and linearly independent. This is the old N equations in N unknowns rule.&lt;br/&gt;&lt;br/&gt;Of course, real-life systems are often not so pretty. They may be quadratic instead of linear; there might be linearly dependent equations in the mix; the system might be over-determined; the system might be be an inequality instead of an equation. All of these difficulties are well-treated in the mathematics literature and I can’t improve upon them here. Instead, lets work on an oft-overlooked difficulty: solving simultaneous systems is boring, tedious, error-prone, work.&lt;br/&gt;&lt;br/&gt;Contour Plotting&lt;br/&gt;&lt;br/&gt;During World War II, British cryptographers at Bletchley Park were searching for keys to German Enigma-encoded messages. At its core, the problem was also a simultaneous system. It was also very big, tedious, full of noisy data, error-prone, and boring. The technique the British used to overcome these hurdles was invented by a Polish cryptographer Henryk Zygalski. The idea has general application.&lt;br/&gt;&lt;br/&gt;The idea is this, create a domain map of each equation in a system of equations. Overlay the maps in a way that visually highlights a simultaneous solution.&lt;br/&gt;&lt;br/&gt;To apply this technique, we define a metric that measures a result’s closeness to the solution, and assign colors to distances. The Bletchley Park ‘colors’ were simply transparent at a solution and black otherwise, however lets use a spectrum where solutions are colored black and brighter colors indicate distance - in other words a contour map where sea-level is our goal.&lt;br/&gt;&lt;br/&gt;Now we interpret the domain values as coordinates of a point in a plane (or hyperplane if there are more than 2 domain variables), and color the domain point corresponding to the result’s distance from the solution. If a point in the domain maps to a solution, we color the point black. If it maps to a non-solution, we use the spectrum color proportional to the distance from the solution. In a system having two equations and two unknowns, there will be two 2-dimensional maps: one map per equation, one dimension per unknown. Here again is our homework example and its two maps:&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;Now a key step: we overlay the maps and use the maximum (lighter) color wherever different colors overlap. This means black occurs in the overlay only in the vicinity of a solution. The overlay of the above two maps produces this bat-like image:&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;Higher Dimensions&lt;br/&gt;There is another detail that needs explaining: what happens if the system has more than two variables? Such a system’s domain cannot immediately be drawn as a two dimensional map.&lt;br/&gt;&lt;br/&gt;The answer is to realize that since a system’s solution occurs at simultaneous minima, we can flatten any N-dimensional domain into two dimensions by maximizing.&lt;br/&gt;&lt;br/&gt;Realistic Example&lt;br/&gt;Here is an real application. Suppose we are seeking the solution of the following system of four equations in four unknowns. This problem was posted to USENET &lt;a href=&quot;http://tolstoy.newcastle.edu.au/R/help/04/11/7134.html&quot;&gt;(from http://tolstoy.newcastle.edu.au/R/help/04/11/7134.html): &lt;/a&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;So we proceed as follows:&lt;br/&gt;- Assign colors to the measures that vary from black as the values stray further from solution&lt;br/&gt;- Flatten each domain into a plane by picking the maximum result from all those that project into the same plane point&lt;br/&gt;- Overlay the domain planes by picking the minimum color from all those that project into the same final-plane point&lt;br/&gt;	-	Color the resulting plane as a contour map to visualize the vicinity of solutions&lt;br/&gt;&lt;br/&gt;Here is the result of flatting the four dimensional domain (λ, σ, δ, τ) into the plane (λ, σ) and then overlaying the four planes:&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;Here are two examples. The first is contrived to demonstrate several concepts. The second is an actual equation in game-theory.&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;Contrived Example&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;Suppose we wish to find solutions to this in the domain x: [0..1], y:(0..16], z:[0..32], t:[-4..4]. The resulting 2D contour plot is:&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;Conclusion&lt;br/&gt;&lt;br/&gt;We can discern the solution to a system of equations or inequalities before solving for the solution. Although the technique works by displaying 2-dimensional contour plots, it works even with systems having an unlimited number of independent variables (dimensions). It even works with non-square systems that are possibly over- or under-determined. &lt;br/&gt;&lt;br/&gt;The idea is to assign a visual marker (like a color) to solutions within the system’s large domain, and then reduce or flatten the domain while retaining the markers. If any solution marks appear anywhere in the result, the system is solvable.&lt;br/&gt;&lt;br/&gt;Techniques like this one, that paint domains and track colors through to solutions, were successfully used in World War II to decrypt Nazi messages, and that was the inspiration for this entry.&lt;br/&gt;&lt;br/&gt;Greg Frascadore, Serranos, August 2006. Updated Dec 2007.&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;</description>
      <enclosure url="http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/10/20_Visual_Solution_Contours_files/droppedImage_1.jpg" length="58299" type="image/jpeg"/>
    </item>
    <item>
      <title>Preimages: A Domain Coloring Intermezzo</title>
      <link>http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/10/20_Preimages%3A_A_Domain_Coloring_Intermezzo.html</link>
      <guid isPermaLink="false">4c56ddc8-68c5-4f24-8bec-364e7653f4b6</guid>
      <pubDate>Sat, 20 Oct 2007 11:53:45 -0600</pubDate>
      <description>&lt;a href=&quot;http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/10/20_Preimages%3A_A_Domain_Coloring_Intermezzo_files/droppedImage_5.jpg&quot;&gt;&lt;img src=&quot;http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Media/object042.jpg&quot; style=&quot;float:left; padding-right:10px; padding-bottom:10px; width:341px; height:179px;&quot;/&gt;&lt;/a&gt;Before proceeding with the domain coloring project, we need a way of painting a function’s range with an image in Mathematica. This will allow us to place a grid or other scale into the range and examine its appearance when viewed through the lens of the function.&lt;br/&gt;&lt;br/&gt;Generating a grid and saving it to a file as an image turns out to be pretty easy. Basically we just draw some lines into a grid, generate a Graphics object, and then Export it to a PNG file called “grid.png”. I’m using PNG instead of GIF because the elements of PNG are RGB color values that are compatible with the RGB values of domain coloring.&lt;br/&gt;&lt;br/&gt;&lt;br/&gt; gridGraphics[color_: LightGray] :=   Module[{i},    Graphics[{color, Thick,     Table[Line[{{i,0}, {i,9}}], {i,0,9}],     Table[Line[{{0,i}, {9,i}}], {i,0,9}]   }]]&lt;br/&gt;&lt;br/&gt; gr = gridGraphics[LightGray];  Show[gr, ImageSize -&gt; 100];  Export[&amp;quot;grid.png&amp;quot;, gr, &amp;quot;PNG&amp;quot;] gr = Import[&amp;quot;grid.png&amp;quot;, &amp;quot;PNG&amp;quot;];   gr1 = grColorFunc[gr, 0, 150]  Show@CodedDensity[{#^2 &amp;amp;}, {0, 15}, &lt;br/&gt;  {gr1}, {}, &lt;br/&gt;  {ImageSize -&gt; 200, PlotPoints -&gt; 250}]&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;There are two important concepts here. First, any Graphics object created by Mathematica can be painted onto the range of a function and then viewed through the lens of the function. Second, any image (well, at least any PNG) that can be imported can also be viewed through a function. Both of these concepts are demonstrated in the next two images. Here are views of the grid above, and my favorite 8thman, seen through the function w2 defined in “Domain Coloring II”.&lt;br/&gt;&lt;br/&gt; gr = Import[&amp;quot;grid.png&amp;quot;, &amp;quot;PNG&amp;quot;];   gr1 = grColorFunc[gr, 0, 150]  &lt;br/&gt; Show@CodedDensity[{w2[#] &amp;amp;}, {-1, 4}, &lt;br/&gt;   {gr1}, {}, {ImageSize -&gt; 200,     PlotPoints -&gt; 250}] gr = Import[&amp;quot;8thman.png&amp;quot;, &amp;quot;PNG&amp;quot;];   gr1 = grColorFunc[gr, 0, 150]  &lt;br/&gt; Show@CodedDensity[{w2[#] &amp;amp;}, {-1, 4}, &lt;br/&gt;   {gr1}, {}, {ImageSize -&gt; 200,     PlotPoints -&gt; 250}]&lt;br/&gt;&lt;br/&gt;</description>
      <enclosure url="http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/10/20_Preimages%3A_A_Domain_Coloring_Intermezzo_files/droppedImage_5.jpg" length="30233" type="image/jpeg"/>
    </item>
    <item>
      <title>Sylvester’s Determinant Identity</title>
      <link>http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/10/20_Sylvester%E2%80%99s_Determinant_Identity.html</link>
      <guid isPermaLink="false">5d342820-ad36-4fd9-8b82-3cc89f492018</guid>
      <pubDate>Sat, 20 Oct 2007 11:51:53 -0600</pubDate>
      <description>&lt;a href=&quot;http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/10/20_Sylvester%E2%80%99s_Determinant_Identity_files/droppedImage_3.jpg&quot;&gt;&lt;img src=&quot;http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Media/object043.jpg&quot; style=&quot;float:left; padding-right:10px; padding-bottom:10px; width:248px; height:186px;&quot;/&gt;&lt;/a&gt;Sylvester was a 19th century mathematician and poet, a collaborator of Cayley, DeMorgan, and Chebyshev, he advanced the fields of matrix theory and algebraic equations, and founded the American Journal of Mathematics. In 1851 he published, in his words, “a remarkable theorem” showing the relation between determinants and submatrices. There are at least 7 published proofs of the theorem. However, Sylvester himself stated his identity without proof, and maybe because of that, the equation has historically been regarded as merely a notable curiosity of the Theory of Determinants. In 2005, I accidentally noticed a form of the identity using an elegant sub-matrix notation. On its face, this redux of Sylvester’s discovery bares a striking resemblance to the ε-δ identity studied in Tensors. In the belief that the similarity is not accidental, I set out to prove that Sylvester’s theorem could be developed (one more time) using the methods of Tensors. &lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;</description>
      <enclosure url="http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/10/20_Sylvester%E2%80%99s_Determinant_Identity_files/droppedImage_3.jpg" length="50550" type="image/jpeg"/>
    </item>
    <item>
      <title>Domain Coloring III</title>
      <link>http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/10/20_Domain_Coloring_III.html</link>
      <guid isPermaLink="false">70b934e3-ac85-4532-8f6f-af51534375b4</guid>
      <pubDate>Sat, 20 Oct 2007 11:36:04 -0600</pubDate>
      <description>&lt;a href=&quot;http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/10/20_Domain_Coloring_III_files/droppedImage_8.jpg&quot;&gt;&lt;img src=&quot;http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Media/object044.jpg&quot; style=&quot;float:left; padding-right:10px; padding-bottom:10px; width:218px; height:218px;&quot;/&gt;&lt;/a&gt;Lundmark used eight techniques to paint the range in his domain coloring paper. In this series of posts I’ll try to reproduce his results using Mathematica’s Cardano3 package. &lt;br/&gt;&lt;br/&gt;In part 1, I described Lundmark’s steps for painting the range. In part II I was able to apply the first 5 techniques using Mathematica’s Cardano 3 package and generated some results that were similar, but still inferior to Lundmark’s results. In this final post on domain coloring, I’ll apply the last three techniques:&lt;br/&gt;&lt;br/&gt;	a.	 Shadowing&lt;br/&gt;	b.	A grid or other reference background&lt;br/&gt;	c.	 * High resolution&lt;br/&gt;&lt;br/&gt;Flagged * techniques were not explicitly stated by Lundmark.&lt;br/&gt;&lt;br/&gt;To recap where things are at, compare the following two pair of images. I generated the left-side images using Mathematica’s Cardano3 package while applying techniques a through e. The right-sides are image captures from Lundmark’s paper. Obviously he is still doing things better.&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;                      (a)                                         (b)                                                         (c)                                        (d)&lt;br/&gt;&lt;br/&gt;Technique F: Shadowing&lt;br/&gt;&lt;br/&gt;Upon close inspection of images c and d you can make out an important difference. The color gradient of (d) depends on both angle and magnitude, while the gradient of (c) is varying only with the angle. You can discern this by drawing an imaginary straight line from the center of (d) towards 4’o-clock position and tracking the colors along the line; moving outwards from the center, the colors alternate yellow, red, yellow, red, etc, depending on the distance from the origin. In contrast, the same line in (c) is alternating yellow, grey, yellow, etc. The grey being the intensity of black appropriate for the angle.&lt;br/&gt;&lt;br/&gt;Time for another refinement.&lt;br/&gt;absColorMix[color1_, color2_, z_] :=&lt;br/&gt;  ColorMix[color1, color2][Max[qArg@z, Abs@FractionalPart@Log[2, 1 + Abs@z]]]&lt;br/&gt;&lt;br/&gt;argColorMix[color1_, color2_, z_] :=&lt;br/&gt;  ColorMix[color1, color2][qArg@z]&lt;br/&gt;&lt;br/&gt;zColorMix[color1_, color2_] :=&lt;br/&gt;  Function[argColorMix[color1, absColorMix[color1, color2, #], #]]&lt;br/&gt;&lt;br/&gt;Show@GraphicsArray@(CodedDensity[{#}, {0, 3}, {blackRedYellow}, {}, \&lt;br/&gt;{PlotPoints -&gt; 400}] &amp;amp; /@ {w1, w2})&lt;br/&gt;                    (e)                                         (f)&lt;br/&gt;&lt;br/&gt;Above, a new version of zColorMix uses absColorMix and argColorMix. Notice how the Arg angle plays a role in both, especially in absColorMix.&lt;br/&gt;&lt;br/&gt;Now I am close. Images (e) and (f) are looking very much (b) and (d). Still missing is that background grid especially visible in (b). I’ll pick up there in Domain Coloring IV.</description>
      <enclosure url="http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/10/20_Domain_Coloring_III_files/droppedImage_8.jpg" length="41476" type="image/jpeg"/>
    </item>
    <item>
      <title>Domain Coloring II</title>
      <link>http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/10/20_Domain_Coloring_II.html</link>
      <guid isPermaLink="false">99aa4dc2-c9a5-4139-bb0b-dddbc94fb8a2</guid>
      <pubDate>Sat, 20 Oct 2007 11:32:23 -0600</pubDate>
      <description>&lt;a href=&quot;http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/10/20_Domain_Coloring_II_files/droppedImage_2.jpg&quot;&gt;&lt;img src=&quot;http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Media/object045.jpg&quot; style=&quot;float:left; padding-right:10px; padding-bottom:10px; width:230px; height:230px;&quot;/&gt;&lt;/a&gt;Lundmark used eight techniques to paint the range in his domain coloring paper. In this entry I’ll try to accomplish them using Mathematica’s Cardano3 package. &lt;br/&gt;&lt;br/&gt;In part 1, I described Lundmark’s steps for painting the range. For easy reference, here they are again ordered as I use them:&lt;br/&gt;&lt;br/&gt;	a.	A angular color gradient&lt;br/&gt;	b.	* Linear meld rate&lt;br/&gt;	c.	Smooth color transition, with discontinuity at 2π&lt;br/&gt;	d.	 * Three colors: black, red, yellow&lt;br/&gt;	e.	Logarithmic radius lines for scale&lt;br/&gt;	f.	Shadowing&lt;br/&gt;	g.	 A grid or other reference background&lt;br/&gt;	h.	* High resolution&lt;br/&gt;&lt;br/&gt;Flagged * techniques were not explicitly stated by Lundmark.&lt;br/&gt;&lt;br/&gt;As demonstration of the effectiveness of these techniques, compare the left and right sides of a plot of z and (z+2)²(z-w-2i)(z+i). I generated the left images with Cardano3 using Lundmark’s colors, but without his technique. The right sides are screen captures from Lundmark’s paper. In the remainder of this essay, you can distinguish Cardano3 images by their distinct and distracting center cross-hairs, which I wasn’t motivated to fix.&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;Techniques A through C&lt;br/&gt;&lt;br/&gt;The first three techniques are easy to accomplish with Cardano3. In fact, I already used them in the left sides of the above images. You simply define a color function using Mathematica’s ColorMix and Arg functions. ColorMix uses a linear-meld rate already. A point I mention because I’ll adjust it later. The xArg simply rescale’s Mathematica’s Arg to yield results in the range [0..2π]. &lt;br/&gt;&lt;br/&gt; w1[z_]:=z&lt;br/&gt; w2[z_]:= ((z + 2)^2*(z - 1 - 2*I)*(z + I))&lt;br/&gt; xArg[z_]:= Arg[ -z]+\[Pi]&lt;br/&gt;&lt;br/&gt; redYellow[z_]:= &lt;br/&gt;    ColorMix[ Red,Yellow][ xArg@z/ ( 2π+$MachineEpsilon)]&lt;br/&gt;&lt;br/&gt; Show@GraphicsArray@(&lt;br/&gt;    CodedDensity[{#},{0,3},&lt;br/&gt;    {redYellow},{},{PlotPoints-&gt;300}]&amp;amp;/@ {w1,w2})&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;Technique D: Three Colors&lt;br/&gt;&lt;br/&gt;Technique d takes a little more effort. ColorMix will only scale between two colors, so you need to define a more generalized color mixing function to replace ColorMix. qArg simply maps [0..2π] into [0..1]. zArgRescale works like Mathematica’s Rescale upon a complex number’s angle, leaving the magnitude intact.&lt;br/&gt;&lt;br/&gt; qArg[z_]:= xArg[z]/(2π+$MachineEpsilon)&lt;br/&gt;&lt;br/&gt; zColorMix[ color1_,color2_]:= &lt;br/&gt;    Function[ z, ColorMix[ color1,color2]@ qArg@z]&lt;br/&gt;&lt;br/&gt; zArgRescale[ z_, { argLo_,argHi_}]:=&lt;br/&gt;    Abs@z E^(((xArg[z] - argLo)/(argHi - argLo))*2*π*I)&lt;br/&gt;&lt;br/&gt; zRainbow[cs__]:= &lt;br/&gt;    zMixColors[ Length[ {cs}]-1, Sequence@@ Partition[ {cs},2,1]]&lt;br/&gt;&lt;br/&gt; zMixColors[ 1,pair1_List]:= &lt;br/&gt;    Function[ z, ( zColorMix@@pair1)[z]]&lt;br/&gt;&lt;br/&gt; zMixColors[ n_Integer, pair1_,pn__]:=&lt;br/&gt;    Function[ z, Which[&lt;br/&gt;        xArg@z&amp;lt; 2π/n, (zColorMix@@pair1)[ zArgRescale[ z, { 0, 2 \[Pi]/n}]],&lt;br/&gt;        xArg@z&gt;= 2π/n, zMixColors[ n-1,pn][ zArgRescale[ z, { 2π/n, 2\[Pi]}]] ]]&lt;br/&gt;&lt;br/&gt; blackRedYellow[z_]:= zRainbow[ Black,Red,Yellow][z]&lt;br/&gt;&lt;br/&gt; Show@ GraphicsArray@&lt;br/&gt;     ( CodedDensity[ {#}, { 0,3}, &lt;br/&gt;    {blackRedYellow}, {}, { PlotPoints-&gt;300}]&amp;amp; /@ { w1,w2})&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;Technique E: Logarithmic Scale&lt;br/&gt;&lt;br/&gt;Now for the logarithmic scale. Lundmark generates the scale as grey levels ranging from black to white as the fractional part of Log₂|w| varies from 0 to 1. There are two difficulties. First, image masks aren’t used in Cardano3; the scale must be integrated into the color function. This is done below to generate the left image, but as you can see it still isn’t quite right. The result seems to be a negative of the right image towards the center, while the periphery is correct. There is a black halo and the shading on the left radiates from white-to-black inside the halo, and black-to-white outside.Notice the black halo and how the shading radiates white-to-black inside the halo, and black-to-white outside.&lt;br/&gt;&lt;br/&gt; logBlackWhite[z_] := &lt;br/&gt;    ColorMix[Black, White][&lt;br/&gt;        Abs@FractionalPart@Log[2, Abs@z]]&lt;br/&gt;&lt;br/&gt;Show@GraphicsArray@(&lt;br/&gt;    CodedDensity[{#}, {0, 2},&lt;br/&gt;    {logBlackWhite}, {}, {PlotPoints -&gt; 400}] &amp;amp; /@ {w1})&lt;br/&gt;&lt;br/&gt;The problem is that Log₂|w| undergoes a sign change at |w| = 1. The solution is to prescale w so its values are &gt;= 1. This is done below by adding 1 in the term Log[2, 1+Abs@z] below.&lt;br/&gt;&lt;br/&gt; logBlackWhite[z_] := &lt;br/&gt;    ColorMix[Black, White][&lt;br/&gt;        Abs@FractionalPart@Log[2, 1+Abs@z]]&lt;br/&gt;&lt;br/&gt;Show@GraphicsArray@(&lt;br/&gt;    CodedDensity[{#}, {0,512},&lt;br/&gt;    {logBlackWhite}, {}, {PlotPoints -&gt; 400}] &amp;amp; /@ {w1})&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;Now for the results. Here are the pre-images of w1 and w2 over the domain (±2 ± 2ℹ).&lt;br/&gt;&lt;br/&gt;absMask[blackColor_, whiteColor_, z_] :=&lt;br/&gt;  ColorMix[blackColor, whiteColor][Abs@FractionalPart@Log[2, 1 + Abs@z]]&lt;br/&gt;&lt;br/&gt;argMask[blackColor_, whiteColor_, z_] :=&lt;br/&gt;  ColorMix[blackColor, whiteColor][qArg@z]&lt;br/&gt;&lt;br/&gt;logBlackWhite[z_] :=&lt;br/&gt;  absMask[argMask[Black, White, z], White, z]&lt;br/&gt;&lt;br/&gt;Show@GraphicsArray@(CodedDensity[{#}, {0, 2}, {logBlackWhite}, {}, \&lt;br/&gt;{PlotPoints -&gt; 400}] &amp;amp; /@ {w1, w2})&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;Finally, combining techniques A through E (angular gradient, linear meld rate, smooth transition, three colors, and logarithmic scale) results in:&lt;br/&gt;logBlackRedYel[z_] := &lt;br/&gt;    absMask[argMask[Black, #1, z], #1, z]&amp;amp;@blackRedYellow[z]&lt;br/&gt;&lt;br/&gt;Show@GraphicsArray@(CodedDensity[{#}, {0, 2},&lt;br/&gt;    {logBlackRedYel}, {}, {PlotPoints -&gt; 400}] &amp;amp; /@ {w1, w2})&lt;br/&gt;&lt;br/&gt;This is looking much better, but obviously short of Lundmark’s results. Things will improve in Domain Coloring III.&lt;br/&gt;&lt;br/&gt;Greg Frascadore @ Pike’s Perk, Colorado Springs CO, Jun 2006. Updated Mar 2007.&lt;br/&gt;</description>
      <enclosure url="http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/10/20_Domain_Coloring_II_files/droppedImage_2.jpg" length="24892" type="image/jpeg"/>
    </item>
    <item>
      <title>Domain Coloring</title>
      <link>http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/10/19_Domain_Coloring.html</link>
      <guid isPermaLink="false">140c1b93-6803-4e5e-9893-9f72a8e82e58</guid>
      <pubDate>Fri, 19 Oct 2007 22:01:19 -0600</pubDate>
      <description>&lt;a href=&quot;http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/10/19_Domain_Coloring_files/droppedImage_2.jpg&quot;&gt;&lt;img src=&quot;http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Media/object046.jpg&quot; style=&quot;float:left; padding-right:10px; padding-bottom:10px; width:220px; height:220px;&quot;/&gt;&lt;/a&gt;Domain coloring helps you visualize how a function behaves. With a little tuning, Mathematica’s Cardano3 package can paint images nearly as beautiful as those in Lundmark’s 2005 paper. &lt;br/&gt;&lt;br/&gt;The process of domain coloring was named by Frank Farris and applied by Lundmark2005 to complex functions. There is a Mathematica package, Cardano3, that creates domain-colored images. Unfortunately, the images rendered by Cardano3 don’t come close to the beauty of Lundmark’s when applied to the same functions. &lt;br/&gt;&lt;br/&gt;Here is a function colored by Cardano3 side-by-side with a rendering of the same function in Lundmark’s paper.&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;Pathetic. Obviously Lundmark gets much better results. Herein I’ll describe how to tune Cardano3 to use Lundmark’s technique.&lt;br/&gt;&lt;br/&gt;Background&lt;br/&gt;&lt;br/&gt;Cardano3 is a Mathematica package for creating graphical representations of complex functions. For domain coloring, you are only concerned with the function CodeDensity: a density plot using a color function to encode information. There is one supplied color function and a generic template from which other color schemes can be created. Here are some colorings using the distributed version of CodeDensity:&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;Well those look nice. Cardano3 seems to have the potential to create rich images.&lt;br/&gt;&lt;br/&gt;Lundmark didn’t invent domain coloring, but he describes the process as follows:&lt;br/&gt;&lt;br/&gt;1. “Paint” the range plane, either by copying a picture of something onto it, or by using some formula to color each point.&lt;br/&gt;2. Color every point z in the domain of f with the color of the corresponding point f(z).&lt;br/&gt;&lt;br/&gt;Lundmark then tuned the process for complex functions by refining the ways to paint the range. In particular, he describes these techniques:&lt;br/&gt;&lt;br/&gt;    a. A angular color gradient&lt;br/&gt;    b. Smooth color transition, but discontinuous at 2π&lt;br/&gt;    c. Logarithmic radius lines for scale&lt;br/&gt;    d. A grid or other reference background&lt;br/&gt;&lt;br/&gt;Contrast the default Cardano3 range with Lundmark’s results on coloring (z)&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;Lundmark is getting much prettier results. There are several other things he is doing that he did not emphasize:&lt;br/&gt;&lt;br/&gt;    e. Shadowing effects&lt;br/&gt;    f. High resolution&lt;br/&gt;    g. non-linear meld rate&lt;br/&gt;&lt;br/&gt;I’ve run out of time. I’ll pick things up in my next blog entry.&lt;br/&gt;&lt;br/&gt;Greg Frascadore, Serranos Coffee, Monument CO, Jun 2006&lt;br/&gt;&lt;br/&gt;</description>
      <enclosure url="http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/10/19_Domain_Coloring_files/droppedImage_2.jpg" length="202101" type="image/jpeg"/>
    </item>
    <item>
      <title>Code Breakout</title>
      <link>http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/10/1_Day_of_longboarding.html</link>
      <guid isPermaLink="false">f124522a-a9fa-443f-973d-5590ddb93a05</guid>
      <pubDate>Mon, 1 Oct 2007 22:48:36 -0600</pubDate>
      <description>&lt;a href=&quot;http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/10/1_Day_of_longboarding_files/droppedImage_1.jpg&quot;&gt;&lt;img src=&quot;http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Media/object047.jpg&quot; style=&quot;float:left; padding-right:10px; padding-bottom:10px; width:251px; height:186px;&quot;/&gt;&lt;/a&gt;The Mathematica programming language pre-dates language-based security. Mathematica has no controls that protect intellectual property the way distributing compiled (binary-only) code does for conventional programming languages. Of course, that doesn't stop folk from trying. &lt;br/&gt;&lt;br/&gt;Here is a protection technique from mathematica-users.org and an demonstration of its weakness.&lt;br/&gt;&lt;br/&gt;The Approach&lt;br/&gt;&lt;br/&gt;    “The basic idea is to include commands at the end of your package which set the attributes of your &amp;quot;secret&amp;quot; functions to be ReadProtected, and then Locked. The ReadProtected means no one can see the function definitions, and the Locked means no one can undo the ReadProtected attribute...encode the package file with the Encode routine. This encrypts the package file, such that it is no longer human readable, but because it is an ASCII text file it is more portable. ... The Needs or Get commands can read in the Encoded package file (possibly requiring a password, if you set one) and decrypt it, and once the package is in memory, the Locked and ReadProtect attributes now protect the secrets in your code.”&lt;br/&gt;&lt;br/&gt;    - &lt;a href=&quot;http://www.mathematica-users.org/webMathematica/wiki/wiki.jsp?pageName=FAQ_Writing_Packages&quot;&gt;http://www.mathematica-users.org/webMathematica/wiki/wiki.jsp?pageName=FAQ_Writing_Packages&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;The Weakness&lt;br/&gt;&lt;br/&gt;The protection afforded by this technique will stop only a casual attack. The weakness is that the package is being loaded into a malicious host - a huge interpreted programming environment (Mathematica) with few security features on which the encoded package can depend. A dedicated attack can craft that environment to pull the ReadProtected assumptions right out from under the loading package.&lt;br/&gt;&lt;br/&gt;As an example, here is a code fragment that cuts right through the above scheme. Execute this before loading a protected package.&lt;br/&gt;&lt;br/&gt;   Unprotect[SetAttributes]&lt;br/&gt;  SetAttributes[sym_, atts_List] := &lt;br/&gt;    SetAttributes[sym, &lt;br/&gt;        DeleteCases[atts, (Locked |ReadProtected)]] /; &lt;br/&gt;            MemberQ[atts, (Locked | ReadProtected)]&lt;br/&gt;  Protect[SetAttributes]&lt;br/&gt;  (* Then load package here *)&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;This redefines SetAttributes so the package locks its functions in vain. Against the mathematica-users.org example, this allows the attacker to then recover the source code by&lt;br/&gt;&lt;br/&gt;    ??demo`*&lt;br/&gt;&lt;br/&gt;All too easy.&lt;br/&gt;&lt;br/&gt;Enhancements&lt;br/&gt;&lt;br/&gt;The previous code describes the main idea. One enhancement we should make is to intercept Set as well as SetAttributes:&lt;br/&gt;&lt;br/&gt;(* copied and extended here from Defeat Readonly below *)&lt;br/&gt;Unprotect[SetAttributes, Set, Attributes]&lt;br/&gt;&lt;br/&gt;SetAttributes[sym_, att_Symbol] /; MemberQ[{Locked, ReadProtected}, att] := \&lt;br/&gt;Null&lt;br/&gt;&lt;br/&gt;SetAttributes[sym_,&lt;br/&gt; atts_List] /; MemberQ[atts, (Locked | &lt;br/&gt;      ReadProtected)] := SetAttributes[sym, DeleteCases[atts, (Locked |&lt;br/&gt;         ReadProtected)]]&lt;br/&gt;&lt;br/&gt;Attributes /: Set[Attributes[sym_], att_Symbol] /; MemberQ[{Locked, &lt;br/&gt;      ReadProtected}, att] := Null&lt;br/&gt;&lt;br/&gt;Attributes /: Set[Attributes[sym_], &lt;br/&gt;      atts_List] /; MemberQ[&lt;br/&gt;          atts, (Locked | ReadProtected)] := SetAttributes[sym, DeleteCases[&lt;br/&gt;    atts, (Locked | ReadProtected)]]&lt;br/&gt;&lt;br/&gt;Protect[SetAttributes, Set, Attributes]&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;Countermeasures&lt;br/&gt;&lt;br/&gt;I don’t know of any way to protect Mathematica packages from prying eyes. The Malicious Host Problem has no good solution. At best, one only slow the intrusion. For this SetAttributes-attack, you might try detecting whether SetAttributes has been overloaded:&lt;br/&gt;&lt;br/&gt;   Through[{System`UpValues, System`DownValues}[System`SetAttributes]]&lt;br/&gt;&lt;br/&gt;If this returns other than {{},{}}, then something is suspicious and you can take an action like aborting the remaining ‘secret’ definitions. Of course, this assumes that UpValues and DownValues are intact.&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;Greg Frascadore, Pikes Perk, Jun 2006</description>
      <enclosure url="http://web.me.com/nissplus/SILKDOTCOM/SwimLanes/Entries/2007/10/1_Day_of_longboarding_files/droppedImage_1.jpg" length="35220" type="image/jpeg"/>
    </item>
  </channel>
</rss>
