Lab: 2 (Newton-Raphson Method)
<html>
<head>
This is Lab-2 on Numerical Analysis (CSE-304)</br>
Date: 21.06.2013</br>
</head>
<body>
<h1>Newton-Raphson Method:</h1>
<button id="button1" onclick="button1onclick()">Show Table</button>
<p id="table"></p>
<p>Root of the Equation: <span id="root"></span></p>
<script>
function f(x)
{
return x*x*x-x-1;
}
function fd(x)
{
return 3*x*x-1;
}
x=1;
tab="";
for(i=0; i<=10; i++)
{
x=x-f(x)/fd(x);
tab=tab+i+"    "+x+"</br>";
}
document.getElementById("root").innerHTML=x;
a=1;
function button1onclick()
{
if(a==1)
{
document.getElementById("table").innerHTML=tab;
document.getElementById("button1").innerHTML="Hide Table";
a=0;
}
else
{
document.getElementById("table").innerHTML="";
document.getElementById("button1").innerHTML="Show Table";
a=1;
}
}
</script>
</br>
</br>
</br>
Coded by : </br>
M.Shawon</br>
Roll No: 09</br>
Batch: CSE E-27th</br>
</body>
</html>
Download .html format from Hacker Box