# Composition of Quaternions as rotations

## Homework Statement

Hi, I am having problems in showing that in practise the composition of two rotations represented by quaternions is still a rotation.
The example I have constructed is:
Rotate (1,1,0) by 45 degrees about the z axis.
The quaternion to use is thus q = cos(22.5)+ksin(22.5)
This gives the vector (0,√2,0), as one would expect.
Then, rotate this new vector by 45 degrees about the x acis.
The quaternion to use is thus p = cos(22.5)+isin(22.5)
This gives the vector (0,1,1), as expected.
However, trying to find the single quaternion rotation to get from (1,1,0) to (0,1,1) is proving problematic..

## Homework Equations

I know that composition of rotations is done in reverse order, ie to find the single quaternion that I need to use, I need to do pq and then apply this to (1,1,0) to give me (0,1,1)

## The Attempt at a Solution

Now, I know that the answer is a rotation of 90 degrees about the y-axis, ie about (0,1,0), which is, in quaternion form, r = cos45+jsin45

But when I multiply p with q, I do not get this.
In fact, pq= cos^2(22.5) + isin(22.5)cos(22.5) + ksin(22.5)cos(22.5) - jsin^2(22.5)
which I cannot get to equal what I want!

By adding and subtracting another sin^2 , I can get the cos45, but then I am left with
sin(22.5)(icos(22.5)+kcos(22.5)-jsin(22.5)) which is no closer!

Could somebody please explain where I have gone wrong/what identities I have missed, as this should work, and I don't understand why it isn't!

Many thanks.