<p>

Here is some simple mathematics:

<p>

$latex 
f(x) = \frac{1}{1 + x^2},
 $

$latex 
f'(x)  =-\frac{2x}{(1+x^2)^2}

 $


which can be implemented in a computer code:

<p>



<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">f</span>(x):
    <span style="color: #BA2121; font-style: italic">&quot;&quot;&quot;Runge&#39;s function.&quot;&quot;&quot;</span>
    <span style="color: #008000; font-weight: bold">return</span> <span style="color: #666666">1/</span>(<span style="color: #666666">1</span> <span style="color: #666666">+</span> x<span style="color: #666666">**2</span>)

<span style="color: #408080; font-style: italic"># Plot f</span>
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">matplotlib.pyplot</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">plt</span>
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
xcoor <span style="color: #666666">=</span> np<span style="color: #666666">.</span>linspace(<span style="color: #666666">-3</span>, <span style="color: #666666">3</span>, <span style="color: #666666">101</span>)
ycoor <span style="color: #666666">=</span> f(xcoor)
plt<span style="color: #666666">.</span>plot(xcoor, ycoor)
plt<span style="color: #666666">.</span>savefig(<span style="color: #BA2121">&#39;f_plot.png&#39;</span>)

<span style="color: #408080; font-style: italic"># Compute f&#39;(x) symbolically and make a Python function out of it</span>
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">sympy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">sm</span>
x <span style="color: #666666">=</span> sm<span style="color: #666666">.</span>Symbol(<span style="color: #BA2121">&#39;x&#39;</span>)
f_expr <span style="color: #666666">=</span> f(x)
<span style="color: #008000; font-weight: bold">print</span> f_expr
df_expr <span style="color: #666666">=</span> sm<span style="color: #666666">.</span>diff(f_expr, x)
<span style="color: #008000; font-weight: bold">print</span> df_expr
df <span style="color: #666666">=</span> sm<span style="color: #666666">.</span>lambdify(x, df_expr)  <span style="color: #408080; font-style: italic"># turn expression into Python function</span>

<span style="color: #408080; font-style: italic"># Plot f&#39;(x)</span>
plt<span style="color: #666666">.</span>figure()
plt<span style="color: #666666">.</span>plot(xcoor, df(xcoor))
plt<span style="color: #666666">.</span>savefig(<span style="color: #BA2121">&#39;df_plot.png&#39;</span>)
plt<span style="color: #666666">.</span>show()
</pre></div>
<p>

A plot of the function $latex f(x)$

appears below.

<p>
<center><p><img src="https://doconce.googlecode.com/hg/doc/blog/f_plot.png" align="bottom" width=400></p></center>

<p>
Here is the derivative $latex f'(x)$ (with figure caption and label, which enables
referring to the figure later):

<p>

<center> <! -- figure -->
<hr class="figure">
<center><p class="caption">Figure 1:  The derivative of Runge's function. <a name="fig:Runge:dfdx"></a> </p></center>
<p><img src="https://doconce.googlecode.com/hg/doc/blog/df_plot.png" align="bottom" width=400></p>
</center>

<p>

Movies can also be embedded:

<p>

<iframe width="420" height="315" src="http://www.youtube.com/embed/75Ju0eM5T2c" frameborder="0" allowfullscreen></iframe>


<p>
The elements above are generated by the following
<a href="http://code.google.com/p/doconce">Doconce</a> code.

<p>



<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%">Here is some simple mathematics:

!bt
\begin{align}
f(x) &amp;= \frac{1}{1 + x^2},
label{eq:f}\\
f&#39;(x) &amp; =-\frac{2x}{(1+x^2)^2}
label{eq:df}
\end{align}
!et
which can be implemented in a computer code:

@@@CODE Runges_func.py

A plot of the function $f(x)$

appears below.

FIGURE: [https://doconce.googlecode.com/hg/doc/blog/f_plot.png, width=400]

Here is the derivative $f&#39;(x)$ (with figure caption and label, which enables
referring to the figure later):

FIGURE: [https://doconce.googlecode.com/hg/doc/blog/df_plot.png, width=400] The derivative of Runge&#39;s function. label{fig:Runge:dfdx}

Movies can also be embedded:

MOVIE: [http://www.youtube.com/watch?v=75Ju0eM5T2c]
</pre></div>
<p>


<table width="95%" border="0">
<tr>
<td width="25" align="center" valign="top">
<img src="https://doconce.googlecode.com/hg/bundled/html_images/lyx_notice.png" hspace="5" alt="Notice"></td>
<th align="left" valign="middle"><b>Notice</b></th>
</tr>
<tr>
<td>&nbsp;</td>
<td align="left" valign="top">
<p><p>

<ol>
<li> There must be no title, author, or date in the document.</li>
<li> If the Doconce code above is stored in a file
   <a href="https://doconce.googlecode.com/hg/doc/blog/demo.do.txt.html"><tt>demo.do.txt</tt></a>, run
   <tt>doconce format html demo --wordpress</tt> to produce the HTML code, stored in
   <a href="https://doconce.googlecode.com/hg/doc/blog/demo_wordpress.html.html"><tt>demo.html</tt></a>.</li>
<li> Copy the text in <tt>demo.html</tt> into the blog text area on
   <a href="http://doconce.wordpress.com"><tt>http://doconce.wordpress.com</tt></a> site, using <em>Text</em> mode (not <em>Visual</em>!).</li>
<li> Remember to first choose the <em>HTML-code</em> tab (and not just <em>Write</em>)
   and to place the copied text between the <tt>div</tt> tags.</li>
</ol></p>
</td>
</tr>
</table>