Group Abstract Group Abstract

Message Boards Message Boards

0
|
34 Views
|
2 Replies
|
3 Total Likes
View groups...
Share
Share this post:
GROUPS:

Are there any other good methods for performing cubic completion?

Posted 1 day ago
2 x^3 - 3 a x^2 + 1 ==     
1 - a^3/2 - 3/2 a^2 (-(a/2) + x) + 2 (-(a/2) + x)^3

Write a Mathematica function that performs cubic completion. For a cubic polynomial in x, such as the equation above, the function should be able to complete the cube to achieve the form shown on the right-hand side.

Here is one way to solve it—are there any better approaches?

AutoCompleteCube[poly_, x_] := 
 Module[{a3, a2, x0, refinedPoly}, a3 = Coefficient[poly, x, 3];
  a2 = Coefficient[poly, x, 2];
  x0 = -a2/(3*a3);
  refinedPoly = 
   Total@Table[(Derivative[i][Function[x, poly]][x0]/i!)*(x - x0)^
       i, {i, 0, 3}];
  refinedPoly]
AutoCompleteCube[2 x^3 - 3 a x^2 + 1, x]
POSTED BY: Bill Blair
2 Replies

Another way:

With[{x0 = First@SolveValues[D[2 x^3 - 3 a x^2 + 1, {x, 2}] == 0, x]},
 Expand[2 x^3 - 3 a x^2 + 1 /. x -> (u + x0)] /. u -> (x - x0)
 ]
(*  1 - a^3/2 - 3/2 a^2 (-(a/2) + x) + 2 (-(a/2) + x)^3  *)

Or:

With[{x0 = First@SolveValues[D[2 x^3 - 3 a x^2 + 1, {x, 2}] == 0, x]},
 Normal@Series[2 x^3 - 3 a x^2 + 1, {x, x0, 3}]
 ]
POSTED BY: Michael Rogers
form = AA (x - x0)^3 + BB (x - x0) + CC;
form /. First@Solve[
   CoefficientList[2 x^3 - 3 a x^2 + 1, x] == CoefficientList[form, x]
   , {AA, BB, CC, x0}
   ]

(*  1/2 (2 - a^3) - 3/2 a^2 (-(a/2) + x) + 2 (-(a/2) + x)^3  *)
POSTED BY: Michael Rogers
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard