Newton's root finding method: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
Line 14: | Line 14: | ||
<tr><td> </td></tr> | <tr><td> </td></tr> | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
// Initial function term | // Initial function term | ||
//var term = function(x) { return x*x; }; | //var term = function(x) { return x*x; }; | ||
//var graph = function(x) { return term(x); }; | //var graph = function(x) { return term(x); }; | ||
var term, graph; | var term, graph; | ||
// Recursion depth | // Recursion depth | ||
Line 46: | Line 35: | ||
var ax = board.create('axis', [[0,0], [1,0]], {strokeColor: 'black'}); | var ax = board.create('axis', [[0,0], [1,0]], {strokeColor: 'black'}); | ||
var ay = board.create('axis', [[0,0], [0,1]], {strokeColor: 'black'}); | var ay = board.create('axis', [[0,0], [0,1]], {strokeColor: 'black'}); | ||
newGraph(document.getElementById('graphterm').value); | |||
var g = board.create('functiongraph', [function(x){return graph(x);}],{strokeWidth: 2, dash:0}); | var g = board.create('functiongraph', [function(x){return graph(x);}],{strokeWidth: 2, dash:0}); | ||
var x = board.create('glider',[s,0,ax], {name: 'x_{0}', strokeColor: 'magenta', fillColor: 'yellow'}); | var x = board.create('glider',[s,0,ax], {name: 'x_{0}', strokeColor: 'magenta', fillColor: 'yellow'}); | ||
Line 66: | Line 59: | ||
} | } | ||
} | } | ||
function newGraph(v) { | |||
eval("term = function(x){ return "+v+";}"); | |||
graph = function(x) { return term(x); }; | |||
g.Y = function(x){ return term(x); }; | |||
g.updateCurve(); | |||
board.update(); | |||
} | |||
</jsxgraph> | </jsxgraph> |
Revision as of 14:14, 3 February 2010
xo is the start value. Drag it. You may change the function term here: