# Calculate Expectation Value of Hamiltonian using Dirac Notation?

## Homework Statement

I have the state:
$|\psi>=cos(\theta)|0>+sin(\theta)|1>$
where $\theta$ is an arbitrary real number and $|\psi>$ is normalized.
And $|0> and |1> refer to the ground state and first excited state of the harmonic oscillator. Calculate the expectation value of the Hamiltonian for the harmonic oscillator. ## Homework Equations [itex]\hat{H}=\hbar*\omega(\hat{N}+1/2)$
where
$\hat{N}=\hat{adagger}*\hat{a}$
The product of the raising and lowering operators

I also know that

## The Attempt at a Solution

So far I know that I can solve this by converting the two states, 0 and 1, to the wave functions and solving the integral.
But I am curious as to how I can solve this using Dirac notation
$<\hat{H}>=<\psi|\hat{H}|\psi>$

specifically I cannot figure out how to apply the derivatives in the momentum operator from N using this notation.

You can no doubt find the relationship between $\hat{a}, \hat{a}^\dagger$ and $\hat{x},\hat{p}$ in your textbook. However, there is a more direct way to solve the problem when you note that the states $|n\rangle$ are actually labeled by the corresponding eigenvalue of the number operator $\hat{N}$. Use this fact to compute the value of $\langle n|\hat{H}|m\rangle$ and use that to compute $\langle \psi|\hat{H}|\psi\rangle$.