Difference between revisions of "Draggable exponential function"

From JSXGraph Wiki
Jump to navigationJump to search
Line 1: Line 1:
 +
Plot the function
 +
''y = e^{ax}''
 +
where the parameter ''a'' is determined by the Point ''A=(x_A, x_Y)''.
 
<jsxgraph width="400" height="400" box="box1">
 
<jsxgraph width="400" height="400" box="box1">
 
var board = JXG.JSXGraph.initBoard('box1', {boundingbox: [-5, 20, 5, -1], axis:true});
 
var board = JXG.JSXGraph.initBoard('box1', {boundingbox: [-5, 20, 5, -1], axis:true});
Line 13: Line 16:
 
           }], {fontSize: 16});
 
           }], {fontSize: 16});
 
</jsxgraph>
 
</jsxgraph>
 +
 +
 +
===The JavaScript code===
 +
<source lang="javascript">
 +
var board = JXG.JSXGraph.initBoard('box1', {boundingbox: [-5, 20, 5, -1], axis:true});
 +
 +
var p = board.create('point', [1, Math.exp(1)]);
 +
var graph = board.create('functiongraph', [
 +
        function(x) {
 +
            var a = Math.log(p.Y()) / p.X();
 +
            return Math.exp(a * x);
 +
        }]);
 +
         
 +
var txt = board.create('text', [-3, 10, function () {
 +
          return "a = " + (Math.log(p.Y()) / p.X()).toFixed(2);
 +
          }], {fontSize: 16});
 +
</source>
  
 
[[Category:Examples]]
 
[[Category:Examples]]
 
[[Category:Calculus]]
 
[[Category:Calculus]]

Revision as of 11:32, 16 February 2016

Plot the function y = e^{ax} where the parameter a is determined by the Point A=(x_A, x_Y).


The JavaScript code

var board = JXG.JSXGraph.initBoard('box1', {boundingbox: [-5, 20, 5, -1], axis:true});

var p = board.create('point', [1, Math.exp(1)]);
var graph = board.create('functiongraph', [
         function(x) {
            var a = Math.log(p.Y()) / p.X();
            return Math.exp(a * x);
         }]);
           
var txt = board.create('text', [-3, 10, function () {
           return "a = " + (Math.log(p.Y()) / p.X()).toFixed(2);
          }], {fontSize: 16});