# How to perform formula operation on the equation?

How to perform formula operation on the equation?

1.How to formulate a formula that contains only one parameter?

1/4 m^2 + m + 5


How to get:

1/4 (m + 2)^2 + 4


2.How to formulate a formula that contains two parameter?

59 - 4 x + x^2 + 16 y + y^2


how to get:

(x - 2)^2 + (y + 8)^2 - 9


For the first one

expr = 1/4* m^2 + m + 5;
ResourceFunction["CompleteSquare"][expr, m]


For the second one, the above ResourceFunction does not work since it only supports one variable. But you can use

expr = 59 - 4 x + x^2 + 16 y + y^2;
CompleteTheSquare[expr, {x, y}]


Where the above function is in the answer by Simon in this post Defining a function that completes the square given a quadratic polynomial expression

• expr = 59 - 4 x + x^2 + 16 y + y^2; CompleteTheSquare[expr, {x, y}]This code does not calculate the answer Mar 10, 2023 at 1:45
• @csn899 did you first evaluate the code given in the link?? it works for me on V 13.2. As I mentioned, I using code posted in another answer. !Mathematica graphics Mar 10, 2023 at 1:45
• Do I need to be connected to the network to use this function(ResourceFunction)? Mar 10, 2023 at 5:18
• @csn899 Yes. But I think there is also a way to download the function to your PC and use it so that you do not need to be connected all the time. I do not know how myself but others would. That is one thing I do not like about ResourceFunctions and that is why I do not use them myself in my code. If you search this site you might find something. If not, you could always make new question about this issue. Mar 10, 2023 at 5:32