Mathematica Asked on January 14, 2021
How can I replace small expressions in larger expressions?
Simple example
Replace[a^2 + b^2 + 2*a*b + x, (a + b)^2 -> c]
I want to get c + x
but the output is a^2 + b^2 + 2*a*b + x
.
Try this.
First:
s = Solve[(a + b)^2 == c, a][[1, 1]]
(* a -> -b - Sqrt[c] *)
second:
a^2 + b^2 + 2*a*b + x /. s // Simplify
(* c + x *)
Have fun!
Answered by Alexei Boulbitch on January 14, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP