Wikipedia:Reference desk/Archives/Mathematics/2024 February 2

From Wikipedia, the free encyclopedia
Mathematics desk
< February 1 << Jan | February | Mar >> February 3 >
Welcome to the Wikipedia Mathematics Reference Desk Archives
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


February 2[edit]

Draw a segment of a cubic function exactly using a cubic Bezier curve[edit]

http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Second-order_curve_is_a_parabolic_segment describes how a segment of a parabola or quadratic curve on a Cartesian plane can be drawn exactly with a quadratic Bezier curve.

Is it possible to draw a segment of a cubic curve exactly with one (preferably) or more cubic Bezier curves?

I.e. given f(x) = ax³ + bx² + cx + d, and endpoints (p, f(p)) and (q, f(q)), what are the coordinates of the two control points?

Thanks, cmɢʟeeτaʟκ 15:18, 2 February 2024 (UTC)[reply]

With a cubic Bezier curve , in order for you to be able to represent , you need to have it so that for all . I don't specify a domain on here but regardless of the domain we can just assume that in order to do so, we need for the coefficients of to match those of . We have to solve for four unknowns here, which are the coordinates of and , since and .
If you expand into a third-order polynomial, you can notice that is a ninth-order polynomial, while is third-order. The coefficient of the ninth-order term is just that of the third-order term of cubed, which means that said third-order term must be in order to match coefficients. In other words, is at most quadratic. When this is the case, is still sixth-order, with the sixth-order term being the second-order term of cubed. Again, to match coefficients, this means that the second order term is also , and is at most linear. This time, coefficient matching works, and you can get that and . In other words, the control points would be equidistantly spaced along the x-axis, which isn't particularly surprising. is naturally equal to .
The next part is finding values of and . I don't know of any tricks here, I just found the values of and manually. After expanding and , through direct comparison I found the values
Or in other words, the two control points are:
,
GalacticShoe (talk) 00:49, 3 February 2024 (UTC)[reply]
Graphs showing the relationship between the roots, and turning, stationary and inflection points of a cubic polynomial, and its first and second derivatives  Done
Thank you so much, @GalacticShoe: that's exactly what I needed. Cheers, cmɢʟeeτaʟκ 07:56, 3 February 2024 (UTC)[reply]
Glad I could be of help :) GalacticShoe (talk) 08:00, 3 February 2024 (UTC)[reply]
Here's a somewhat different take on the problem giving an equivalent result: Write
Then:
Evaluate at t=0 to get
You can easily solve for A, B, C, D in terms of F and its derivatives at 0:
Note that the last expression is the third order Maclaurin approximation for F(1), and this is exact since F is a cubic polynomial. If
is any cubic parametric curve then these formulas generate the endpoints and control points from t=0 to t=1. In particular, if the curve is y=f(x) from x=P to x=Q, where f is a cubic polynomial, take
Then:
This gives the endpoints and control points as:
The expression for the y-coordinate at Q is the Taylor series approximation of f(Q), and it's exact since f is a cubic polynomial. I don't think it would be hard to generalize these formulas to nth order Bezier curves, and you might say that the expressions for the y coordinates are actually generalizations of Taylor appromations since the last one is, in fact, the actual Taylor approximation. Since the formulas use derivatives instead of coefficients, you can use them to generate accurate Bezier approximations for any parametric curve of sufficient smoothness. --RDBury (talk) 11:08, 4 February 2024 (UTC)[reply]
Thank you very much for the general solution, @RDBury: cmɢʟeeτaʟκ 16:37, 4 February 2024 (UTC)[reply]