I7 4510u+ GT 840M OR i7 4702MQ + GT740M?

I want to buy a new laptop. I'm confused between these two.

1. HP Pavilion 15-p045tx (i7 4510u+ GT 840M)

2. Lenovo idepad z510 ( i7 4702MQ + GT740M)

I will be using laptop for moderate gaming and for medium pocessing in MATLAB, ANSYS, FLUENT.
Which one should I buy considering future prospective?(atleast 4-5 years)

Or should I go with an i5 4210u+ Nvidia 820M configuration to save money?
( HP 15-r022tx)

I want to buy laptop just to serve these purpose.
(All laptops are with 8 Gb ram)

Please suggest the best laptop.

The i7 4702MQ paired with the GT740M is better as it will provide for a much better overall performance. The 840M can't make up for the fact that the i7 4510u has 2 cores, or 4 threads less than the i7 4702MQ. Overall, second option is better.

Do NOT get an HP, they are garbage.