Power series - pointwise: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
Line 5: | Line 5: | ||
<html> | <html> | ||
<p> | <p> | ||
nth-coefficient: <input type="text" id="input" value="1 / factorial(n)"> | nth-coefficient: <input type="text" id="input" value="x^n * 1 / factorial(n)"> | ||
</html> | </html> | ||
Line 18: | Line 18: | ||
var x, n, m = 50; | var x, n, m = 50; | ||
var txtraw = document.getElementById('input').value; | var txtraw = document.getElementById('input').value; | ||
var a_n = board.jc.snippet(txtraw, true, 'n', true); | var a_n = board.jc.snippet(txtraw, true, 'x, n', true); | ||
var s = 0; | var s = 0; | ||
x = p.X(); | x = p.X(); | ||
for (n = 0; n < m; n++) { | for (n = 0; n < m; n++) { | ||
s += a_n(n) * Math.pow(x, n); | s += a_n(x, n); // * Math.pow(x, n); | ||
} | } | ||
q.moveTo([x, s], 0); | q.moveTo([x, s], 0); |
Revision as of 11:05, 7 January 2019
Approximate the value of
- [math]\displaystyle{ \sum_{n=0}^\infty a_n\cdot x^n }[/math]
for various values of [math]\displaystyle{ x }[/math]. Drag the point 'x', the blue point shows the value of the above series.
nth-coefficient:
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, m = 50;
var txtraw = document.getElementById('input').value;
var a_n = board.jc.snippet(txtraw, true, 'n', true);
var s = 0;
x = p.X();
for (n = 0; n < m; n++) {
s += a_n(n) * Math.pow(x, n);
}
q.moveTo([x, s], 0);
});