Siemens has agreed to buy Mentor Graphics, the specialist in electronic design automation, for $4.5 billion. The company is also investing €70 million in Bentley Systems to develop joint solutions for infrastructure and industry. The company also said it plans to divest its medical business, which caused its share price to rise.