Simple math: 3,500 calories = 1 pound. Adjust exercise and diet to enable you to burn 3,500 calories more than what you take in. Medical personnel will say don't lose more than 2 lbs per week. So, provided you burn 7,000 calories more than you take in per week, you'll lose that 2 lbs.
US Army physical fitness manual will tell you that your workout intensity should not exceed your Training Heart Rate (THR) to prevent injury. Here's how to calculate your THR:
THR = Training Heart Rate = (70% x HHR) + RHR
HRR = Heart Rate Reserve = MHR - RHR
MHR = Maximum Heart Rate = 220 - Your Age. (220 is a constant.)
RHR = Resting Heart Rate = Heart Beats Per Minute when body at rest.
RHR = 66 bpm when person is at rest (sitting in their lazy boy).
MHR = 220 - 45 years old = 175
HHR = 175-66 = 109 bpm
THR = (70% x 109) + 66 = 76 + 66 = 142 bpm
So, the 45 year old man with a 66 bpm heart rate at rest should work out at an intensity of 142 bpm. Anything more will only cause injury. Anything less is not less efficent/effective.
Now, all you gotta do is keep 142 bpm for an extended period of time regardless of the exercise. So, treadmill exercise, it doesn't matter if you're running at 9 mph for x minutes or walking 3 mph on an incline of 10 degrees carrying two 5 pound weights. All that matters for intensity is to maintain the THR throughout the exercise (example: 20 minutes).
If you have a good treadmill or a sports watch, it'll convert your BPM intensity and weight over to a more accurate count of calories burned.
Now for your goal:
40 lbs in 3 months (12 weeks) is 3.333 pounds/week. So, just to put it out there, medical personnel will tell you your goal is too aggressive right off the bat. But let's crunch the numbers anyhow.
3,500 x 3.333 = 11,667 caloric difference per week or 1,667 caloric difference per day.
So, if you're diet is 2,000 calories per day then your exercise should be 3,667 per day theoretically.
In the example above: I know for myself it takes me 40 minutes at 142 BPM to burn 500 calories. So, if I was to accomplish your goal, I would have to work the treadmill for 5 hours per day (or something equivalent like work a construction job all day long moving concrete and bricks).
Actually, it might be less because your body burns calories all day long, even when you sleep. So, you could crunch the numbers for that to get an even more accurate count.
You might want to use a supplement like Bladderwrack to increase your metabolism to help burn your fat more efficiently. You can get Bladderwrack at your local natural foods grocery store or a pharmacy. It'll effect your thyroid though.
Okay, so this is an oversimplification of the weight loss and it's a good start but then you'll need to consider what kind of food you're taking in too. Here's a good article explaining why: http://authoritynutrition.com/debunking-the-calorie-myth/
Article's bottom line: Calories in, calories out does work for weight loss but you also have to consider metabolic issues too (No carbs in your diet. Eat only protein, veggies, and fruit.) Atkins diet does work pretty effectively.
I believe in the best diet is the Traditional Chinese Diet. Read the book "The Tao of Eating" and you'll know the "ancient Chinese secret". Seriously, it has changed my health in so many ways that I don't have enough paper to write about it.