By Liana B. Baker

(Reuters) - Lazard Ltd <LAZ.N>, the investment bank that advised SolarCity Corp <SCTY.O> on its $2.6 billion sale to Tesla Motors Inc <TSLA.O>, made an error in its analysis that discounted the value of the U.S. solar energy company by $400 million, a regulatory filing by Tesla showed on Wednesday.

While the purchase price was within the valuation range that Lazard came up with for SolarCity even after accounting for the miscalculation, the error illustrates how even leading investment banks can make mistakes on some of the highest-profile deals.

The mistake came after Tesla and SolarCity co-founder Elon Musk, who is the largest shareholder in both companies, went out of his way to create processes and structures, including a special board committee at SolarCity, aimed at alleviating concerns that he used his influence to force the two companies into a deal.

An analysis by Lazard for SolarCity that indicated an equity value of between $14.75 and $34.00 per share was wrong because it double-counted some of the company's projected indebtedness, according to Tesla's filing with the U.S. Securities and Exchange Commission.

This was the result of a computational error "in certain SolarCity spreadsheets setting forth SolarCity’s financial information that Lazard used in its discounted cash flow valuation analyses," according to the filing.

The error was not included in the valuation analysis performed by Tesla and its financial adviser, Evercore Partners Inc <EVR.N>, the filing said.

After becoming aware of the mistake on Aug. 18, more than two weeks after the signing of the deal, Lazard realized the accurate valuation range was $18.75 to $37.75 per share.

SolarCity and Tesla agreed however that the error would not change their view of the deal, according to the filing. The purchase price, to be paid with Tesla stock, equated to $25.37 per share.

Lazard, SolarCity and Tesla declined to comment.

Lazard ranks No. 10 in the Thomson Reuters Americas M&A league table so far this year, down two spots on where it was last year.

This is not the first time a major investment bank has made a miscalculation on a big deal. An erroneous share count in the leveraged buyout of Tibco Software in 2014 by its financial adviser, Goldman Sachs Group Inc <GS.N>, led to a Tibco shareholder lawsuit that was settled earlier this year.

Goldman discovered it had overstated the number of Tibco's fully diluted shares only after the company agreed to sell itself to private equity firm Vista Equity.

This had the effect of lowering the sale price to $4.14 billion from the $4.24 billion used in Goldman's fairness opinion. Nevertheless, Tibco decided not to ask Vista to pay the additional $100 million.

Goldman and Vista agreed to pay $30 million to the Tibco shareholders as part of the settlement, the Wall Street Journal reported at the time.

(Reporting by Liana B. Baker in New York; Editing by Andrew Hay and Matthew Lewis)