title: Evaluating Complex Numbers in Parsed Equations
body: <p>I am trying to write a program for evaluating derivatives at a point using complex step differentiation <a href="http://blogs.mathworks.com/cleve/2013/10/14/complex-step-differentiation/)" rel="nofollow">complex step differentiation</a>. </p>
  
  <p>This involves taking some analytic function F(x) and evaluating it at some imaginary point F(x+ih) where h is some real parameter. F'(x) is then given by imag(F(x+ih))/h. </p>
  
  <p>I have tested this method for evaluating derivatives using <a href="https://github.com/dankogai/swift-complex" rel="nofollow">this</a> swift code for the complex numbers and it seems to converge on a solution much quicker than using finite difference methods is more stable as well. </p>
  
  <p>I am however having a hard time figuring out how to implement this for user inputted functions that can be parsed. </p>
  
  <p>I've tried looking into using DDMathParser however it does not support complex numbers. I was wondering if this would be possible at all using NSExpression however I don't understand how it works and I do not know if there would be any way of evaluating complex numbers with it. </p>
  
  <p>If you guys have any idea of how to deal with this I'd appreciate it!</p>