1

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
csn899
  • 3,953
  • 6
  • 13

1 Answers1

4

For the first one

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

Mathematica graphics

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}]

Mathematica graphics

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

Nasser
  • 143,286
  • 11
  • 154
  • 359
  • CompleteTheSquare[expr, {x, y}]```This code does not calculate the answer – csn899 Mar 10 '23 at 01:45
  • 1
    @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 – Nasser Mar 10 '23 at 01:45
  • Do I need to be connected to the network to use this function(ResourceFunction)? – csn899 Mar 10 '23 at 05:18
  • 1
    @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. – Nasser Mar 10 '23 at 05:32