<!--{{{-->
<link rel='alternate' type='application/rss+xml' title='RSS' href='index.xml' />
<!--}}}-->
Background: #fff
Foreground: #000
PrimaryPale: #8cf
PrimaryLight: #18f
PrimaryMid: #04b
PrimaryDark: #014
SecondaryPale: #ffc
SecondaryLight: #fe8
SecondaryMid: #db4
SecondaryDark: #841
TertiaryPale: #eee
TertiaryLight: #ccc
TertiaryMid: #999
TertiaryDark: #666
Error: #f88
/*{{{*/
body {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}

a {color:[[ColorPalette::PrimaryMid]];}
a:hover {background-color:[[ColorPalette::PrimaryMid]]; color:[[ColorPalette::Background]];}
a img {border:0;}

h1,h2,h3,h4,h5,h6 {color:[[ColorPalette::SecondaryDark]]; background:transparent;}
h1 {border-bottom:2px solid [[ColorPalette::TertiaryLight]];}
h2,h3 {border-bottom:1px solid [[ColorPalette::TertiaryLight]];}

.button {color:[[ColorPalette::PrimaryDark]]; border:1px solid [[ColorPalette::Background]];}
.button:hover {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::SecondaryLight]]; border-color:[[ColorPalette::SecondaryMid]];}
.button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::SecondaryDark]];}

.header {background:[[ColorPalette::PrimaryMid]];}
.headerShadow {color:[[ColorPalette::Foreground]];}
.headerShadow a {font-weight:normal; color:[[ColorPalette::Foreground]];}
.headerForeground {color:[[ColorPalette::Background]];}
.headerForeground a {font-weight:normal; color:[[ColorPalette::PrimaryPale]];}

.tabSelected{color:[[ColorPalette::PrimaryDark]];
	background:[[ColorPalette::TertiaryPale]];
	border-left:1px solid [[ColorPalette::TertiaryLight]];
	border-top:1px solid [[ColorPalette::TertiaryLight]];
	border-right:1px solid [[ColorPalette::TertiaryLight]];
}
.tabUnselected {color:[[ColorPalette::Background]]; background:[[ColorPalette::TertiaryMid]];}
.tabContents {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::TertiaryPale]]; border:1px solid [[ColorPalette::TertiaryLight]];}
.tabContents .button {border:0;}

#sidebar {}
#sidebarOptions input {border:1px solid [[ColorPalette::PrimaryMid]];}
#sidebarOptions .sliderPanel {background:[[ColorPalette::PrimaryPale]];}
#sidebarOptions .sliderPanel a {border:none;color:[[ColorPalette::PrimaryMid]];}
#sidebarOptions .sliderPanel a:hover {color:[[ColorPalette::Background]]; background:[[ColorPalette::PrimaryMid]];}
#sidebarOptions .sliderPanel a:active {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::Background]];}

.wizard {background:[[ColorPalette::PrimaryPale]]; border:1px solid [[ColorPalette::PrimaryMid]];}
.wizard h1 {color:[[ColorPalette::PrimaryDark]]; border:none;}
.wizard h2 {color:[[ColorPalette::Foreground]]; border:none;}
.wizardStep {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];
	border:1px solid [[ColorPalette::PrimaryMid]];}
.wizardStep.wizardStepDone {background:[[ColorPalette::TertiaryLight]];}
.wizardFooter {background:[[ColorPalette::PrimaryPale]];}
.wizardFooter .status {background:[[ColorPalette::PrimaryDark]]; color:[[ColorPalette::Background]];}
.wizard .button {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryLight]]; border: 1px solid;
	border-color:[[ColorPalette::SecondaryPale]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryPale]];}
.wizard .button:hover {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Background]];}
.wizard .button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::Foreground]]; border: 1px solid;
	border-color:[[ColorPalette::PrimaryDark]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryDark]];}
	
.wizard .notChanged {background:transparent;}
.wizard .changedLocally {background:#80ff80;}
.wizard .changedServer {background:#8080ff;}
.wizard .changedBoth {background:#ff8080;}
.wizard .notFound {background:#ffff80;}
.wizard .putToServer {background:#ff80ff;}
.wizard .gotFromServer {background:#80ffff;}

#messageArea {border:1px solid [[ColorPalette::SecondaryMid]]; background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]];}
#messageArea .button {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::SecondaryPale]]; border:none;}

.popupTiddler {background:[[ColorPalette::TertiaryPale]]; border:2px solid [[ColorPalette::TertiaryMid]];}

.popup {background:[[ColorPalette::TertiaryPale]]; color:[[ColorPalette::TertiaryDark]]; border-left:1px solid [[ColorPalette::TertiaryMid]]; border-top:1px solid [[ColorPalette::TertiaryMid]]; border-right:2px solid [[ColorPalette::TertiaryDark]]; border-bottom:2px solid [[ColorPalette::TertiaryDark]];}
.popup hr {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::PrimaryDark]]; border-bottom:1px;}
.popup li.disabled {color:[[ColorPalette::TertiaryMid]];}
.popup li a, .popup li a:visited {color:[[ColorPalette::Foreground]]; border: none;}
.popup li a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border: none;}
.popup li a:active {background:[[ColorPalette::SecondaryPale]]; color:[[ColorPalette::Foreground]]; border: none;}
.popupHighlight {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
.listBreak div {border-bottom:1px solid [[ColorPalette::TertiaryDark]];}

.tiddler .defaultCommand {font-weight:bold;}

.shadow .title {color:[[ColorPalette::TertiaryDark]];}

.title {color:[[ColorPalette::SecondaryDark]];}
.subtitle {color:[[ColorPalette::TertiaryDark]];}

.toolbar {color:[[ColorPalette::PrimaryMid]];}
.toolbar a {color:[[ColorPalette::TertiaryLight]];}
.selected .toolbar a {color:[[ColorPalette::TertiaryMid]];}
.selected .toolbar a:hover {color:[[ColorPalette::Foreground]];}

.tagging, .tagged {border:1px solid [[ColorPalette::TertiaryPale]]; background-color:[[ColorPalette::TertiaryPale]];}
.selected .tagging, .selected .tagged {background-color:[[ColorPalette::TertiaryLight]]; border:1px solid [[ColorPalette::TertiaryMid]];}
.tagging .listTitle, .tagged .listTitle {color:[[ColorPalette::PrimaryDark]];}
.tagging .button, .tagged .button {border:none;}

.footer {color:[[ColorPalette::TertiaryLight]];}
.selected .footer {color:[[ColorPalette::TertiaryMid]];}

.sparkline {background:[[ColorPalette::PrimaryPale]]; border:0;}
.sparktick {background:[[ColorPalette::PrimaryDark]];}

.error, .errorButton {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Error]];}
.warning {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryPale]];}
.lowlight {background:[[ColorPalette::TertiaryLight]];}

.zoomer {background:none; color:[[ColorPalette::TertiaryMid]]; border:3px solid [[ColorPalette::TertiaryMid]];}

.imageLink, #displayArea .imageLink {background:transparent;}

.annotation {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border:2px solid [[ColorPalette::SecondaryMid]];}

.viewer .listTitle {list-style-type:none; margin-left:-2em;}
.viewer .button {border:1px solid [[ColorPalette::SecondaryMid]];}
.viewer blockquote {border-left:3px solid [[ColorPalette::TertiaryDark]];}

.viewer table, table.twtable {border:2px solid [[ColorPalette::TertiaryDark]];}
.viewer th, .viewer thead td, .twtable th, .twtable thead td {background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::Background]];}
.viewer td, .viewer tr, .twtable td, .twtable tr {border:1px solid [[ColorPalette::TertiaryDark]];}

.viewer pre {border:1px solid [[ColorPalette::SecondaryLight]]; background:[[ColorPalette::SecondaryPale]];}
.viewer code {color:[[ColorPalette::SecondaryDark]];}
.viewer hr {border:0; border-top:dashed 1px [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::TertiaryDark]];}

.highlight, .marked {background:[[ColorPalette::SecondaryLight]];}

.editor input {border:1px solid [[ColorPalette::PrimaryMid]];}
.editor textarea {border:1px solid [[ColorPalette::PrimaryMid]]; width:100%;}
.editorFooter {color:[[ColorPalette::TertiaryMid]];}

#backstageArea {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::TertiaryMid]];}
#backstageArea a {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;}
#backstageArea a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; }
#backstageArea a.backstageSelTab {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
#backstageButton a {background:none; color:[[ColorPalette::Background]]; border:none;}
#backstageButton a:hover {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;}
#backstagePanel {background:[[ColorPalette::Background]]; border-color: [[ColorPalette::Background]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]];}
.backstagePanelFooter .button {border:none; color:[[ColorPalette::Background]];}
.backstagePanelFooter .button:hover {color:[[ColorPalette::Foreground]];}
#backstageCloak {background:[[ColorPalette::Foreground]]; opacity:0.6; filter:'alpha(opacity:60)';}
/*}}}*/
/*{{{*/
* html .tiddler {height:1%;}

body {font-size:.75em; font-family:arial,helvetica; margin:0; padding:0;}

h1,h2,h3,h4,h5,h6 {font-weight:bold; text-decoration:none;}
h1,h2,h3 {padding-bottom:1px; margin-top:1.2em;margin-bottom:0.3em;}
h4,h5,h6 {margin-top:1em;}
h1 {font-size:1.35em;}
h2 {font-size:1.25em;}
h3 {font-size:1.1em;}
h4 {font-size:1em;}
h5 {font-size:.9em;}

hr {height:1px;}

a {text-decoration:none;}

dt {font-weight:bold;}

ol {list-style-type:decimal;}
ol ol {list-style-type:lower-alpha;}
ol ol ol {list-style-type:lower-roman;}
ol ol ol ol {list-style-type:decimal;}
ol ol ol ol ol {list-style-type:lower-alpha;}
ol ol ol ol ol ol {list-style-type:lower-roman;}
ol ol ol ol ol ol ol {list-style-type:decimal;}

.txtOptionInput {width:11em;}

#contentWrapper .chkOptionInput {border:0;}

.externalLink {text-decoration:underline;}

.indent {margin-left:3em;}
.outdent {margin-left:3em; text-indent:-3em;}
code.escaped {white-space:nowrap;}

.tiddlyLinkExisting {font-weight:bold;}
.tiddlyLinkNonExisting {font-style:italic;}

/* the 'a' is required for IE, otherwise it renders the whole tiddler in bold */
a.tiddlyLinkNonExisting.shadow {font-weight:bold;}

#mainMenu .tiddlyLinkExisting,
	#mainMenu .tiddlyLinkNonExisting,
	#sidebarTabs .tiddlyLinkNonExisting {font-weight:normal; font-style:normal;}
#sidebarTabs .tiddlyLinkExisting {font-weight:bold; font-style:normal;}

.header {position:relative;}
.header a:hover {background:transparent;}
.headerShadow {position:relative; padding:4.5em 0em 1em 1em; left:-1px; top:-1px;}
.headerForeground {position:absolute; padding:4.5em 0em 1em 1em; left:0px; top:0px;}

.siteTitle {font-size:3em;}
.siteSubtitle {font-size:1.2em;}

#mainMenu {position:absolute; left:0; width:10em; text-align:right; line-height:1.6em; padding:1.5em 0.5em 0.5em 0.5em; font-size:1.1em;}

#sidebar {position:absolute; right:3px; width:16em; font-size:.9em;}
#sidebarOptions {padding-top:0.3em;}
#sidebarOptions a {margin:0em 0.2em; padding:0.2em 0.3em; display:block;}
#sidebarOptions input {margin:0.4em 0.5em;}
#sidebarOptions .sliderPanel {margin-left:1em; padding:0.5em; font-size:.85em;}
#sidebarOptions .sliderPanel a {font-weight:bold; display:inline; padding:0;}
#sidebarOptions .sliderPanel input {margin:0 0 .3em 0;}
#sidebarTabs .tabContents {width:15em; overflow:hidden;}

.wizard {padding:0.1em 1em 0em 2em;}
.wizard h1 {font-size:2em; font-weight:bold; background:none; padding:0em 0em 0em 0em; margin:0.4em 0em 0.2em 0em;}
.wizard h2 {font-size:1.2em; font-weight:bold; background:none; padding:0em 0em 0em 0em; margin:0.4em 0em 0.2em 0em;}
.wizardStep {padding:1em 1em 1em 1em;}
.wizard .button {margin:0.5em 0em 0em 0em; font-size:1.2em;}
.wizardFooter {padding:0.8em 0.4em 0.8em 0em;}
.wizardFooter .status {padding:0em 0.4em 0em 0.4em; margin-left:1em;}
.wizard .button {padding:0.1em 0.2em 0.1em 0.2em;}

#messageArea {position:fixed; top:2em; right:0em; margin:0.5em; padding:0.5em; z-index:2000; _position:absolute;}
.messageToolbar {display:block; text-align:right; padding:0.2em 0.2em 0.2em 0.2em;}
#messageArea a {text-decoration:underline;}

.tiddlerPopupButton {padding:0.2em 0.2em 0.2em 0.2em;}
.popupTiddler {position: absolute; z-index:300; padding:1em 1em 1em 1em; margin:0;}

.popup {position:absolute; z-index:300; font-size:.9em; padding:0; list-style:none; margin:0;}
.popup .popupMessage {padding:0.4em;}
.popup hr {display:block; height:1px; width:auto; padding:0; margin:0.2em 0em;}
.popup li.disabled {padding:0.4em;}
.popup li a {display:block; padding:0.4em; font-weight:normal; cursor:pointer;}
.listBreak {font-size:1px; line-height:1px;}
.listBreak div {margin:2px 0;}

.tabset {padding:1em 0em 0em 0.5em;}
.tab {margin:0em 0em 0em 0.25em; padding:2px;}
.tabContents {padding:0.5em;}
.tabContents ul, .tabContents ol {margin:0; padding:0;}
.txtMainTab .tabContents li {list-style:none;}
.tabContents li.listLink { margin-left:.75em;}

#contentWrapper {display:block;}
#splashScreen {display:none;}

#displayArea {margin:1em 17em 0em 14em;}

.toolbar {text-align:right; font-size:.9em;}

.tiddler {padding:1em 1em 0em 1em;}

.missing .viewer,.missing .title {font-style:italic;}

.title {font-size:1.6em; font-weight:bold;}

.missing .subtitle {display:none;}
.subtitle {font-size:1.1em;}

.tiddler .button {padding:0.2em 0.4em;}

.tagging {margin:0.5em 0.5em 0.5em 0; float:left; display:none;}
.isTag .tagging {display:block;}
.tagged {margin:0.5em; float:right;}
.tagging, .tagged {font-size:0.9em; padding:0.25em;}
.tagging ul, .tagged ul {list-style:none; margin:0.25em; padding:0;}
.tagClear {clear:both;}

.footer {font-size:.9em;}
.footer li {display:inline;}

.annotation {padding:0.5em; margin:0.5em;}

* html .viewer pre {width:99%; padding:0 0 1em 0;}
.viewer {line-height:1.4em; padding-top:0.5em;}
.viewer .button {margin:0em 0.25em; padding:0em 0.25em;}
.viewer blockquote {line-height:1.5em; padding-left:0.8em;margin-left:2.5em;}
.viewer ul, .viewer ol {margin-left:0.5em; padding-left:1.5em;}

.viewer table, table.twtable {border-collapse:collapse; margin:0.8em 1.0em;}
.viewer th, .viewer td, .viewer tr,.viewer caption,.twtable th, .twtable td, .twtable tr,.twtable caption {padding:3px;}
table.listView {font-size:0.85em; margin:0.8em 1.0em;}
table.listView th, table.listView td, table.listView tr {padding:0px 3px 0px 3px;}

.viewer pre {padding:0.5em; margin-left:0.5em; font-size:1.2em; line-height:1.4em; overflow:auto;}
.viewer code {font-size:1.2em; line-height:1.4em;}

.editor {font-size:1.1em;}
.editor input, .editor textarea {display:block; width:100%; font:inherit;}
.editorFooter {padding:0.25em 0em; font-size:.9em;}
.editorFooter .button {padding-top:0px; padding-bottom:0px;}

.fieldsetFix {border:0; padding:0; margin:1px 0px 1px 0px;}

.sparkline {line-height:1em;}
.sparktick {outline:0;}

.zoomer {font-size:1.1em; position:absolute; overflow:hidden;}
.zoomer div {padding:1em;}

* html #backstage {width:99%;}
* html #backstageArea {width:99%;}
#backstageArea {display:none; position:relative; overflow: hidden; z-index:150; padding:0.3em 0.5em 0.3em 0.5em;}
#backstageToolbar {position:relative;}
#backstageArea a {font-weight:bold; margin-left:0.5em; padding:0.3em 0.5em 0.3em 0.5em;}
#backstageButton {display:none; position:absolute; z-index:175; top:0em; right:0em;}
#backstageButton a {padding:0.1em 0.4em 0.1em 0.4em; margin:0.1em 0.1em 0.1em 0.1em;}
#backstage {position:relative; width:100%; z-index:50;}
#backstagePanel {display:none; z-index:100; position:absolute; width:90%; margin:0em 3em 0em 3em; padding:1em 1em 1em 1em;}
.backstagePanelFooter {padding-top:0.2em; float:right;}
.backstagePanelFooter a {padding:0.2em 0.4em 0.2em 0.4em;}
#backstageCloak {display:none; z-index:20; position:absolute; width:100%; height:100px;}

.whenBackstage {display:none;}
.backstageVisible .whenBackstage {display:block;}
/*}}}*/
/***
StyleSheet for use when a translation requires any css style changes.
This StyleSheet can be used directly by languages such as Chinese, Japanese and Korean which need larger font sizes.
***/
/*{{{*/
body {font-size:0.8em;}
#sidebarOptions {font-size:1.05em;}
#sidebarOptions a {font-style:normal;}
#sidebarOptions .sliderPanel {font-size:0.95em;}
.subtitle {font-size:0.8em;}
.viewer table.listView {font-size:0.95em;}
/*}}}*/
/*{{{*/
@media print {
#mainMenu, #sidebar, #messageArea, .toolbar, #backstageButton, #backstageArea {display: none ! important;}
#displayArea {margin: 1em 1em 0em 1em;}
/* Fixes a feature in Firefox 1.5.0.2 where print preview displays the noscript content */
noscript {display:none;}
}
/*}}}*/
<!--{{{-->
<div class='header' macro='gradient vert [[ColorPalette::PrimaryLight]] [[ColorPalette::PrimaryMid]]'>
<div class='headerShadow'>
<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;
<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>
</div>
<div class='headerForeground'>
<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;
<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>
</div>
</div>
<div id='mainMenu' refresh='content' tiddler='MainMenu'></div>
<div id='sidebar'>
<div id='sidebarOptions' refresh='content' tiddler='SideBarOptions'></div>
<div id='sidebarTabs' refresh='content' force='true' tiddler='SideBarTabs'></div>
</div>
<div id='displayArea'>
<div id='messageArea'></div>
<div id='tiddlerDisplay'></div>
</div>
<!--}}}-->
<!--{{{-->
<div class='toolbar' macro='toolbar [[ToolbarCommands::ViewToolbar]]'></div>
<div class='title' macro='view title'></div>
<div class='subtitle'><span macro='view modifier link'></span>, <span macro='view modified date'></span> (<span macro='message views.wikified.createdPrompt'></span> <span macro='view created date'></span>)</div>
<div class='tagging' macro='tagging'></div>
<div class='tagged' macro='tags'></div>
<div class='viewer' macro='view text wikified'></div>
<div class='tagClear'></div>
<!--}}}-->
<!--{{{-->
<div class='toolbar' macro='toolbar [[ToolbarCommands::EditToolbar]]'></div>
<div class='title' macro='view title'></div>
<div class='editor' macro='edit title'></div>
<div macro='annotations'></div>
<div class='editor' macro='edit text'></div>
<div class='editor' macro='edit tags'></div><div class='editorFooter'><span macro='message views.editor.tagPrompt'></span><span macro='tagChooser'></span></div>
<!--}}}-->
To get started with this blank TiddlyWiki, you'll need to modify the following tiddlers:
* SiteTitle & SiteSubtitle: The title and subtitle of the site, as shown above (after saving, they will also appear in the browser title bar)
* MainMenu: The menu (usually on the left)
* DefaultTiddlers: Contains the names of the tiddlers that you want to appear when the TiddlyWiki is opened
You'll also need to enter your username for signing your edits: <<option txtUserName>>
These InterfaceOptions for customising TiddlyWiki are saved in your browser

Your username for signing your edits. Write it as a WikiWord (eg JoeBloggs)

<<option txtUserName>>
<<option chkSaveBackups>> SaveBackups
<<option chkAutoSave>> AutoSave
<<option chkRegExpSearch>> RegExpSearch
<<option chkCaseSensitiveSearch>> CaseSensitiveSearch
<<option chkAnimate>> EnableAnimations

----
Also see AdvancedOptions
<<importTiddlers>>
I am a researcher in quantum information theory based at Royal holloway, University of London. I have worked in applied mathematics, quantum information theory, and condensed matter physics for the past eight years or so.

Inspired by the recent discussions (see, eg., Michael Nielsen’s blog postings) surrounding open science I have decided to make my research notes open. This TiddlyWiki is one attempt to make my notes accessible to a wider audience, and it is hoped that it can be as current a snapshot of my research notes as possible. The content is a little sparse at the moment, but I hope to add more as time passes. 

If you make any progress on the ideas or open problems discussed on this site then please let me know: I am more than happy for anything here to become a joint project, the more the merrier! (After all, it might be easier to write a joint paper with the collaborators on this site rather than rewriting everything yourself…)

If you want to look at any of my notes which include many formulae then I'd strongly suggest installing the jsMath [[fonts|http://www.math.union.edu/~dpvc/jsMath/download/jsMath-fonts.html]] (they are 4 ttf files).
The central place to find out about my current research is my [[blog|http://tjoresearchnotes.wordpress.com/]]. You can find links to the rss updates from my twitter and del.icio.us accounts and from this TiddlyWiki there.

Draft posts can be found [[here|Draft blog posts]].
[[The simulation problem]]
!Introduction

One thing I'm beginning to understand in practising open science in the web 2.0 age is that it is all about getting //content// from A to B. Also, what seems to be becoming clear, is that the //format// of the content is becoming increasingly less well-defined: news articles blend with blog posts blend with music videos blend with scientific data. It used to be that the format dictated the content (eg. via the file extension), but now this distinction is much less clear.

However, what isn't working so well (at least to my inexperienced mind) is content //synchronisation// between services. 
!Introduction
The Davidenko equation is a system of differential equations which track the zeros of a parameter-dependent system of polynomials.

!Simple example

Let $p_t(x) = \sum_{j=0}^d a_j(t) x^j$ be a parameter-dependent polynomial of degree $d$ in the variable $x$. Write $z_j(t)$, $j = 1, 2, \ldots, d$ for the (possibly compex) zeroes of $p_t(x)$. We want to set up a system of ordinary differential equations for the parameter-dependent zeros of $p_t(x)$. This can be done in several ways. One way is to suppose that we know $z_j(t)$, $j = 1, 2, \ldots, d$ at a time $t$ and to consider a small change in $H(x,t) = p_t(x)$:
$$
dH(x,t) = \frac{\partial H(x,t)}{\partial x} dx + \frac{\partial H(x,t)}{\partial t} dt.
$$
Now, substituting $x = z_j(t)$ we obtain
$$
dH(z_j(t),t) = \frac{\partial H(z_j(t),t)}{\partial x} dz_j(t) + \frac{\partial H(z_j(t),t)}{\partial t} dt.
$$
Now, because $z_j(t)$ is supposed to be a zero of $p_t(x)$ for all time we must have that
$$
0 = \frac{\partial H(z_j(t),t)}{\partial x} dz_j(t) + \frac{\partial H(z_j(t),t)}{\partial t} dt
$$
so that
$$
\frac{dz_j(t)}{dt} = - \left(\frac{\partial H(z_j(t),t)}{\partial x}\right)^{-1} \frac{\partial H(z_j(t),t)}{\partial t}.
$$
This is the basic Davidenko equation.

!!A small example polynomial
Suppose that 
$$
p_t(x) = x^2 + (1+t)x - 1.
$$
In this case the Davidenko equation becomes
$$
\frac{dz_j(t)}{dt} = - \frac{z_j(t)}{2z_j(t) + t - 1}, \quad j = 1, 2.
$$

!Full derivation

[[Discrete phase space]]
[[Random QSAT]]
[[Toward efficient quantum circuits for the Laughlin wavefunction]]
[[On open science]]
[[Hamiltonian complexity]]
[[What is a quantum phase transition?]]

In the (now foundational) paper quant-ph/9707038 Lo and Popescu describe protocols involving [[local operations and classical communication|Local operations and classical communication]] on quantum bipartite entangled states. There are several tricks that one can play with entangled states in this setting and I just want to note down some of the more basic and fundamental results. All of the results here pertain to two $d$-dimensional quantum systems (qudits). 

Write $|\Psi^+\rangle = \frac{1}{\sqrt{d}}\sum_{j=1}^d |jj\rangle$. Then we have the following
<<<
''Lemma 1''. Let $M$ be a $d\times d$ matrix. Then 
$$
M\otimes \mathbb{I}|\Psi^+\rangle = \mathbb{I}\otimes M^T|\Psi^+\rangle.
$$
<<<
<<<
//Proof//.
$$
M\otimes \mathbb{I}|\Psi^+\rangle = \frac{1}{\sqrt{d}}\sum_{j,k=1}^d m_{k,j} |kj\rangle =  \frac{1}{\sqrt{d}}\sum_{j,k=1}^d m_{j,k} |jk\rangle = \mathbb{I}\otimes M^T|\Psi^+\rangle.
$$
<<<
The second result tells us how to prepare essentially //any// two-qudit state from $|\Psi^+\rangle$ via a local rotation and a post-selected measurement on just //one// half of $|\Psi^+\rangle$. This is the //remote-control of entanglement// trick. It is also known as the Reeh-Schlieder theorem in algebraic quantum field theory (where it applies in a vastly more general setting) which is also called the //Taj-Mahal theorem// (because someone could create the Taj-Mahal on the other side of the universe by simply measuring one half of a sufficiently entangled state and post selecting). The precise result is
<<<
''Proposition 1''. Let $|\phi\rangle = \sum_{j=1}^d \sqrt{p_j}|u_jv_j\rangle$ be the Schmidt decomposition of an arbitrary pure state of two qudits. Suppose that $p_j>0$. Then 
$$
|\phi\rangle = A\otimes \mathbb{I}|\Psi^+\rangle,
$$
where $A = MUV^T$ with $U|j\rangle = |u_j\rangle$, $V|j\rangle = |v_j\rangle$, and $M|j\rangle = \sqrt{dp_j}|j\rangle$.
<<<
<<<
//Proof//. Follows directly after applying Lemma 1.
<<<
In this note I will describe how to construct all of the ground states for a class of interacting quantum spin systems. The systems considered here pertain to $n$ qudits (with local dimension $d$) arranged in a line, and have the following form (they are a subclass of the family of [[quantum satisfiability|Quantum satisfiability]] instances).
$$
\sum_{j=1}^{n-1} |\phi_{j,j+1}\rangle\langle\phi_{j,j+1}|\otimes \mathbb{I}_{[n]\setminus\{j,j+1\}},
$$
where the pure states $|\phi_{j,j+1}\rangle$ have [[Schmidt decomposition]]
$$
|\phi_{j,j+1}\rangle = \sum_{k=1}^d\sqrt{q_k^{(j)}}|u_kv_k\rangle,
$$
with $q_j>0$. The pure states $|\phi_{j,j+1}\rangle$ are otherwise arbitrary.

The way to solve these systems is to exploit [[Proposition 1|Entanglement remote-control]]: we first write 
$$
|\phi_{j,j+1}\rangle = A_j\otimes \mathbb{I}_{j+1}|\Psi^+\rangle,
$$
where $|\Psi^+\rangle = \frac{1}{\sqrt{d}}\sum_{j=1}^d |jj\rangle$. The next step is to take a ground state $|\Omega\rangle$ of 
$$
K = \sum_{j=1}^{n-1} |\Psi_{j,j+1}^+\rangle\langle\Psi_{j,j+1}^+|\otimes \mathbb{I}_{[n]\setminus\{j,j+1\}}.
$$ 
and construct
$$
|\Gamma\rangle = T_1\otimes T_2\otimes \cdots \otimes T_{n-1}\otimes \mathbb{I}_n|\Omega\rangle,
$$
where, for $j$ even (need to check these formulae!),
$$
T_{n-j} = (A_{j-1}^\dagger A_{j-2}^*\cdots A_2^* A_1^\dagger)^{-1},
$$
and for $j$ odd,
$$
T_{n-j} = (A_{j-1}^* A_{j-2}^\dagger\cdots A_2^* A_1^\dagger)^{-1}.
$$
We now have the following
<<<
''Proposition 1''. $|\Gamma\rangle$ is a ground state of $H$.
<<<
<<<
//Proof//.
<<<
[[Stochastic Davidenko equation]]

From Oded Regev's lecture [[notes|http://www.cs.tau.ac.il/~odedr/teaching/quantum_fall_2005/ln/qma.pdf]]: 
<<<
As we all know, for any two lines in $\mathbb{R}^n$ that go through the origin (i.e., one-dimensional subspaces), one can define the angle between them. If we take a line and a plane, we can again define the angle between them in a natural way. But what happens if we take two planes? Here our three-dimensional intuition is no longer good enough. Indeed, in three-dimensions, two two-dimensional subspaces always intersect in a line, and orthogonal to that line we find the angle between the two subspaces. This is no longer true in higher dimensions: Starting from four dimensions, two two-dimensional subspaces generally have a trivial intersection, and instead of forming an angle, they form two angles! 
In more generality, the question we consider in this section is how two subspaces interact. This question turns out to have a very elegant answer, as we shall soon see. This answer, which was first given in a remarkable paper of C. Jordan in 1875, was since rediscovered many times by mathematicians, statisticians, physicists, and computer scientists. In addition to being a crucial component in witness-preserving amplification of QMA, this question also plays an important role in many recent results in quantum computation, often in an implicit way... This topic is also covered in Chapter VII of the [[book|http://books.google.co.uk/books?id=eay3HALl620C&dq=bhatia+matrix+analysis&printsec=frontcover&source=bn&hl=en&ei=_2zfSYeQCNqD-AaHj6yFCQ&sa=X&oi=book_result&ct=result&resnum=4]] by
Bhatia.
<<<
The lemma itself is as follows.
<<<
''Lemma 1'' (Jordan, 1875). For any two Hermitian projectors $\Pi_0$ and $\Pi_1$, there exists an orthogonal decomposition of the Hilbert space into one dimensional and two dimensional subspaces that are invariant under both $\Pi_0$ and $\Pi_1$. Moreover, inside each two-dimensional subspace, $\Pi_0$ and $\Pi_1$ are rank-one projectors. (In other words, inside each two-dimensional subspace there are two unit vectors $|v\rangle$ and $|w\rangle$ suchthat $\Pi_0$ projects on $|v\rangle$ and $\Pi_1$ projects on $|w\rangle$.)
<<<
The proof of this lemma is actually elementary:
<<<
//Proof//. The idea is to look at the hermitian matrix $H = \Pi_0 + \Pi_1$. It turns out that the eigenvectors of $H$ can be partitioned into sets of size one or two, and these sets in fact span the subspaces mentioned in the lemma. 
Let $|\phi\rangle$ be an eigenvector of $H$, of unit length. Let $\lambda$ be the corresponding eigenvalue. Then
$$
\Pi_0|\phi\rangle +  \Pi_1|\phi\rangle = \lambda|\phi\rangle.
$$
Assume first that $\Pi_0|\phi\rangle$ lies in the subspace spanned by $|\phi\rangle$. By the eigenvector equation above, we have that $\Pi_1|\phi\rangle$ lies in the same subspace. This means that the subspace spanned by $|\phi\rangle$ is invariant under $\Pi_0$ and $\Pi_1$, hence it is an eigenvector of both projectors. Hence $\Pi_0|\phi\rangle$ is $0$ or $|\phi\rangle$, and similarly for $\Pi_1$. 
So we now assume that $\Pi_0|\phi\rangle$ is not in the subspace spanned by $|\phi\rangle$. So consider, instead, the two-dimensional subspace $S$ spanned by $|\phi\rangle$ and $\Pi_0|\phi\rangle$. Evidently $S$ is invariant under $\phi_0$ because
$$
\Pi_0(\alpha |\phi\rangle + \beta\Pi_0|\phi) = (\alpha+\beta)\Pi_0|\phi\rangle \in S.
$$
It is also invariant under $\Pi_1$ thanks to the eigenvector equation:
$$
\Pi_1|\phi\rangle = \lambda|\phi\rangle - \Pi_0|\phi\rangle \in S
$$
so that
$$
\Pi_1\Pi_0|\phi\rangle = \Pi_1(\lambda|\phi\rangle - \Pi_1|\phi\rangle) = (\lambda-1)\Pi_1|\phi\rangle \in S.
$$
Because $S$ is invariant under both $\Pi_0$ and $\Pi_1$ it is invariant under $H$. Hence, the vector orthogonal to $|\phi\rangle$ in $S$ is actually another eigenvector of $H$, and so $S$ is actually spanned by a pair of eigenvectors of $H$, as claimed. To conclude, note that inside $S$ the operators $\Pi_0$ and $\Pi_1$ are rank-one projectors.
<<<
/***
|''Name:''|LoadRemoteFileThroughProxy (previous LoadRemoteFileHijack)|
|''Description:''|When the TiddlyWiki file is located on the web (view over http) the content of [[SiteProxy]] tiddler is added in front of the file url. If [[SiteProxy]] does not exist "/proxy/" is added. |
|''Version:''|1.1.0|
|''Date:''|mar 17, 2007|
|''Source:''|http://tiddlywiki.bidix.info/#LoadRemoteFileHijack|
|''Author:''|BidiX (BidiX (at) bidix (dot) info)|
|''License:''|[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D ]]|
|''~CoreVersion:''|2.2.0|
***/
//{{{
version.extensions.LoadRemoteFileThroughProxy = {
 major: 1, minor: 1, revision: 0, 
 date: new Date("mar 17, 2007"), 
 source: "http://tiddlywiki.bidix.info/#LoadRemoteFileThroughProxy"};

if (!window.bidix) window.bidix = {}; // bidix namespace
if (!bidix.core) bidix.core = {};

bidix.core.loadRemoteFile = loadRemoteFile;
loadRemoteFile = function(url,callback,params)
{
 if ((document.location.toString().substr(0,4) == "http") && (url.substr(0,4) == "http")){ 
 url = store.getTiddlerText("SiteProxy", "/proxy/") + url;
 }
 return bidix.core.loadRemoteFile(url,callback,params);
}
//}}}
[[About]]
[[Blog]]
[[Ideas]]
[[Problems]]
[[Notes]]
[[Talks]]
[[Courses]]
[[Jordan's lemma]]
[[Mathematics notes]]
!Title of talk: Hamiltonian Complexity
These are notes for a talk to be given at the 2009 IMA [[conference|http://www.ima.org.uk/Conferences/quantum_computing_programme.html]] on quantum computing and complexity of simulation.

The idea of the talk is to give a very gentle introduction to results about the computational complexity of simulating physical systems.
!Outline
* Title slide
* Outline
* Physical systems
** Hilbert space
** Hamiltonians
** States
** Observables
*** //Physically// measurable observables are //local//
* Simulation
** Want to be able to //predict//
** What problems? Want to predict local observables.
*** Equilibrium:
**** Zero temp.
**** Non-zero temp.
*** Non-equilibrium: dynamical observables.
** Efficiency: scaling with $n$, $d$, $\|h\|$, and $\mbox{supp}(A)$ is crucial
* Hardness
** What does //hard// mean?
*** Physical predictions impossible if hard!
*** But maybe system can never enter //hard// states?
** Review of //hardness// results (see other talks)
*** QMA etc.
* Efficient simulation
** Describe [[QSAT|Quantum satisfiability]]
*** Review of //easiness// results 
*** Describe partial results toward extending alphabet; relate to 3-[[colouring]].
*** Describe entanglement remote-control solution.
** Describe //dynamics//
*** Describe the [[Lieb-Robinson bound]].
*** Describe how Lieb-Robinson can be used to provide approximate QCA description of propagator.
** Describe //adiabatic continuation//.
*** Quote results on efficient simulation of gapped adiabatic evolution for 2D systems.
/***
|''Name:''|PasswordOptionPlugin|
|''Description:''|Extends TiddlyWiki options with non encrypted password option.|
|''Version:''|1.0.2|
|''Date:''|Apr 19, 2007|
|''Source:''|http://tiddlywiki.bidix.info/#PasswordOptionPlugin|
|''Author:''|BidiX (BidiX (at) bidix (dot) info)|
|''License:''|[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D ]]|
|''~CoreVersion:''|2.2.0 (Beta 5)|
***/
//{{{
version.extensions.PasswordOptionPlugin = {
	major: 1, minor: 0, revision: 2, 
	date: new Date("Apr 19, 2007"),
	source: 'http://tiddlywiki.bidix.info/#PasswordOptionPlugin',
	author: 'BidiX (BidiX (at) bidix (dot) info',
	license: '[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D]]',
	coreVersion: '2.2.0 (Beta 5)'
};

config.macros.option.passwordCheckboxLabel = "Save this password on this computer";
config.macros.option.passwordInputType = "password"; // password | text
setStylesheet(".pasOptionInput {width: 11em;}\n","passwordInputTypeStyle");

merge(config.macros.option.types, {
	'pas': {
		elementType: "input",
		valueField: "value",
		eventName: "onkeyup",
		className: "pasOptionInput",
		typeValue: config.macros.option.passwordInputType,
		create: function(place,type,opt,className,desc) {
			// password field
			config.macros.option.genericCreate(place,'pas',opt,className,desc);
			// checkbox linked with this password "save this password on this computer"
			config.macros.option.genericCreate(place,'chk','chk'+opt,className,desc);			
			// text savePasswordCheckboxLabel
			place.appendChild(document.createTextNode(config.macros.option.passwordCheckboxLabel));
		},
		onChange: config.macros.option.genericOnChange
	}
});

merge(config.optionHandlers['chk'], {
	get: function(name) {
		// is there an option linked with this chk ?
		var opt = name.substr(3);
		if (config.options[opt]) 
			saveOptionCookie(opt);
		return config.options[name] ? "true" : "false";
	}
});

merge(config.optionHandlers, {
	'pas': {
 		get: function(name) {
			if (config.options["chk"+name]) {
				return encodeCookie(config.options[name].toString());
			} else {
				return "";
			}
		},
		set: function(name,value) {config.options[name] = decodeCookie(value);}
	}
});

// need to reload options to load passwordOptions
loadOptionsCookie();

/*
if (!config.options['pasPassword'])
	config.options['pasPassword'] = '';

merge(config.optionsDesc,{
		pasPassword: "Test password"
	});
*/
//}}}
[[Solving a simple QSAT instance]]
[[Quantum circuits for the Laughlin wavefunction]]
/***
|Name|Plugin: Scientific Notation|
|Created by|BobMcElrath|
|Email|my first name at my last name dot org|
|Location|http://bob.mcelrath.org/tiddlyjsmath-2.0.3.html|
|Version|1.0|
|Requires|[[TiddlyWiki|http://www.tiddlywiki.com]] &ge; 2.0.3, [[jsMath|http://www.math.union.edu/~dpvc/jsMath/]] &ge; 3.0, [[Plugin: jsMath]]|
!Description
This plugin will render numbers expressed in scientific notation, such as {{{3.5483e12}}} using the jsMath plugin to display it in an intuitive way such as 3.5483e12.  You may customize the number of significant figures displayed, as well as "normalize" numbers so that {{{47392.387e9}}} is displayed as 47392.387e9.
!Installation
Install the Requirements, above, add this tiddler to your tiddlywiki, and give it the {{{systemConfig}}} tag.
!History
* 1-Feb-06, version 1.0, Initial release
!Code
***/
//{{{
config.formatters.push({
  name: "scientificNotation",
  match: "\\b[0-9]+\\.[0-9]+[eE][+-]?[0-9]+\\b",
  element: "span",
  className: "math",
  normalize: true,                          // set to 'true' to convert numbers to X.XXX \times 10^{y}
  sigfigs: 3,                               // with this many digits in the mantissa
  handler: function(w) {
    var snRegExp = new RegExp("\\b([0-9]+(?:\\.[0-9]+)?)[eE]([-0-9+]+)\\b");
    var mymatch = snRegExp.exec(w.matchText);
    var mantissa = mymatch[1];
    var exponent = parseInt(mymatch[2]);
    // normalize the number.
    if(this.normalize) {
      mantissa = parseFloat(mantissa);
      while(mantissa > 10.0) {
        mantissa = mantissa / 10.0;
        exponent++; 
      }
      while(mantissa < 1.0) {
        mantissa = mantissa * 10.0;
        exponent--;
      }
      var sigfigsleft = this.sigfigs;
      mantissa = parseInt(mantissa) + "." + (Math.round(Math.pow(10,this.sigfigs-1)*mantissa)+"").substr(1,this.sigfigs-1);
    }
    var e = document.createElement(this.element);
    e.className = this.className;
    if(exponent == 0) {
      e.appendChild(document.createTextNode(mantissa));
    } else {
      e.appendChild(document.createTextNode(mantissa + "\\times 10^{" + exponent + "}"));
    }
    w.output.appendChild(e);
  }
});
//}}}
/***
|Name|Plugin: arXiv Links|
|Created by|BobMcElrath|
|Email|my first name at my last name dot org|
|Location|http://bob.mcelrath.org/tiddlyjsmath-2.0.3.html|
|Version|1.0|
|Requires|[[TiddlyWiki|http://www.tiddlywiki.com]] &ge; 2.0.3|
!Description
This formatting plugin will render links to the [[arXiv|http://www.arxiv.org]] preprint system.  If you type a paper reference such as hep-ph/0509024, it will be rendered as an external link to the abstract of that paper.
!Installation
Add this tiddler to your tiddlywiki, and give it the {{{systemConfig}}} tag.
!History
* 1-Feb-06, version 1.0, Initial release
!Code
***/
//{{{
config.formatters.push({
  name: "arXivLinks",
  match: "\\b(?:astro-ph|cond-mat|hep-ph|hep-th|hep-lat|gr-qc|nucl-ex|nucl-th|quant-ph|(?:cs|math|nlin|physics|q-bio)(?:\\.[A-Z]{2})?)/[0-9]{7}\\b",
  element: "a",
  handler: function(w) {
    var e = createExternalLink(w.output, "http://arxiv.org/abs/"+w.matchText);
    e.target = "_blank"; // open in new window
    w.outputText(e,w.matchStart,w.nextMatch);
  }
});
//}}}
/***
|Name|Plugin: jsMath|
|Created by|BobMcElrath|
|Email|my first name at my last name dot org|
|Location|http://bob.mcelrath.org/tiddlyjsmath.html|
|Version|1.5.1|
|Requires|[[TiddlyWiki|http://www.tiddlywiki.com]] &ge; 2.0.3, [[jsMath|http://www.math.union.edu/~dpvc/jsMath/]] &ge; 3.0|
!Description
LaTeX is the world standard for specifying, typesetting, and communicating mathematics among scientists, engineers, and mathematicians.  For more information about LaTeX itself, visit the [[LaTeX Project|http://www.latex-project.org/]].  This plugin typesets math using [[jsMath|http://www.math.union.edu/~dpvc/jsMath/]], which is an implementation of the TeX math rules and typesetting in javascript, for your browser.  Notice the small button in the lower right corner which opens its control panel.
!Installation
In addition to this plugin, you must also [[install jsMath|http://www.math.union.edu/~dpvc/jsMath/download/jsMath.html]] on the same server as your TiddlyWiki html file.  If you're using TiddlyWiki without a web server, then the jsMath directory must be placed in the same location as the TiddlyWiki html file.

I also recommend modifying your StyleSheet use serif fonts that are slightly larger than normal, so that the math matches surrounding text, and \\small fonts are not unreadable (as in exponents and subscripts).
{{{
.viewer {
  line-height: 125%;
  font-family: serif;
  font-size: 12pt;
}
}}}

If you had used a previous version of [[Plugin: jsMath]], it is no longer necessary to edit the main tiddlywiki.html file to add the jsMath <script> tag.  [[Plugin: jsMath]] now uses ajax to load jsMath.
!History
* 11-Nov-05, version 1.0, Initial release
* 22-Jan-06, version 1.1, updated for ~TW2.0, tested with jsMath 3.1, editing tiddlywiki.html by hand is no longer necessary.
* 24-Jan-06, version 1.2, fixes for Safari, Konqueror
* 27-Jan-06, version 1.3, improved error handling, detect if ajax was already defined (used by ZiddlyWiki)
* 12-Jul-06, version 1.4, fixed problem with not finding image fonts
* 26-Feb-07, version 1.5, fixed problem with Mozilla "unterminated character class".
* 27-Feb-07, version 1.5.1, Runs compatibly with TW 2.1.0+, by Bram Chen
!Examples
|!Source|!Output|h
|{{{The variable $x$ is real.}}}|The variable $x$ is real.|
|{{{The variable \(y\) is complex.}}}|The variable \(y\) is complex.|
|{{{This \[\int_a^b x = \frac{1}{2}(b^2-a^2)\] is an easy integral.}}}|This \[\int_a^b x = \frac{1}{2}(b^2-a^2)\] is an easy integral.|
|{{{This $$\int_a^b \sin x = -(\cos b - \cos a)$$ is another easy integral.}}}|This $$\int_a^b \sin x = -(\cos b - \cos a)$$ is another easy integral.|
|{{{Block formatted equations may also use the 'equation' environment \begin{equation}  \int \tan x = -\ln \cos x \end{equation} }}}|Block formatted equations may also use the 'equation' environment \begin{equation}  \int \tan x = -\ln \cos x \end{equation}|
|{{{Equation arrays are also supported \begin{eqnarray} a &=& b \\ c &=& d \end{eqnarray} }}}|Equation arrays are also supported \begin{eqnarray} a &=& b \\ c &=& d \end{eqnarray} |
|{{{I spent \$7.38 on lunch.}}}|I spent \$7.38 on lunch.|
|{{{I had to insert a backslash (\\) into my document}}}|I had to insert a backslash (\\) into my document|
!Code
***/
//{{{

// AJAX code adapted from http://timmorgan.org/mini
// This is already loaded by ziddlywiki...
if(typeof(window["ajax"]) == "undefined") {
  ajax = {
      x: function(){try{return new ActiveXObject('Msxml2.XMLHTTP')}catch(e){try{return new ActiveXObject('Microsoft.XMLHTTP')}catch(e){return new XMLHttpRequest()}}},
      gets: function(url){var x=ajax.x();x.open('GET',url,false);x.send(null);return x.responseText}
  }
}

// Load jsMath
jsMath = {
  Setup: {inited: 1},          // don't run jsMath.Setup.Body() yet
  Autoload: {root: new String(document.location).replace(/[^\/]*$/,'jsMath/')}  // URL to jsMath directory, change if necessary
};
var jsMathstr;
try {
  jsMathstr = ajax.gets(jsMath.Autoload.root+"jsMath.js");
} catch(e) {
  alert("jsMath was not found: you must place the 'jsMath' directory in the same place as this file.  "
       +"The error was:\n"+e.name+": "+e.message);
  throw(e);  // abort eval
}
try {
  window.eval(jsMathstr);
} catch(e) {
  alert("jsMath failed to load.  The error was:\n"+e.name + ": " + e.message + " on line " + e.lineNumber);
}
jsMath.Setup.inited=0;  //  allow jsMath.Setup.Body() to run again

// Define wikifers for latex
config.formatterHelpers.mathFormatHelper = function(w) {
    var e = document.createElement(this.element);
    e.className = this.className;
    var endRegExp = new RegExp(this.terminator, "mg");
    endRegExp.lastIndex = w.matchStart+w.matchLength;
    var matched = endRegExp.exec(w.source);
    if(matched) {
        var txt = w.source.substr(w.matchStart+w.matchLength, 
            matched.index-w.matchStart-w.matchLength);
        if(this.keepdelim) {
          txt = w.source.substr(w.matchStart, matched.index+matched[0].length-w.matchStart);
        }
        e.appendChild(document.createTextNode(txt));
        w.output.appendChild(e);
        w.nextMatch = endRegExp.lastIndex;
    }
}

config.formatters.push({
  name: "displayMath1",
  match: "\\\$\\\$",
  terminator: "\\\$\\\$\\n?", // 2.0 compatability
  termRegExp: "\\\$\\\$\\n?",
  element: "div",
  className: "math",
  handler: config.formatterHelpers.mathFormatHelper
});

config.formatters.push({
  name: "inlineMath1",
  match: "\\\$", 
  terminator: "\\\$", // 2.0 compatability
  termRegExp: "\\\$",
  element: "span",
  className: "math",
  handler: config.formatterHelpers.mathFormatHelper
});

var backslashformatters = new Array(0);

backslashformatters.push({
  name: "inlineMath2",
  match: "\\\\\\\(",
  terminator: "\\\\\\\)", // 2.0 compatability
  termRegExp: "\\\\\\\)",
  element: "span",
  className: "math",
  handler: config.formatterHelpers.mathFormatHelper
});

backslashformatters.push({
  name: "displayMath2",
  match: "\\\\\\\[",
  terminator: "\\\\\\\]\\n?", // 2.0 compatability
  termRegExp: "\\\\\\\]\\n?",
  element: "div",
  className: "math",
  handler: config.formatterHelpers.mathFormatHelper
});

backslashformatters.push({
  name: "displayMath3",
  match: "\\\\begin\\{equation\\}",
  terminator: "\\\\end\\{equation\\}\\n?", // 2.0 compatability
  termRegExp: "\\\\end\\{equation\\}\\n?",
  element: "div",
  className: "math",
  handler: config.formatterHelpers.mathFormatHelper
});

// These can be nested.  e.g. \begin{equation} \begin{array}{ccc} \begin{array}{ccc} ...
backslashformatters.push({
  name: "displayMath4",
  match: "\\\\begin\\{eqnarray\\}",
  terminator: "\\\\end\\{eqnarray\\}\\n?", // 2.0 compatability
  termRegExp: "\\\\end\\{eqnarray\\}\\n?",
  element: "div",
  className: "math",
  keepdelim: true,
  handler: config.formatterHelpers.mathFormatHelper
});

// The escape must come between backslash formatters and regular ones.
// So any latex-like \commands must be added to the beginning of
// backslashformatters here.
backslashformatters.push({
    name: "escape",
    match: "\\\\.",
    handler: function(w) {
        w.output.appendChild(document.createTextNode(w.source.substr(w.matchStart+1,1)));
        w.nextMatch = w.matchStart+2;
    }
});

config.formatters=backslashformatters.concat(config.formatters);

window.wikify = function(source,output,highlightRegExp,tiddler)
{
    if(source && source != "") {
        if(version.major == 2 && version.minor > 0) {
            var wikifier = new Wikifier(source,getParser(tiddler),highlightRegExp,tiddler);
            wikifier.subWikifyUnterm(output);
        } else {
            var wikifier = new Wikifier(source,formatter,highlightRegExp,tiddler);
            wikifier.subWikify(output,null);
        }
        jsMath.ProcessBeforeShowing();
    }
}
//}}}
[[Computer science problems]]
[[Mathematics problems]]
[[Physics problems]]
[[Miscellaneous problems]]
!Introduction
In a recent paper [[arXiv:0902.4797|http://arxiv.org/abs/0902.4797]] Riera, Pico, and Latorre describe a quantum circuit which efficiently prepares a quantum register in the integer quantum Hall effect ground state. 
An open problem from this paper is to describe quantum circuits which efficiently prepare the Laughlin wavefunction for the fractional quantum Hall effect. This problem is significantly more complicated than the integer quantum Hall effect case because there are delicate cancellations that can occur and must be accounted for.
!Sequential generation
One might hope to build a quantum circuit for the Laughlin wavefunction //sequentially//. To do this one needs to have some kind of recursion relation. 
!!Representing the Laughlin function in a quantum register
The way we represent a multiparticle wavefunction in a quantum register is to use a basis where a monomial multiplied by a gaussian weighting: 
$$
z_1^{d_1}z_2^{d_2}\cdots z_n^{d_n} e^{-\frac12\sum_{j=1}^n |z_j|^2}
$$ 
is represented as
$$
|d_1d_2\cdots d_n\rangle.
$$
Because the gaussian weighting is the same for all terms in the wavefunctions we wish to represent we typically drop it from now on and just speak of the //monomial// $z_1^{d_1}z_2^{d_2}\cdots z_n^{d_n}$ as being represented by $|d_1d_2\cdots d_n\rangle$.
!!A simple recursion relation for the Vandermonde determinant 
A nice recursion relation is described in the [[paper|http://arxiv.org/abs/cond-mat/9306022]] of Dunne, who notes the following properties of the Vandermonde determinant: let 
$$
V_n(z_1, z_2, \ldots, z_n) = \prod_{1\le j<k}^n(z_j-z_k).
$$
Note that
$$
V_n(z_1, z_2, \ldots, z_n) = V_{n-1}(z_2, z_3, \ldots, z_n)\prod_{j=2}^n(z_1-z_j).
$$
We now write 
$$
\prod_{j=2}^n(z_1-z_j) = \sum_{k=0}^{n-1} (-1)^kz^{n-1-k}e_k,
$$
where $e_0 = 1$, $e_1 = \sum_{k=2}^n z_k$, $\ldots$, $e_{n-1} = z_2z_3\cdots z_{n}$, i.e., $e_l$ is the sum of all products of $l$ distinct variables $z_2, z_3, \ldots, z_n$.
This observation now allows us to write out the desired recursion:
$$
(V_n(z_1, z_2, \ldots, z_n))^{2m+1} = \left(\sum_{k=0}^{n-1} (-1)^kz^{n-1-k}e_k\right)^{2m+1}(V_{n-1}(z_2, z_3, \ldots, z_n))^{2m+1}.
$$
!!An example for $m=1$
Let's consider the simplest case, namely $V_2(z_1, z_2)$: this is represented as
$$
V_2(z_1, z_2) = (z_1-z_2) \mapsto \frac{1}{\sqrt{2}}(|10\rangle-|01\rangle).
$$
Now the Laughlin wavefunction with $m=1$ is represented as
$$
(V_2(z_1, z_2))^3 = (z_1-z_2)^3 \mapsto \frac{1}{\sqrt{20}}(|30\rangle - 3|21\rangle + 3|12\rangle - |03\rangle).
$$
Introducing the linear operator
$$
L_{j,k}|x_1x_2\cdots x_n\rangle = |x_1x_2\cdots x_{j-1} (x_j+k) x_{j+1} \cdots x_n\rangle
$$
allows us to also write
$$
(V_2(z_1, z_2))^3 \mapsto (L_{1,2} - 2L_{1,1}L_{2,1} + L_{2,2}) \times \frac{1}{\sqrt{2}}(|10\rangle-|01\rangle).
$$
It is convenient to adopt a multi-index notation and define
$$
L_{\mu}|x_1x_2\cdots x_n\rangle = |(x_1+\mu_1)(x_2+\mu_2)\cdots(x_n+\mu_n)\rangle
$$
where $\mu = (\mu_1, \mu_2, \ldots, \mu_n)$. Thus
$$
(V_2(z_1, z_2))^3 \mapsto (L_{(2,0)} - 2L_{(1,1)} + L_{(0,2)}) \times \frac{1}{\sqrt{2}}(|10\rangle-|01\rangle).
$$
!!A nonunitary(!) quantum circuit for the Laughline wavefunction
The recursion relation for the Vandermonde determinant can now be represented, in quantum notation, as
$$
|V_n\rangle = \sum_{k=0}^{n-1} (-1)^k|n-1-k\rangle E_k|V_{n-1}\rangle,
$$
where 
$$
|V_n\rangle = \frac{1}{\sqrt{n!}} \sum_{\pi\in S_n} \epsilon(\pi)|\pi^{-1}(0)\pi^{-1}(1)\cdots \pi^{-1}(n-1)\rangle
$$ 
is the quantum representation of the Vandermonde determinant, and
$$
E_k = \sum_{\mu\subset \{0,1,\ldots, n-1\},  |\mu| = k} L_\mu
$$
Cubing this recursion in the obvious way gives a //nonunitary// circuit for the $m=1$ Laughlin wavefunction. Unfortunately the operators $E_k$ aren't unitary, so this is why the problem is hard.
In the paper quant-ph/0602108 Sergey Bravyi introduced a class of systems which are aimed at generalising the [[satisfiability|http://en.wikipedia.org/wiki/Boolean_satisfiability_problem]] problem. 

The idea is to replace a $k$-SAT instance, by a quantum hamiltonian 
$$
H = -\sum_{e\in E} h_e,
$$
where each of $h_e$ is a //projector// onto some subspace whose [[support]] is bounded by $k$. 
non-linear notes on my research
Tobias J. Osborne's research notes
The [[approach|Entanglement remote-control and deciding QSAT]] to deciding [[QSAT|Quantum satisfiability]] instances via [[entanglement remote-control|Entanglement remote-control]] reduces the problem of first finding the ground-eigenspace of hamiltonians of the form
$$
H = \sum_{e\in E} |\Psi^{+}\rangle_e\langle \Psi^{+}|\otimes \mathbb{I}_{[n]\setminus e},
$$
where $|\Psi^+\rangle = \frac{1}{\sqrt{d}}\sum_{j=1}^d |jj\rangle$ and $E$ is the edge set of some finite //tree//-graph $G = (V=[n], E)$ with $[n]=\{1,2,\ldots, n\}$. The second step is to add in extra constraints to form loops. 

I'll focus on solving the first problem. In fact, I'll just try and describe the ground eigenspace for the simplest possible example, namely, the following hamiltonian on 3 qudits
$$
H = |\Psi^{+}\rangle_{12}\langle \Psi^{+}|\otimes \mathbb{I}_3 + \mathbb{I}_1\otimes |\Psi^{+}\rangle_{23}\langle \Psi^{+}|.
$$
It's pretty easy to find quite a lot of states in the ground eigenspace: any state of the form $|jkl\rangle$ with $j\not=k$ and $k\not=l$, $j,k,l \in [d]$ will do. How many of these are there? Well, there are $d^3-2d^2+d$ such states. Are these all the ground states? Well, no, there are a couple more, namely, any state of the form
$$
|\eta(k)\rangle = \frac{1}{\sqrt{d}}\sum_{j=1}^d e^{\frac{2\pi i}{d}jk} |jjj\rangle,
$$
with $k\in [d-1]$ is also a ground state. There are $d-1$ such states. Thus there are at least $d^3-2d^2+1$ orthogonal ground states. Is this all of them? There should be more because the smallest the ground eigenspace can be is $d^3-2d$-dimensional.
!Introduction
The [[Davidenko equation]] is a system of differential equations which track the zeros of parameter-dependent system of polynomials. This note is aimed at understanding what happens when the polynomials depend on one or more [[continuous-time martingales|Continuous-time martingale]], such as simple [[brownian motions|Brownian motion]]. 

!Simple example
(This needs to be fixed: the second order terms aren't correct yet!)
To understand what I'm talking about let's derive the stochastic Davidenko equation in the case of a parameter-dependent polynomial in one variable. Note that this discussion is at the level of [[physical rigour]].
Let $p(x) = \sum_{j=0}^d a_j(B_t, t) x^j$ be a polynomial of degree $d$ whose coefficients $a_j$ are functions of $B_t$ and $t$, where $B_t$ is a [[Wiener process]], i.e., a standard [[Brownian motion]]. We want to understand the zeros $z_l(B_t, t)$, $l = 1, 2, \ldots, d$ of $p(x)$. To do this we mimic the derivation of the [[Davidenko equation]] and set up a set of [[Stochastic differential equations|Stochastic differential equation]] for $z_l(B_t,t)$. As with the [[Davidenko equation]] this can be done in a variety of ways. 
Consider a small change in $p(x)$:
$$
dp(x) = \sum_{j=0}^d da_j(B_t,t) x^j + ja_j(B_t,t)x^{j-1} dx + jx^{j-1}da_j(B_t,t)dx + j(j-1)a_j(B_t,t)x^{j-2}(dx)^2.
$$
(Here we are foreshadowing the use of [[Itō's rule]].) 
Now use [[Itō's rule]] to write
$$
da_j(B_t,t) = \frac{\partial a_j(y,t)}{\partial t}\Bigg|_{y=B_t} dt + \frac{\partial a_j(y,t)}{\partial y}\Bigg|_{y=B_t} dB_t + \frac12\frac{\partial^2 a_j(y,t)}{\partial^2 y}\Bigg|_{y=B_t}dt
$$
for the SDE satisfied by $a_j(B_t,t)$. Then we have that
$$
dp(x) = \sum_{j=0}^d \left(\frac{\partial a_j(y,t)}{\partial t}\Bigg|_{y=B_t} dt + \frac{\partial a_j(y,t)}{\partial y}\Bigg|_{y=B_t} dB_t + \frac12\frac{\partial^2 a_j(y,t)}{\partial^2 y}\Bigg|_{y=B_t}dt\right) x^j + ja_j(B_t,t)x^{j-1} dx + j(j-1)a_j(B_t,t)x^{j-2}(dx)^2.
$$
Now if $z_l(B_t, t)$ is a zero of $p(x)$ then we must have that $0 = dp(z_l(B_t, t))$, i.e., 
$$
0= \sum_{j=0}^d \left(\frac{\partial a_j(y,t)}{\partial t}\Bigg|_{y=B_t} dt + \frac{\partial a_j(y,t)}{\partial y}\Bigg|_{y=B_t} dB_t + \frac12\frac{\partial^2 a_j(y,t)}{\partial^2 y}\Bigg|_{y=B_t}dt\right) z_l(B_t, t)^j + ja_j(B_t,t)z_l(B_t, t)^{j-1} dz_l(B_t, t) + j(j-1)a_j(B_t,t)z_l(B_t,t)^{j-2}(dz_l(B_t,t))^2.
$$
This is the stochastic Davidenko equation.
!!A small example polynomial
Suppose that 
$$
p(x) = x^2+B_tx-1.
$$
Thus, $a_0 = -1$, $a_1 = B_t$, and $a_2 = 1$. In this case the stochastic Davidenko equation becomes
$$
z_l(B_t,t)dB_t + (2z_l(B_t,t) + B_t)dz_l(B_t,t) = 0,
$$
or
$$
dz_l(B_t,t) = - \frac{z_l(B_t,t)}{2z_l(B_t,t) + B_t} dB_t.
$$
!2009
[[Notes on talk for IMA conference at IMS]]
The simulation problem aims to formalise in a concrete way what a theoretical physicist does when they make a prediction about a physical system. I would argue that the simulation problem is the central problem of the newly emerging field of [[hamiltonian complexity]].
I am a lecturer in the [[department of mathematics|http://www.ma.rhul.ac.uk/]] at Royal Holloway, University of London.

I am currently exploring the possibilities offered by [[open science|http://en.wikipedia.org/wiki/Open_notebook_science]] via this TiddlyWiki and my [[blog|http://tjoresearchnotes.wordpress.com/]].
/***
Description: Contains the stuff you need to use Tiddlyspot
Note, you also need UploadPlugin, PasswordOptionPlugin and LoadRemoteFileThroughProxy
from http://tiddlywiki.bidix.info for a complete working Tiddlyspot site.
***/
//{{{

// edit this if you are migrating sites or retrofitting an existing TW
config.tiddlyspotSiteId = 'tjoresearchnotes';

// make it so you can by default see edit controls via http
config.options.chkHttpReadOnly = false;
window.readOnly = false; // make sure of it (for tw 2.2)
window.showBackstage = true; // show backstage too

// disable autosave in d3
if (window.location.protocol != "file:")
	config.options.chkGTDLazyAutoSave = false;

// tweak shadow tiddlers to add upload button, password entry box etc
with (config.shadowTiddlers) {
	SiteUrl = 'http://'+config.tiddlyspotSiteId+'.tiddlyspot.com';
	SideBarOptions = SideBarOptions.replace(/(<<saveChanges>>)/,"$1<<tiddler TspotSidebar>>");
	OptionsPanel = OptionsPanel.replace(/^/,"<<tiddler TspotOptions>>");
	DefaultTiddlers = DefaultTiddlers.replace(/^/,"[[WelcomeToTiddlyspot]] ");
	MainMenu = MainMenu.replace(/^/,"[[WelcomeToTiddlyspot]] ");
}

// create some shadow tiddler content
merge(config.shadowTiddlers,{

'WelcomeToTiddlyspot':[
 "This document is a ~TiddlyWiki from tiddlyspot.com.  A ~TiddlyWiki is an electronic notebook that is great for managing todo lists, personal information, and all sorts of things.",
 "",
 "@@font-weight:bold;font-size:1.3em;color:#444; //What now?// &nbsp;&nbsp;@@ Before you can save any changes, you need to enter your password in the form below.  Then configure privacy and other site settings at your [[control panel|http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/controlpanel]] (your control panel username is //" + config.tiddlyspotSiteId + "//).",
 "<<tiddler TspotControls>>",
 "See also GettingStarted.",
 "",
 "@@font-weight:bold;font-size:1.3em;color:#444; //Working online// &nbsp;&nbsp;@@ You can edit this ~TiddlyWiki right now, and save your changes using the \"save to web\" button in the column on the right.",
 "",
 "@@font-weight:bold;font-size:1.3em;color:#444; //Working offline// &nbsp;&nbsp;@@ A fully functioning copy of this ~TiddlyWiki can be saved onto your hard drive or USB stick.  You can make changes and save them locally without being connected to the Internet.  When you're ready to sync up again, just click \"upload\" and your ~TiddlyWiki will be saved back to tiddlyspot.com.",
 "",
 "@@font-weight:bold;font-size:1.3em;color:#444; //Help!// &nbsp;&nbsp;@@ Find out more about ~TiddlyWiki at [[TiddlyWiki.com|http://tiddlywiki.com]].  Also visit [[TiddlyWiki.org|http://tiddlywiki.org]] for documentation on learning and using ~TiddlyWiki. New users are especially welcome on the [[TiddlyWiki mailing list|http://groups.google.com/group/TiddlyWiki]], which is an excellent place to ask questions and get help.  If you have a tiddlyspot related problem email [[tiddlyspot support|mailto:support@tiddlyspot.com]].",
 "",
 "@@font-weight:bold;font-size:1.3em;color:#444; //Enjoy :)// &nbsp;&nbsp;@@ We hope you like using your tiddlyspot.com site.  Please email [[feedback@tiddlyspot.com|mailto:feedback@tiddlyspot.com]] with any comments or suggestions."
].join("\n"),

'TspotControls':[
 "| tiddlyspot password:|<<option pasUploadPassword>>|",
 "| site management:|<<upload http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/store.cgi index.html . .  " + config.tiddlyspotSiteId + ">>//(requires tiddlyspot password)//<br>[[control panel|http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/controlpanel]], [[download (go offline)|http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/download]]|",
 "| links:|[[tiddlyspot.com|http://tiddlyspot.com/]], [[FAQs|http://faq.tiddlyspot.com/]], [[blog|http://tiddlyspot.blogspot.com/]], email [[support|mailto:support@tiddlyspot.com]] & [[feedback|mailto:feedback@tiddlyspot.com]], [[donate|http://tiddlyspot.com/?page=donate]]|"
].join("\n"),

'TspotSidebar':[
 "<<upload http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/store.cgi index.html . .  " + config.tiddlyspotSiteId + ">><html><a href='http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/download' class='button'>download</a></html>"
].join("\n"),

'TspotOptions':[
 "tiddlyspot password:",
 "<<option pasUploadPassword>>",
 ""
].join("\n")

});
//}}}
| !date | !user | !location | !storeUrl | !uploadDir | !toFilename | !backupdir | !origin |
| 10/04/2009 17:04:38 | Tobias J. Osborne | [[/|http://tjoresearchnotes.tiddlyspot.com/]] | [[store.cgi|http://tjoresearchnotes.tiddlyspot.com/store.cgi]] | . | [[index.html | http://tjoresearchnotes.tiddlyspot.com/index.html]] | . |
| 10/04/2009 18:11:56 | Tobias J. Osborne | [[/|http://tjoresearchnotes.tiddlyspot.com/]] | [[store.cgi|http://tjoresearchnotes.tiddlyspot.com/store.cgi]] | . | [[index.html | http://tjoresearchnotes.tiddlyspot.com/index.html]] | . |
| 13/04/2009 23:22:27 | Tobias J. Osborne | [[/|http://tjoresearchnotes.tiddlyspot.com/]] | [[store.cgi|http://tjoresearchnotes.tiddlyspot.com/store.cgi]] | . | [[index.html | http://tjoresearchnotes.tiddlyspot.com/index.html]] | . |
| 14/04/2009 07:05:26 | Tobias J. Osborne | [[/|http://tjoresearchnotes.tiddlyspot.com/]] | [[store.cgi|http://tjoresearchnotes.tiddlyspot.com/store.cgi]] | . | [[index.html | http://tjoresearchnotes.tiddlyspot.com/index.html]] | . |
| 14/04/2009 17:13:10 | Tobias J. Osborne | [[/|http://tjoresearchnotes.tiddlyspot.com/]] | [[store.cgi|http://tjoresearchnotes.tiddlyspot.com/store.cgi]] | . | [[index.html | http://tjoresearchnotes.tiddlyspot.com/index.html]] | . | ok |
| 14/04/2009 17:13:38 | Tobias J. Osborne | [[/|http://tjoresearchnotes.tiddlyspot.com/]] | [[store.cgi|http://tjoresearchnotes.tiddlyspot.com/store.cgi]] | . | [[index.html | http://tjoresearchnotes.tiddlyspot.com/index.html]] | . |
| 17/04/2009 15:59:48 | Tobias J. Osborne | [[/|http://tjoresearchnotes.tiddlyspot.com/]] | [[store.cgi|http://tjoresearchnotes.tiddlyspot.com/store.cgi]] | . | [[index.html | http://tjoresearchnotes.tiddlyspot.com/index.html]] | . | ok |
| 17/04/2009 16:14:04 | Tobias J. Osborne | [[/|http://tjoresearchnotes.tiddlyspot.com/]] | [[store.cgi|http://tjoresearchnotes.tiddlyspot.com/store.cgi]] | . | [[index.html | http://tjoresearchnotes.tiddlyspot.com/index.html]] | . | ok |
| 17/04/2009 16:27:34 | Tobias J. Osborne | [[/|http://tjoresearchnotes.tiddlyspot.com/]] | [[store.cgi|http://tjoresearchnotes.tiddlyspot.com/store.cgi]] | . | [[index.html | http://tjoresearchnotes.tiddlyspot.com/index.html]] | . |
| 27/04/2009 15:43:06 | Tobias J. Osborne | [[/|http://tjoresearchnotes.tiddlyspot.com/]] | [[store.cgi|http://tjoresearchnotes.tiddlyspot.com/store.cgi]] | . | [[index.html | http://tjoresearchnotes.tiddlyspot.com/index.html]] | . |
/***
|''Name:''|UploadPlugin|
|''Description:''|Save to web a TiddlyWiki|
|''Version:''|4.1.3|
|''Date:''|Feb 24, 2008|
|''Source:''|http://tiddlywiki.bidix.info/#UploadPlugin|
|''Documentation:''|http://tiddlywiki.bidix.info/#UploadPluginDoc|
|''Author:''|BidiX (BidiX (at) bidix (dot) info)|
|''License:''|[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D ]]|
|''~CoreVersion:''|2.2.0|
|''Requires:''|PasswordOptionPlugin|
***/
//{{{
version.extensions.UploadPlugin = {
	major: 4, minor: 1, revision: 3,
	date: new Date("Feb 24, 2008"),
	source: 'http://tiddlywiki.bidix.info/#UploadPlugin',
	author: 'BidiX (BidiX (at) bidix (dot) info',
	coreVersion: '2.2.0'
};

//
// Environment
//

if (!window.bidix) window.bidix = {}; // bidix namespace
bidix.debugMode = false;	// true to activate both in Plugin and UploadService
	
//
// Upload Macro
//

config.macros.upload = {
// default values
	defaultBackupDir: '',	//no backup
	defaultStoreScript: "store.php",
	defaultToFilename: "index.html",
	defaultUploadDir: ".",
	authenticateUser: true	// UploadService Authenticate User
};
	
config.macros.upload.label = {
	promptOption: "Save and Upload this TiddlyWiki with UploadOptions",
	promptParamMacro: "Save and Upload this TiddlyWiki in %0",
	saveLabel: "save to web", 
	saveToDisk: "save to disk",
	uploadLabel: "upload"	
};

config.macros.upload.messages = {
	noStoreUrl: "No store URL in parmeters or options",
	usernameOrPasswordMissing: "Username or password missing"
};

config.macros.upload.handler = function(place,macroName,params) {
	if (readOnly)
		return;
	var label;
	if (document.location.toString().substr(0,4) == "http") 
		label = this.label.saveLabel;
	else
		label = this.label.uploadLabel;
	var prompt;
	if (params[0]) {
		prompt = this.label.promptParamMacro.toString().format([this.destFile(params[0], 
			(params[1] ? params[1]:bidix.basename(window.location.toString())), params[3])]);
	} else {
		prompt = this.label.promptOption;
	}
	createTiddlyButton(place, label, prompt, function() {config.macros.upload.action(params);}, null, null, this.accessKey);
};

config.macros.upload.action = function(params)
{
		// for missing macro parameter set value from options
		if (!params) params = {};
		var storeUrl = params[0] ? params[0] : config.options.txtUploadStoreUrl;
		var toFilename = params[1] ? params[1] : config.options.txtUploadFilename;
		var backupDir = params[2] ? params[2] : config.options.txtUploadBackupDir;
		var uploadDir = params[3] ? params[3] : config.options.txtUploadDir;
		var username = params[4] ? params[4] : config.options.txtUploadUserName;
		var password = config.options.pasUploadPassword; // for security reason no password as macro parameter	
		// for still missing parameter set default value
		if ((!storeUrl) && (document.location.toString().substr(0,4) == "http")) 
			storeUrl = bidix.dirname(document.location.toString())+'/'+config.macros.upload.defaultStoreScript;
		if (storeUrl.substr(0,4) != "http")
			storeUrl = bidix.dirname(document.location.toString()) +'/'+ storeUrl;
		if (!toFilename)
			toFilename = bidix.basename(window.location.toString());
		if (!toFilename)
			toFilename = config.macros.upload.defaultToFilename;
		if (!uploadDir)
			uploadDir = config.macros.upload.defaultUploadDir;
		if (!backupDir)
			backupDir = config.macros.upload.defaultBackupDir;
		// report error if still missing
		if (!storeUrl) {
			alert(config.macros.upload.messages.noStoreUrl);
			clearMessage();
			return false;
		}
		if (config.macros.upload.authenticateUser && (!username || !password)) {
			alert(config.macros.upload.messages.usernameOrPasswordMissing);
			clearMessage();
			return false;
		}
		bidix.upload.uploadChanges(false,null,storeUrl, toFilename, uploadDir, backupDir, username, password); 
		return false; 
};

config.macros.upload.destFile = function(storeUrl, toFilename, uploadDir) 
{
	if (!storeUrl)
		return null;
		var dest = bidix.dirname(storeUrl);
		if (uploadDir && uploadDir != '.')
			dest = dest + '/' + uploadDir;
		dest = dest + '/' + toFilename;
	return dest;
};

//
// uploadOptions Macro
//

config.macros.uploadOptions = {
	handler: function(place,macroName,params) {
		var wizard = new Wizard();
		wizard.createWizard(place,this.wizardTitle);
		wizard.addStep(this.step1Title,this.step1Html);
		var markList = wizard.getElement("markList");
		var listWrapper = document.createElement("div");
		markList.parentNode.insertBefore(listWrapper,markList);
		wizard.setValue("listWrapper",listWrapper);
		this.refreshOptions(listWrapper,false);
		var uploadCaption;
		if (document.location.toString().substr(0,4) == "http") 
			uploadCaption = config.macros.upload.label.saveLabel;
		else
			uploadCaption = config.macros.upload.label.uploadLabel;
		
		wizard.setButtons([
				{caption: uploadCaption, tooltip: config.macros.upload.label.promptOption, 
					onClick: config.macros.upload.action},
				{caption: this.cancelButton, tooltip: this.cancelButtonPrompt, onClick: this.onCancel}
				
			]);
	},
	options: [
		"txtUploadUserName",
		"pasUploadPassword",
		"txtUploadStoreUrl",
		"txtUploadDir",
		"txtUploadFilename",
		"txtUploadBackupDir",
		"chkUploadLog",
		"txtUploadLogMaxLine"		
	],
	refreshOptions: function(listWrapper) {
		var opts = [];
		for(i=0; i<this.options.length; i++) {
			var opt = {};
			opts.push();
			opt.option = "";
			n = this.options[i];
			opt.name = n;
			opt.lowlight = !config.optionsDesc[n];
			opt.description = opt.lowlight ? this.unknownDescription : config.optionsDesc[n];
			opts.push(opt);
		}
		var listview = ListView.create(listWrapper,opts,this.listViewTemplate);
		for(n=0; n<opts.length; n++) {
			var type = opts[n].name.substr(0,3);
			var h = config.macros.option.types[type];
			if (h && h.create) {
				h.create(opts[n].colElements['option'],type,opts[n].name,opts[n].name,"no");
			}
		}
		
	},
	onCancel: function(e)
	{
		backstage.switchTab(null);
		return false;
	},
	
	wizardTitle: "Upload with options",
	step1Title: "These options are saved in cookies in your browser",
	step1Html: "<input type='hidden' name='markList'></input><br>",
	cancelButton: "Cancel",
	cancelButtonPrompt: "Cancel prompt",
	listViewTemplate: {
		columns: [
			{name: 'Description', field: 'description', title: "Description", type: 'WikiText'},
			{name: 'Option', field: 'option', title: "Option", type: 'String'},
			{name: 'Name', field: 'name', title: "Name", type: 'String'}
			],
		rowClasses: [
			{className: 'lowlight', field: 'lowlight'} 
			]}
};

//
// upload functions
//

if (!bidix.upload) bidix.upload = {};

if (!bidix.upload.messages) bidix.upload.messages = {
	//from saving
	invalidFileError: "The original file '%0' does not appear to be a valid TiddlyWiki",
	backupSaved: "Backup saved",
	backupFailed: "Failed to upload backup file",
	rssSaved: "RSS feed uploaded",
	rssFailed: "Failed to upload RSS feed file",
	emptySaved: "Empty template uploaded",
	emptyFailed: "Failed to upload empty template file",
	mainSaved: "Main TiddlyWiki file uploaded",
	mainFailed: "Failed to upload main TiddlyWiki file. Your changes have not been saved",
	//specific upload
	loadOriginalHttpPostError: "Can't get original file",
	aboutToSaveOnHttpPost: 'About to upload on %0 ...',
	storePhpNotFound: "The store script '%0' was not found."
};

bidix.upload.uploadChanges = function(onlyIfDirty,tiddlers,storeUrl,toFilename,uploadDir,backupDir,username,password)
{
	var callback = function(status,uploadParams,original,url,xhr) {
		if (!status) {
			displayMessage(bidix.upload.messages.loadOriginalHttpPostError);
			return;
		}
		if (bidix.debugMode) 
			alert(original.substr(0,500)+"\n...");
		// Locate the storeArea div's 
		var posDiv = locateStoreArea(original);
		if((posDiv[0] == -1) || (posDiv[1] == -1)) {
			alert(config.messages.invalidFileError.format([localPath]));
			return;
		}
		bidix.upload.uploadRss(uploadParams,original,posDiv);
	};
	
	if(onlyIfDirty && !store.isDirty())
		return;
	clearMessage();
	// save on localdisk ?
	if (document.location.toString().substr(0,4) == "file") {
		var path = document.location.toString();
		var localPath = getLocalPath(path);
		saveChanges();
	}
	// get original
	var uploadParams = new Array(storeUrl,toFilename,uploadDir,backupDir,username,password);
	var originalPath = document.location.toString();
	// If url is a directory : add index.html
	if (originalPath.charAt(originalPath.length-1) == "/")
		originalPath = originalPath + "index.html";
	var dest = config.macros.upload.destFile(storeUrl,toFilename,uploadDir);
	var log = new bidix.UploadLog();
	log.startUpload(storeUrl, dest, uploadDir,  backupDir);
	displayMessage(bidix.upload.messages.aboutToSaveOnHttpPost.format([dest]));
	if (bidix.debugMode) 
		alert("about to execute Http - GET on "+originalPath);
	var r = doHttp("GET",originalPath,null,null,username,password,callback,uploadParams,null);
	if (typeof r == "string")
		displayMessage(r);
	return r;
};

bidix.upload.uploadRss = function(uploadParams,original,posDiv) 
{
	var callback = function(status,params,responseText,url,xhr) {
		if(status) {
			var destfile = responseText.substring(responseText.indexOf("destfile:")+9,responseText.indexOf("\n", responseText.indexOf("destfile:")));
			displayMessage(bidix.upload.messages.rssSaved,bidix.dirname(url)+'/'+destfile);
			bidix.upload.uploadMain(params[0],params[1],params[2]);
		} else {
			displayMessage(bidix.upload.messages.rssFailed);			
		}
	};
	// do uploadRss
	if(config.options.chkGenerateAnRssFeed) {
		var rssPath = uploadParams[1].substr(0,uploadParams[1].lastIndexOf(".")) + ".xml";
		var rssUploadParams = new Array(uploadParams[0],rssPath,uploadParams[2],'',uploadParams[4],uploadParams[5]);
		var rssString = generateRss();
		// no UnicodeToUTF8 conversion needed when location is "file" !!!
		if (document.location.toString().substr(0,4) != "file")
			rssString = convertUnicodeToUTF8(rssString);	
		bidix.upload.httpUpload(rssUploadParams,rssString,callback,Array(uploadParams,original,posDiv));
	} else {
		bidix.upload.uploadMain(uploadParams,original,posDiv);
	}
};

bidix.upload.uploadMain = function(uploadParams,original,posDiv) 
{
	var callback = function(status,params,responseText,url,xhr) {
		var log = new bidix.UploadLog();
		if(status) {
			// if backupDir specified
			if ((params[3]) && (responseText.indexOf("backupfile:") > -1))  {
				var backupfile = responseText.substring(responseText.indexOf("backupfile:")+11,responseText.indexOf("\n", responseText.indexOf("backupfile:")));
				displayMessage(bidix.upload.messages.backupSaved,bidix.dirname(url)+'/'+backupfile);
			}
			var destfile = responseText.substring(responseText.indexOf("destfile:")+9,responseText.indexOf("\n", responseText.indexOf("destfile:")));
			displayMessage(bidix.upload.messages.mainSaved,bidix.dirname(url)+'/'+destfile);
			store.setDirty(false);
			log.endUpload("ok");
		} else {
			alert(bidix.upload.messages.mainFailed);
			displayMessage(bidix.upload.messages.mainFailed);
			log.endUpload("failed");			
		}
	};
	// do uploadMain
	var revised = bidix.upload.updateOriginal(original,posDiv);
	bidix.upload.httpUpload(uploadParams,revised,callback,uploadParams);
};

bidix.upload.httpUpload = function(uploadParams,data,callback,params)
{
	var localCallback = function(status,params,responseText,url,xhr) {
		url = (url.indexOf("nocache=") < 0 ? url : url.substring(0,url.indexOf("nocache=")-1));
		if (xhr.status == 404)
			alert(bidix.upload.messages.storePhpNotFound.format([url]));
		if ((bidix.debugMode) || (responseText.indexOf("Debug mode") >= 0 )) {
			alert(responseText);
			if (responseText.indexOf("Debug mode") >= 0 )
				responseText = responseText.substring(responseText.indexOf("\n\n")+2);
		} else if (responseText.charAt(0) != '0') 
			alert(responseText);
		if (responseText.charAt(0) != '0')
			status = null;
		callback(status,params,responseText,url,xhr);
	};
	// do httpUpload
	var boundary = "---------------------------"+"AaB03x";	
	var uploadFormName = "UploadPlugin";
	// compose headers data
	var sheader = "";
	sheader += "--" + boundary + "\r\nContent-disposition: form-data; name=\"";
	sheader += uploadFormName +"\"\r\n\r\n";
	sheader += "backupDir="+uploadParams[3] +
				";user=" + uploadParams[4] +
				";password=" + uploadParams[5] +
				";uploaddir=" + uploadParams[2];
	if (bidix.debugMode)
		sheader += ";debug=1";
	sheader += ";;\r\n"; 
	sheader += "\r\n" + "--" + boundary + "\r\n";
	sheader += "Content-disposition: form-data; name=\"userfile\"; filename=\""+uploadParams[1]+"\"\r\n";
	sheader += "Content-Type: text/html;charset=UTF-8" + "\r\n";
	sheader += "Content-Length: " + data.length + "\r\n\r\n";
	// compose trailer data
	var strailer = new String();
	strailer = "\r\n--" + boundary + "--\r\n";
	data = sheader + data + strailer;
	if (bidix.debugMode) alert("about to execute Http - POST on "+uploadParams[0]+"\n with \n"+data.substr(0,500)+ " ... ");
	var r = doHttp("POST",uploadParams[0],data,"multipart/form-data; ;charset=UTF-8; boundary="+boundary,uploadParams[4],uploadParams[5],localCallback,params,null);
	if (typeof r == "string")
		displayMessage(r);
	return r;
};

// same as Saving's updateOriginal but without convertUnicodeToUTF8 calls
bidix.upload.updateOriginal = function(original, posDiv)
{
	if (!posDiv)
		posDiv = locateStoreArea(original);
	if((posDiv[0] == -1) || (posDiv[1] == -1)) {
		alert(config.messages.invalidFileError.format([localPath]));
		return;
	}
	var revised = original.substr(0,posDiv[0] + startSaveArea.length) + "\n" +
				store.allTiddlersAsHtml() + "\n" +
				original.substr(posDiv[1]);
	var newSiteTitle = getPageTitle().htmlEncode();
	revised = revised.replaceChunk("<title"+">","</title"+">"," " + newSiteTitle + " ");
	revised = updateMarkupBlock(revised,"PRE-HEAD","MarkupPreHead");
	revised = updateMarkupBlock(revised,"POST-HEAD","MarkupPostHead");
	revised = updateMarkupBlock(revised,"PRE-BODY","MarkupPreBody");
	revised = updateMarkupBlock(revised,"POST-SCRIPT","MarkupPostBody");
	return revised;
};

//
// UploadLog
// 
// config.options.chkUploadLog :
//		false : no logging
//		true : logging
// config.options.txtUploadLogMaxLine :
//		-1 : no limit
//      0 :  no Log lines but UploadLog is still in place
//		n :  the last n lines are only kept
//		NaN : no limit (-1)

bidix.UploadLog = function() {
	if (!config.options.chkUploadLog) 
		return; // this.tiddler = null
	this.tiddler = store.getTiddler("UploadLog");
	if (!this.tiddler) {
		this.tiddler = new Tiddler();
		this.tiddler.title = "UploadLog";
		this.tiddler.text = "| !date | !user | !location | !storeUrl | !uploadDir | !toFilename | !backupdir | !origin |";
		this.tiddler.created = new Date();
		this.tiddler.modifier = config.options.txtUserName;
		this.tiddler.modified = new Date();
		store.addTiddler(this.tiddler);
	}
	return this;
};

bidix.UploadLog.prototype.addText = function(text) {
	if (!this.tiddler)
		return;
	// retrieve maxLine when we need it
	var maxLine = parseInt(config.options.txtUploadLogMaxLine,10);
	if (isNaN(maxLine))
		maxLine = -1;
	// add text
	if (maxLine != 0) 
		this.tiddler.text = this.tiddler.text + text;
	// Trunck to maxLine
	if (maxLine >= 0) {
		var textArray = this.tiddler.text.split('\n');
		if (textArray.length > maxLine + 1)
			textArray.splice(1,textArray.length-1-maxLine);
			this.tiddler.text = textArray.join('\n');		
	}
	// update tiddler fields
	this.tiddler.modifier = config.options.txtUserName;
	this.tiddler.modified = new Date();
	store.addTiddler(this.tiddler);
	// refresh and notifiy for immediate update
	story.refreshTiddler(this.tiddler.title);
	store.notify(this.tiddler.title, true);
};

bidix.UploadLog.prototype.startUpload = function(storeUrl, toFilename, uploadDir,  backupDir) {
	if (!this.tiddler)
		return;
	var now = new Date();
	var text = "\n| ";
	var filename = bidix.basename(document.location.toString());
	if (!filename) filename = '/';
	text += now.formatString("0DD/0MM/YYYY 0hh:0mm:0ss") +" | ";
	text += config.options.txtUserName + " | ";
	text += "[["+filename+"|"+location + "]] |";
	text += " [[" + bidix.basename(storeUrl) + "|" + storeUrl + "]] | ";
	text += uploadDir + " | ";
	text += "[[" + bidix.basename(toFilename) + " | " +toFilename + "]] | ";
	text += backupDir + " |";
	this.addText(text);
};

bidix.UploadLog.prototype.endUpload = function(status) {
	if (!this.tiddler)
		return;
	this.addText(" "+status+" |");
};

//
// Utilities
// 

bidix.checkPlugin = function(plugin, major, minor, revision) {
	var ext = version.extensions[plugin];
	if (!
		(ext  && 
			((ext.major > major) || 
			((ext.major == major) && (ext.minor > minor))  ||
			((ext.major == major) && (ext.minor == minor) && (ext.revision >= revision))))) {
			// write error in PluginManager
			if (pluginInfo)
				pluginInfo.log.push("Requires " + plugin + " " + major + "." + minor + "." + revision);
			eval(plugin); // generate an error : "Error: ReferenceError: xxxx is not defined"
	}
};

bidix.dirname = function(filePath) {
	if (!filePath) 
		return;
	var lastpos;
	if ((lastpos = filePath.lastIndexOf("/")) != -1) {
		return filePath.substring(0, lastpos);
	} else {
		return filePath.substring(0, filePath.lastIndexOf("\\"));
	}
};

bidix.basename = function(filePath) {
	if (!filePath) 
		return;
	var lastpos;
	if ((lastpos = filePath.lastIndexOf("#")) != -1) 
		filePath = filePath.substring(0, lastpos);
	if ((lastpos = filePath.lastIndexOf("/")) != -1) {
		return filePath.substring(lastpos + 1);
	} else
		return filePath.substring(filePath.lastIndexOf("\\")+1);
};

bidix.initOption = function(name,value) {
	if (!config.options[name])
		config.options[name] = value;
};

//
// Initializations
//

// require PasswordOptionPlugin 1.0.1 or better
bidix.checkPlugin("PasswordOptionPlugin", 1, 0, 1);

// styleSheet
setStylesheet('.txtUploadStoreUrl, .txtUploadBackupDir, .txtUploadDir {width: 22em;}',"uploadPluginStyles");

//optionsDesc
merge(config.optionsDesc,{
	txtUploadStoreUrl: "Url of the UploadService script (default: store.php)",
	txtUploadFilename: "Filename of the uploaded file (default: in index.html)",
	txtUploadDir: "Relative Directory where to store the file (default: . (downloadService directory))",
	txtUploadBackupDir: "Relative Directory where to backup the file. If empty no backup. (default: ''(empty))",
	txtUploadUserName: "Upload Username",
	pasUploadPassword: "Upload Password",
	chkUploadLog: "do Logging in UploadLog (default: true)",
	txtUploadLogMaxLine: "Maximum of lines in UploadLog (default: 10)"
});

// Options Initializations
bidix.initOption('txtUploadStoreUrl','');
bidix.initOption('txtUploadFilename','');
bidix.initOption('txtUploadDir','');
bidix.initOption('txtUploadBackupDir','');
bidix.initOption('txtUploadUserName','');
bidix.initOption('pasUploadPassword','');
bidix.initOption('chkUploadLog',true);
bidix.initOption('txtUploadLogMaxLine','10');


// Backstage
merge(config.tasks,{
	uploadOptions: {text: "upload", tooltip: "Change UploadOptions and Upload", content: '<<uploadOptions>>'}
});
config.backstageTasks.push("uploadOptions");


//}}}