Difference between revisions of "Power series - pointwise"

From JSXGraph Wiki
Jump to: navigation, search
(Created page with "<jsxgraph width="600" height="600"> var board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-8,8,8,-8], axis:true}); var f, curve; // global objects var p = board.create('...")
 
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
Approximate the value of
 +
:<math> \sum_{n=0}^\infty a_n\cdot x^n</math>
 +
for various values of <math>x</math>.
 +
Drag the point 'x', the blue point shows the value of the above series.
 +
<html>
 +
<p>
 +
nth-coefficient: <input type="text" id="input" value="x^n * 1 / factorial(n)">,
 +
start summation at n = <input type="number" id="startval" value="0" style="width:2em"><br />
 +
</html>
 +
 
<jsxgraph width="600" height="600">
 
<jsxgraph width="600" height="600">
var board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-8,8,8,-8], axis:true});
+
var board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-8,8,8,-8], axis:true, showClearTraces: true});
var f, curve; // global objects
+
 
 +
var p = board.create('glider', [0, 0, board.defaultAxes.x] , {name: 'x'});
 +
var q = board.create('point', [0, 1], {name: '', color: 'blue', trace: true, fixed: true});
 +
 
 +
p.on('up', function(evt) {
 +
 
 +
  var x, n, s, m = 50;
 +
  var txtraw = document.getElementById('input').value;
 +
  var a_n = board.jc.snippet(txtraw, true, 'x, n', true);
 +
  var n_0 = parseInt(document.getElementById('startval').value);
 +
 
 +
  x = p.X();
 +
  for (n = n_0, s = 0; n < m; n++) {
 +
    s += a_n(x, n);
 +
  }
 +
  q.moveTo([x, s], 0);
 +
});
  
var p = board.create('glider', [1, 0, board.defaultAxes.x]);
 
 
</jsxgraph>
 
</jsxgraph>
 +
 +
===The underlying JavaScript code===
 +
<source lang="javascript">
 +
var board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-8,8,8,-8], axis:true, showClearTraces: true});
 +
 +
var p = board.create('glider', [0, 0, board.defaultAxes.x] , {name: 'x'});
 +
var q = board.create('point', [0, 1], {name: '', color: 'blue', trace: true, fixed: true});
 +
 +
p.on('up', function(evt) {
 +
 +
  var x, n, s, m = 50;
 +
  var txtraw = document.getElementById('input').value;
 +
  var a_n = board.jc.snippet(txtraw, true, 'x, n', true);
 +
  var n_0 = parseInt(document.getElementById('startval').value);
 +
 +
  x = p.X();
 +
  for (n = n_0, s = 0; n < m; n++) {
 +
    s += a_n(x, n);
 +
  }
 +
  q.moveTo([x, s], 0);
 +
});
 +
 +
</source>
 +
 +
[[Category:Examples]]
 +
[[Category:Calculus]]

Latest revision as of 19:01, 7 January 2019

Approximate the value of

[math] \sum_{n=0}^\infty a_n\cdot x^n[/math]

for various values of [math]x[/math]. Drag the point 'x', the blue point shows the value of the above series.

nth-coefficient: , start summation at n =

The underlying JavaScript code

var board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-8,8,8,-8], axis:true, showClearTraces: true});

var p = board.create('glider', [0, 0, board.defaultAxes.x] , {name: 'x'});
var q = board.create('point', [0, 1], {name: '', color: 'blue', trace: true, fixed: true});

p.on('up', function(evt) {

  var x, n, s, m = 50;
  var txtraw = document.getElementById('input').value;
  var a_n = board.jc.snippet(txtraw, true, 'x, n', true);
  var n_0 = parseInt(document.getElementById('startval').value);

  x = p.X();
  for (n = n_0, s = 0; n < m; n++) {
    s += a_n(x, n);
  }
  q.moveTo([x, s], 0);
});