Newton's root finding method: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
Line 8: Line 8:
<td>
<td>
<form>
<form>
<input style="border:none; background-color:#efefef;padding:5px;margin-left:2px;" type="text" onchange="newGraph(this.value);" value="x*x"  size="40"/>
<input style="border:none; background-color:#efefef;padding:5px;margin-left:2px;" type="text" id="graphterm" value="x*x"  size="40"/>
<input type="button" value="set function term" onClick="newGraph(document.getElementById('graphterm').value)">;
</form>
</form>
</td>
</td>
Line 14: Line 15:
<script type="text/javascript">
<script type="text/javascript">
// Initial function term
// Initial function term
function term(x) { return x*x; }
var term;
//function term(x) { return x*x; }
// Recursion depth
// Recursion depth
var steps = 11;
var steps = 11;
Line 33: Line 35:
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'});
function graph(x) { return term(x); }
 
//function graph(x) { return term(x); }
newGraph(document.getElementById('graphterm').value);
newton(x,steps);
newton(x,steps);
function xval(board) {
function xval(board) {

Revision as of 14:05, 3 February 2010

xo is the start value. Drag it.

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