Difference between revisions of "Tc"
(Created page with "This is a very useful tool. A tc is a complex number z together with a complex vector dz attached to. The notation dz is probably not the best but it is to mimic physicist no...") |
(→Derivatives) |
||
Line 54: | Line 54: | ||
It computes derivatives for you. | It computes derivatives for you. | ||
− | Say you defined Z=(z,1) and computed W=cos( | + | Say you defined Z=(z,1) and computed W=cos(Z×Z). Then you get W=(a,b) with a=cos(z×z) and b= the derivative $\partial a/\partial z$.: you did not need to determine that $\partial \cos(z^2)/\partial z=-2z\sin(z^2)$, the class computed b iteratively for you. |
== Implementation == | == Implementation == | ||
Either I will put code here or a link to download code. | Either I will put code here or a link to download code. |
Revision as of 15:20, 27 February 2014
This is a very useful tool.
A tc is a complex number z together with a complex vector dz attached to. The notation dz is probably not the best but it is to mimic physicist notation, like \[(z+dz)\times(w+dw)=w\,z+(w\,dz+z\,dw)+\text{neglected}\] or \[\cos(z+dz)=\cos(z)-\sin(z)dz.\]
Contents
Operator overloading
C++ allows operator overloading. In other words, you can use instructions like d=c+a*b in your programs, with any kind type of objects for a,b,c,d.
This is why it is much easier to program with complex numbers in C++ than in Java for instance. Compare C++
z=u*z*(z*z+cos(c*z)+d);
with Java
z=mul(u,mul(z,add(mul(z,z),add(cos(mul(c,z)),d))));
or worse, with C
mul(w,c,z);
cos(w,w);
add(w,w,d);
mul(v,z,z);
add(w,w,v);
mul(w,z,w);
mul(z,u,w);
Operations
One defines \[(z,dz) + (w,dw) = (z+w,dz+dw)\] \[(z,dz) \times (w,dw) = (z\,w,w\,dz+z\,dw)\] \[-(z,dz) = (-z,-dz)\] \[1/(z,dz) = (1/z,-dz/zˆ2)\] \[\overline{(z,dz)} = (\overline{z},\overline{dz})\] \[\exp(z,dz)=(\exp(z),\exp(z)dz)\] \[\cos(z,dz)=(\cos(z),-\sin(z)dz)\] \[etc...\]
Tangent space and jets
One can imagine that a tc pair (z,dz) represents a moving point, starting from z and moving at speed dz: $z(t)=z+dz\,t+o(t)$ . In other words it is an element in the tangent space TC of the complex numbers field C. This is why I chose the name tc for the C++ class. It can also be considered as 1-jets (can be generalized to higher degree power series expansions, like $(z,b,c)$ representing $z(t)=z+b\,t+c\,t^2+o(t^2)$).
Derivatives
It computes derivatives for you.
Say you defined Z=(z,1) and computed W=cos(Z×Z). Then you get W=(a,b) with a=cos(z×z) and b= the derivative $\partial a/\partial z$.: you did not need to determine that $\partial \cos(z^2)/\partial z=-2z\sin(z^2)$, the class computed b iteratively for you.
Implementation
Either I will put code here or a link to download code.