Introduction to LaTeX Equations
This is not a general tutorial on how to create equations in
. If you want to display equations ever, at all, anywhere, you must know how to create
equations (IMHO).
Trac Instllation
There are a number of Latex Plugins for web pages (see Plugin History below). This one simply requires a single file to be copied into your trac plugins sudirectory. You can browse that file or download the current development version and copy into yourplugins directory. Use:
svn co http://www.openvest.com/svn/tools/trunk/LatexEquationMacro
It presumes that you have latex and dvipng installed and accessable from your server software.
Sample Equations
You can view the source of these equations in the alt= tag of an equation. Some browswers give it to you as you hover over the image, others if you view the source code (ctrl-U in Firefox). The easiest way to see them all is to look for the Plain Text link at the bottom of the page.
Equity Risk Calculation
There are two methods of placing LatexEquations? into a wiki page. LatexEquation deployed in the new stye of WikiMacros deployed as a TracPlugin. Given that, both:
[[LatexEquation(r_n=\sum_{k=1}^K{X_{n,k}\cdot b_k+u_nn)]]
and
{{{
#!LatexEquation
r_n=\sum_{k=1}^K{X_{n,k}\cdot b_k+u_nn)
}}}
display as:
Duration Calculations
Macaulay Duration

Macaulay Duration at any date

Macaulay Duration closed form solution
![D=\frac{C(\alpha+\frac{1}{r})[(1+r)^m-1]-Cm+100r(m-1+\alpha)}
{C[(1+r)^m-1]+100r}](../chrome/site/images/latex/a9578f3881560bfcb5cab2cf7465ddbc.png)
Black-Scholes
Call Option
Put Option
where
and
| Stock price |
| Strike Price of option |
| Risk-free rate of return |
| Time to Expiration in years |
| Volatility |
| Cumulative normal distribution function |
For my pythonic friends out there here's some python code for Black-Scholes. Of course it has to start with the Cumulative Normal Distribution Function (CND):
# Cumulate Normal Distribution Function def CND(X): (a1,a2,a3,a4,a5) = (0.31938153, -0.356563782, 1.781477937, -1.821255978, 1.330274429) L = abs(X) K = 1.0 / (1.0 + 0.2316419 * L) w = 1.0 - 1.0 / sqrt(2*pi)*exp(-L*L/2.) * (a1*K + a2*K*K + a3*pow(K,3) + a4*pow(K,4) + a5*pow(K,5)) if X<0: w = 1.0-w return w # Black Sholes Function def BlackSholes(CallPutFlag,S,X,T,r,v): d1 = (log(S/X)+(r+v*v/2.)*T)/(v*sqrt(T)) d2 = d1-v*sqrt(T) if CallPutFlag=='c': return S*CND(d1)-X*exp(-r*T)*CND(d2) else: return X*exp(-r*T)*CND(-d2)-S*CND(-d1)
Not a python fan? Look for Balck-Scholes in your language of choice over here.
Other equations
![\[f(n) = \left\{
\begin{array}{l l}
n/2 & \quad \mbox{if $n$ is even}\\
-(n+1)/2 & \quad \mbox{if $n$ is odd}\\ \end{array} \right. \]](../chrome/site/images/latex/0ca7d6a61ced082f211e345d1cd6dfdb.png)
and

Notes on MathML
MathML is coming along but is still of niche interest. Compare
to the MathML version here in your browser.
Plugin History
This came from the original LatexFormulaMacro. For a number of reasons I went with the .11dev release of Trac (Genshi, pygments etc). With newer Trac Versions these old style macros are on the way out. I have created a small Macro where you only need to copy 1 file into the site plugins directory and you are off and running.
I aparently was working from an older (and simpler) version of the Latex macro. Good thing too, because the Version 0.9 rendition starts to look hard. I should maybe bring some of the functionality forward. The code changes and install requirements of the Graphvis plugin scare me.
That brings me to one last note. There is a plugin version already available in this ticket someone needs to take chagrge of this madness. I'll take a look to see which is most functional for me. YMMV!
