Difference between revisions of "Vertex equations of a quadratic function and it's inverse"

From JSXGraph Wiki
Jump to: navigation, search
 
Line 41: Line 41:
 
</source>
 
</source>
  
 +
===Inverse quadratic function===
 
Conversely, also the inverse quadratic function can be uniquely defined by its vertex ''V'' and one more point ''P''.
 
Conversely, also the inverse quadratic function can be uniquely defined by its vertex ''V'' and one more point ''P''.
 
The function term of the inverse function has the form
 
The function term of the inverse function has the form
Line 61: Line 62:
 
             function(x) {
 
             function(x) {
 
                 var den = p.Y()- v.Y(),
 
                 var den = p.Y()- v.Y(),
                     a = (p.X() - v.X()) / (den * den);
+
                     a = (p.X() - v.X()) / (den * den),
                 return Math.sqrt((x - v.X()) / a) + v.Y();
+
                    sign = (p.Y() >= 0) ? 1 : -1;
 +
                 return sign * Math.sqrt((x - v.X()) / a) + v.Y();
 
             }]);
 
             }]);
  
Line 75: Line 77:
 
             function(x) {
 
             function(x) {
 
                 var den = p.Y()- v.Y(),
 
                 var den = p.Y()- v.Y(),
                     a = (p.X() - v.X()) / (den * den);
+
                     a = (p.X() - v.X()) / (den * den),
                 return Math.sqrt((x - v.X()) / a) + v.Y();
+
                    sign = (p.Y() >= 0) ? 1 : -1;
 +
                 return sign * Math.sqrt((x - v.X()) / a) + v.Y();
 
             }]);
 
             }]);
 
 
</source>
 
</source>
  

Latest revision as of 14:21, 16 December 2014

A parabola can be uniquely defined by its vertex V=(v_x, v_y) and one more point P=(p_x, p_y). The function term of the parabola then has the form

y = a (x-v_x)^2 + v_y.

a can be determined by solving

p_y = a (p_x-v_x)^2 + v_y for a which gives

a = (p_y - v_y) / (p_x - v_x)^2 .


JavaScript code

var b = JXG.JSXGraph.initBoard('box1', {boundingbox: [-5, 5, 5, -5], grid:true});
var v = b.create('point', [0,0], {name:'V'}),
    p = b.create('point', [3,3], {name:'P'}),
    f = b.create('functiongraph', [
             function(x) {
                 var den = p.X()- v.X(),
                     a = (p.Y() - v.Y()) / (den * den);
                 return a * (x - v.X()) * (x - v.X()) + v.Y();
             }]);

})();

Inverse quadratic function

Conversely, also the inverse quadratic function can be uniquely defined by its vertex V and one more point P. The function term of the inverse function has the form

y = sqrt((x-v_x)/a) + v_y.

a can be determined by solving

p_y = sqrt((p_x-v_x)/a) + v_y for a which gives

a = (p_x - v_x) / (p_y - v_y)^2 .


JavaScript code

var b = JXG.JSXGraph.initBoard('box2', {boundingbox: [-5, 5, 5, -5], grid:true});
var v = b.create('point', [0,0], {name:'V'}),
    p = b.create('point', [3,3], {name:'P'}),
    f = b.create('functiongraph', [
             function(x) {
                 var den = p.Y()- v.Y(),
                     a = (p.X() - v.X()) / (den * den),
                     sign = (p.Y() >= 0) ? 1 : -1;
                 return sign * Math.sqrt((x - v.X()) / a) + v.Y();
             }]);