Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have three key points on a graph. How do I find out what the formula for this graph would be? The points are: (3,0) (5,2) (7,6). It is known that the graph will be a quadratic. Thanks

share|improve this question
    
"quadratic" means parabola? –  Vitaliy Kaurov Oct 18 '12 at 6:06
5  
Try InterpolatingPolynomial[{{3, 0}, {5, 2}, {7, 6}}, x] or LinearAlgebra`VandermondeSolve[{3, 5, 7}, {0, 2, 6}, Transpose -> True].x^Range[0, 2]. –  J. M. Oct 18 '12 at 7:37

1 Answer 1

You can try Fit:

Fit[{{3, 0} , {5, 2}, {7, 6}}, {1, x, x^2}, x]

The graph can be generated by:

Plot[Evaluate@Fit[{{3, 0} , {5, 2}, {7, 6}}, {1, x, x^2}, x], {x, 2, 8}]

Mathematica graphics

For your case, another approach is to solve the equations generated by the given points:

exp = a x^2 + b x + c ;
eqn = Table[((exp == y ) /. {x -> i[[1]], y -> i[[2]]}), 
            {i, {{3, 0} , {5, 2}, {7, 6}}}];
sol = Solve[eqn, {a, b, c}]
Plot[exp /. sol, {x, 2, 8}]

Of course, this solution will not work if the number of points increases and some of these points are not located on the curve.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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