Can you post that code to compare?
it is the same code only the variables are chanced.
Do you have a link to some site describing the math behind IK?
I think this one. Learn about Robot Inverse Kinematics
Where did you get the math from ?
See the attached word file, I have written the math by myself.
The file in the first post.