When you're planning a day trip with the family or a visit to an old friend, travelling by train can sometimes be easier and lot less stressful than sitting in miles of traffic.

But one part of using trains that certainly is not less stressful is trying to figure out why some ticket prices are so much more expensive than others and how to get the best deal.

Train fares are extremely frustrating and it often feels like they've been worked out by a a cryptic code that seems impossible to crack.

So in an attempt to make fares seem simpler, we asked East Midlands Trains how exactly fares are calculated in the hope it would shed some light on the mystery.

How are fares calculated?

A lot of train ticket prices are regulated by Government rulings and are essentially set by authorities above train companies heads.

Many fares were set years ago and have just changed in line with Government policy.

East Midlands Trains believe that around 50% of their fares are set by Government using July's Retail Prices Index (RPI), which measures inflation to determine the appropriate price of fares.

Season ticket prices whether they're weekly, monthly or yearly are not controlled by train companies at all.

A spokeswoman for East Midlands Trains said: "Season tickets are termed as 'regulated fares' and their annual changes are set by the Government, not train companies."

East Midlands Trains has revealed how tickets are calculated.

How do East Midlands Trains calculate other fares?

Half of train fares are set by East Midlands Trains themselves who take into account a wide range of factors in order to calculate the price of its train tickets.

The spokeswoman added: "In common with other transport providers, the price of a fare can take into account factors such as the speed, comfort, frequency, available space and the amount of time between the purchase of the ticket and the journey itself."

Speed, comfort and frequency apply to the set prices of tickets bought on the day as well as advance tickets, whereas available space and time between purchase and travel only effect advance tickets.

So two train journeys that take almost exactly the same amount of time (for example Nottingham to Derby and Derby to Leicester) could have different prices due to the distance travelled in the same amount of time.

A single off-peak ticket bought on the day of travel from Nottingham to Derby costs £7.25, whereas Derby to Leicester is £11.30, but both journeys take just under 30 minutes.

Nottingham to Derby is only 15 miles, whereas Derby to Leicester is 30.1 meaning that the train between Derby and Leicester must travel quicker in order to complete the journey in the same time as the other train.

Why do advance ticket prices vary so much and change so quickly

Advance tickets tend to reflect the demand of tickets and thus change as the demand changes.

There are only a limited number of advance tickets available for each service.

Those tickets will start at a set price and then will decrease or increase in price depending on how many or how few are sold.

The spokeswoman said: "Advance fares are sold in limited numbers and designed to encourage customers to use services which we know do not tend to be full.

"This is to manage the number of passengers travelling with us, particularly during the busiest times of the day."

So peak services are unlikely to have cheap advance tickets, but there might be a service at a random point of the day that is not in high demand that can offer a bargain price.

Ticket prices vary immensely.

Why can you buy on board some trains but not others?

East Midlands Trains operate a Penalty Fare scheme which means passengers are not permitted to buy a ticket on board.

But this scheme is only used on certain stations and routes.

Train managers do not operate this scheme, specialised revenue prevention officers board services at random times to check valid tickets.

Only then will you be charged a penalty fare of £20 or double the anytime single price to the next station, depending on which is the greater amount.

Every station on the East Midlands Trains line between London St Pancras, Nottingham and Derby, including Beeston and Mansfield are included in the scheme.

The spokeswoman added: "Similar to other train companies across the country, we encourage customers to always buy their ticket before boarding the train.

"Some smaller stations do not have a ticket office and therefore customers travelling from these stations may buy their ticket on board the train."

Penalty fares can be appealed and disputed, but there has to be an exceptional circumstance in order to uphold the appeal.

Why are fares so complicated?

Unfortunately there are just so many aspects of a journey to consider when pricing train fares, meaning it's difficult to make ticket prices easier to understand.

East Midlands Trains is working with other train companies and the Government to make fares simpler for train users.

The company took part in an easier fares consultation earlier this year in an attempt to connect with passengers and ask what changes they want to see.

The spokeswoman added: "We have also taken a leading role in making fares simpler for customers.

"We took part in a simpler fares pilot scheme in 2017 and actively supported the industry's simpler fares consultation earlier this year."

The results of the consultation are due to be released before the end of the year, so easier to understand fares could be heading our way soon.