1
$\begingroup$

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
$\endgroup$

1 Answer 1

4
$\begingroup$

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

$\endgroup$
4
  • $\begingroup$ expr = 59 - 4 x + x^2 + 16 y + y^2; CompleteTheSquare[expr, {x, y}]This code does not calculate the answer $\endgroup$
    – csn899
    Commented Mar 10, 2023 at 1:45
  • 1
    $\begingroup$ @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 $\endgroup$
    – Nasser
    Commented Mar 10, 2023 at 1:45
  • $\begingroup$ Do I need to be connected to the network to use this function(ResourceFunction)? $\endgroup$
    – csn899
    Commented Mar 10, 2023 at 5:18
  • 1
    $\begingroup$ @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. $\endgroup$
    – Nasser
    Commented Mar 10, 2023 at 5:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.