Problem 61143. Translating parabola by its vertex to the origin
Given a quadratic polynomial, p(x) = ax^2 + bx + c (a ~= 0), represented by the vector [a b c], consider the translation of the parabola by shifting its vertex to the origin (see figure below).
Find
- d (d>0) the shifting distance of the above translation;
- v the vertical shift, which stands for 'up' and 'down' if the parabola is upward or downward shifted, respectively, or simply '' if the graph does not undergo a translation;
- h the horizontal shift, which stands for 'right' and 'left' if the parabola is shifted to the right and to the left, respectively, or simply '' if the graph does not undergo a translation.
Hint: Be careful to the potential computer errors whenever the results will be integer numbers.
input: p
output: [d, v, h]
Solution Stats
Problem Comments
-
3 Comments
ChrisR
on 2 Jan 2026 at 17:18
Nice problem, Luisa. One suggestion is to check whether the distances are within some tolerance of the correct answer. Instead of assert(isequal(d,d_correct)), you could do assert(abs(d-d_correct)<tolerance).
Christian Schröder
on 2 Jan 2026 at 21:37
I agree with Chris on both counts. Nice problem! And for comparing floats, it's best to use isapprox(), as always.
Luisa
on 3 Jan 2026 at 10:40
Thank you. As claimed, I fixed all non-integer answers, namely Tests 2, 3 and 5. However, I do not understand why they fitted for me.
Solution Comments
Show commentsProblem Recent Solvers5
Suggested Problems
More from this Author12
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!