Difference between revisions of "Newton's root finding method"

From JSXGraph Wiki
Jump to: navigation, search
Line 16: Line 16:
 
// 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); };
 +
 
// Recursion depth
 
// Recursion depth
 
var steps = 11;
 
var steps = 11;
Line 28: Line 30:
 
</html>
 
</html>
 
<jsxgraph width="600" height="500">
 
<jsxgraph width="600" height="500">
newGraph(document.getElementById('graphterm').value)
 
 
 
var i;
 
var i;
 
var board = JXG.JSXGraph.initBoard('jxgbox', {originX: 300, originY: 200, unitX: 40, unitY: 40, axis:true});
 
var board = JXG.JSXGraph.initBoard('jxgbox', {originX: 300, originY: 200, unitX: 40, unitY: 40, axis:true});
Line 56: Line 56:
 
function newGraph(v) {
 
function newGraph(v) {
 
eval("term = function(x){ return "+v+";}");
 
eval("term = function(x){ return "+v+";}");
graph = function(x) { return term(x); }
+
graph = function(x) { return term(x); };
 
g.Y = function(x){ return term(x); };
 
g.Y = function(x){ return term(x); };
 
g.updateCurve();
 
g.updateCurve();

Revision as of 16:09, 3 February 2010

xo is the start value. Drag it.

You may change the function term here:
f(x) =
;