Draggable exponential function: Difference between revisions
From JSXGraph Wiki
| A WASSERMANN (talk | contribs) No edit summary | A WASSERMANN (talk | contribs) No edit summary | ||
| Line 17: | Line 17: | ||
| var txt = board.create('text', [-3, 10, function () { | var txt = board.create('text', [-3, 10, function () { | ||
|             return "a = " + (Math.log( |             return "a = " + (Math.log(A.Y()) / A.X()).toFixed(2); | ||
|            }], {fontSize: 16}); |            }], {fontSize: 16}); | ||
| </jsxgraph> | </jsxgraph> | ||
| Line 34: | Line 34: | ||
| var txt = board.create('text', [-3, 10, function () { | var txt = board.create('text', [-3, 10, function () { | ||
|             return "a = " + (Math.log( |             return "a = " + (Math.log(A.Y()) / A.X()).toFixed(2); | ||
|            }], {fontSize: 16}); |            }], {fontSize: 16}); | ||
| </source> | </source> | ||
Revision as of 09:36, 16 February 2016
Plot the function
- [math]\displaystyle{ y = e^{ax} }[/math]
where the parameter [math]\displaystyle{ a }[/math] is determined by the Point [math]\displaystyle{ A=(x_A, y_A) }[/math].
That means,
- [math]\displaystyle{ a = log(y_A) / x_A }[/math]
The JavaScript code
var board = JXG.JSXGraph.initBoard('box1', {boundingbox: [-5, 20, 5, -1], axis:true});
var A = board.create('point', [1, Math.exp(1)]);
var graph = board.create('functiongraph', [
         function(x) {
            var a = Math.log(A.Y()) / A.X();
            return Math.exp(a * x);
         }]);
           
var txt = board.create('text', [-3, 10, function () {
           return "a = " + (Math.log(A.Y()) / A.X()).toFixed(2);
          }], {fontSize: 16});
