Square Root
Код скрипта
<HTML>
<HEAD>
<TITLE>Square Root</TITLE>
<SCRIPT LANGUAGE="LiveScript">
<!-- Hide from old browsers
// Chris Englmeier <machin@mindspring.com>
// feel free to use this script as long as this text remains intact
// http://www.geocities.com/SiliconValley/Heights/2052
// Copyright 1996 Chris Englmeier
function Newton(Input){
// f(x) = x*x - Input.value
// f'(x) = 2*x
var X = 1;
var FX = X*X - Input.value;
for (var i = 0; i < 10; i++) {
X = X - FX/(2*X);
FX = X*X - Input.value;
}
Input.value = X;
return true;
}
function ClearForm(form) {
form.Sqr.value = "";
}
<!-- done hiding from old browsers -->
</SCRIPT>
</HEAD>
<BODY bgcolor="#FFFFFF">
<CENTER><H1>Square Root</H1>
<p>
<hr>
<b>
<FORM METHOD=POST>Input value to Square Root:
<p>
<INPUT TYPE=TEXT NAME=Sqr SIZE=10 MAXLENGTH=10 onFocus="ClearForm(this.form)">
<p>
<INPUT TYPE="button" VALUE="Calculate" onClick="Newton(this.form.Sqr)">
</FORM><BR CLEAR=ALL>