LateX in WordPress.

Recently, I learned LateX to compile documents. It is great. Though the learning the syntax was a pain to wade through at first, it really becomes natural after a few months of using LateX to build documents. You can even version control it!

Anyway, I found a great WP plugin here that lets you use inline LateX formulas! It is truly epic.

Now I can write out proofs, equations and more in the notation those proofs, equations and more deserve to be written in! The following examples are some of the neat things you can use LateX for within wordpress.

  \forall x \in X, \quad \exists y \leq \epsilon

   \alpha, \beta, \gamma, \delta, \epsilon, \varepsilon,   \zeta, \mu, \theta, \vartheta, \phi,   \varphi, \omega, \sigma, \varsigma,   \Gamma, \Delta, \Theta, \Phi, \Omega

   \cos (2\theta) = \cos^2 \theta - \sin^2 \theta

   \lim_{x \to \infty} \exp(-x) = 0

   \frac{n!}{k!(n-k)!} = \binom{n}{k}

  \sqrt[n]{1+x+x^2+x^3+\ldots}

   \sum_{i=1}^{10} t_i

   \int_0^\infty e^{-x} \, dx

   ( \big( \Big( \bigg( \Bigg(

   A_{m,n} =   \begin{pmatrix}    a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\    a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\    \vdots  & \vdots  & \ddots & \vdots  \\    a_{m,1} & a_{m,2} & \cdots & a_{m,n}   \end{pmatrix}

These samples were taken from here. So far from testing, you can expect any inline mathematics functions to work with this plugin. General LateX formatting does not work, so not everything is going to be done with LateX – HTML/CSS are still going to dominate that scene.

  WordPress + LateX = Awesome
Posted in Programming, Wordpress | Tagged , | Comments closed

Greatest common denominator in Scheme.

Here I’ve implemented Euclid’s famous functions for calculating the greatest common denominator. I’ve also implemented a slight addition that allows us to calculate the integer coefficients x and y such that d = gcd(a, b) = ax + by. These algorithms were adapted from Thomas Cormen’s exercises on pages 859-860 of Introduction to Algorithms, 2nd Edition.

#lang racket
(require test-engine/racket-tests)
 
;; calculate the greatest common denominator for a and b
(define (euclid a b)
  (cond
    [(= b 0) a]
    [else (euclid b (modulo a b))]
    ))
 
;; register some test cases
(check-expect (euclid 5 10) 5)
(check-expect (euclid 18 8) 2)
(check-expect (euclid 99 78) 3)
 
;; calculate (d, x, y) such that d = gcd(a, b) = ax + by
(define (euclid-ext a b)
  (cond
    [(= b 0) (values a 1 0)]
    [else (let-values ([(d x y) (euclid-ext b (modulo a b))])
            (values d y (- x (* (quotient a b) y))))]
    ))
 
;; register a test case
(check-expect (call-with-values (lambda () (euclid-ext 99 78)) list)
              (list 3 -11 14))
(test)
Posted in Programming | Tagged , , , | Comments closed

Writing a simple PLT Racket program with a test case.

I’m considering deploying a small PLT Racket web server so I thought I should brush up on the most recent version of Scheme that I’m familiar with: PLT Racket. The following is a small sample program and the syntax for testing that function.

#lang racket
 
(require test-engine/racket-tests)
 
(define (my-factorial x)
  (cond
    [(= x 0) 1]
    [else (* x (my-factorial (- x 1)))]
    ))
 
(check-expect (my-factorial 5) 120)
(check-expect (my-factorial 20) 2432902008176640000)
(test)

After running the application in a PLT Racket interpreter you should see the test results. I ran mine in DrRacket and received the following output.

Welcome to DrRacket, version 5.0.1 [3m].
Language: racket; memory limit: 128 MB.
Both test passed!
>

How fun! Keep in touch for when I deploy the web server.

Resources:
http://docs.racket-lang.org/test-engine/index.html?q=test#%28def._%28%28lib._test-engine/racket-tests..rkt%29._test%29%29

Posted in Programming | Tagged , , | Comments closed