Orbits for space missions I am just wondering say if there is an expedition where some astronauts are sent to the moon, how do they choose the trajectory for the spaceshuttle (or whatnot)? I mean there are many possible trajectories depending on the initial velocity at which the vessel is launched. There must be some sort of optimal trajectory they choose right? What are the factors they take into account when choosing the trajectory? Things like costs, stability and so on? What does stability mean in this context? 
 A: I took one class called "Optimal Control", and it answers your question pretty much exactly.  For a space mission, it's likely that you would use some fairly specific software package to do this, but it does come down to an optimization problem.
That said, the optimization will almost certainly be empirical.  To start with, you need some accurate "map" of the solar system that includes the motion of astronomical bodies.  Then, using this time-dependent map, you need a code that can calculate a trajectory based on an input of the craft's thrust.  This is done by numerical integration of some sort, and some methods are better than others while some methods take longer than others.  Then you need to establish an objective Figure Of Merit (FOM) function or functions.  The core of an optimization problem is that you will want to minimize whatever FOM you have.  This is done by numerically finding a minimum of the FOM by adjusting some input vector.  The selection of that input can be difficult as well.  There is not just one thrust vector to optimize on, because it is time-dependent.  So you take the thrust vector over time, say $\vec{F}(t)$ and break it up into a number of intervals $n$.  Then you can minimize $FOM$ on all of the independent variables in the time-dependent thrust vector.  It is also common to do this several times, starting with a small $n$ and then increasing the number of time steps to refine it further.
A logical $FOM$ would be to minimize cost, which is almost certainly related to the amount of propellant used to deliver a given payload to a certain location within a certain time-frame.  Alternatively, time may be a floating variable that you also wish to minimize.  A major part of the challenge and finess comes from the fact that $FOM$ has many many unique local minimums and numerical techniques can only find you local minimums, not a global minimum.  That means that when traveling to the moon, for instance, every given number of gravitational assists will probably lead to a unique local minimum and in order to find the others, you have to start with different initial conditions.  A good astrophysicist should be able to predict the potentially good paths and give the program initial conditions that will lead to those different local minimums.  Then the process would be to compare the different minimums and pick the one that best fit the mission objectives.
When actually carrying out the mission, there's the harry fact that your systems don't have perfect accuracy.  While you may have a trajectory mapped out, there will be deviations from this trajectory, and one of the roles of a mission control center while the spacecraft is in flight is to analyze the trajectory and program in appropriate corrections.  The Mars Science Laboratory, for instance, is in this part of its mission now.  It has a handful of previously planned corrections that are carried out routinely.
