# Simplifying Sqrt[a+b]Sqrt[a-b] to Sqrt[a^2-b^2]

Posted 1 year ago
2095 Views
|
4 Replies
|
0 Total Likes
|
 Clarification: I need a listable function that can find and replace every occurrence of Power[z1,1/2]*Power[z2,1/2] in a data set of several hundred thousand equations with Power[z1 z2,1/2] without effecting anything else in the data set.How does one take an expression like Sqrt[a+b]Sqrt[a-b] and get Mathematica to return Sqrt[a^2-b^2], or said differently, what is the opposite of PowerExpand (neither Simplify nor FullSimplify is the answer)?I've tried some basic pattern matching with no luck, that boils down to the fact I don't know how to pattern match the sequence of Power[z1,1/2]Power[z2,1/2].All suggestions are appreciated.BTW: because of what "b" is in my problem Sqrt[a^2-b^2] = c, which then goes on to cancel with other terms so this issue creates a major bottleneck in simplifying an very complex problem.
4 Replies
Sort By:
Posted 1 year ago
 Hi Troy,You need to provide some assumptions for that identity to be true. exp = Sqrt[a + b]*Sqrt[a - b] Simplify[exp, a + b >= 0 && a - b >= 0] (* Sqrt[a^2 - b^2] *) 
Posted 1 year ago
 Hi Rohit,I'm sorry you've miss understood, but your suggestion is not a workable solution for my problem as I need a routine that pattern matches so that I can apply it to between 100,000 to 1 million symbolic equations where this issue is not always present. Also, the assumption you are making is, in general, false.
 Hi Troy,Sorry about that. I did not realize you were looking for a generic solution. Regarding how to pattern match the sequence of Power[z1,1/2]Power[z2,1/2] Power[z1, 1/2] Power[z2, 1/2] /. Times[Power[a_, 1/2], Power[b_, 1/2]] :> Power[a b, 1/2] (* Sqrt[z1 z2] *) But again, that might just be a specific solution and potentially dangerous since it is not true for all z1 and z2.