I need your help to code this New Secant Method into Javascript.
The secant method uses two starting parameters, while this new method require only one starting parameter.
Thank you in advance.
Thank you for your answer [ed: comment], here is what i have tried, but it dosn't work :
<script>
var x
var pi = 3.141592653589793, e = 2.7182818284590452;
function meth_sec() {
with (Math) {
f = "sin(x)-x/2"; a = 1; s = 1;
f = prompt("your function f(x) = ", f)
while (s >= 0) {
a = eval(prompt("type the approximation. = ", a))
x = a;
}
}
} function iter() {
with (Math) {
y = eval(f)
x = a + (abs(y)/2) - abs(y)*((y(a+abs(y/2)))/((y(a+abs(y/2)))-y)
return x
}
}
function sgn(y) { return (y > 0) - (y < 0) }
</script>