For example:
var a=8;
var b=6;
function c(a,b) {
return a*b;
}
And now I want that "c" will return me 56 and I want to do that only
by changing "b" and this "goal seek" function will return me solution
that "b" must be equal 7
I hope I didn't explain too chaotic.
I tried to find that on google but without any results.
Thanks in advance
Michael
Perhaps this for a start:
http://en.wikipedia.org/wiki/Newton%27s_method
Gregor
--
http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
http://web.gregorkofler.com ::: meine JS-Spielwiese
http://www.image2d.com ::: Bildagentur für den alpinen Raum
>For example:
>var a=8;
>var b=6;
>function c(a,b) {
> return a*b;
>}
>
>And now I want that "c" will return me 56 and I want to do that only
>by changing "b" and this "goal seek" function will return me solution
>that "b" must be equal 7
Go to <URL:http://www.merlyn.demon.co.uk/js-demos.htm#FZ>, insert
in the textarea
function c(a,b) { return a*b; }
c(8, X) - 56
put Min X =, say, 0 and Max X = 50, press Find, and read the answer.
Then read the whole page, and View Source to find out how it is done :
it uses
function FindZero(F) { with (F) {
var j, X, XV, HV, LV, Fn = EX1.value
var Lo = userIn(Min1), Hi = userIn(Max1)
X = Lo ; LV = eval(Fn)
X = Hi ; HV = eval(Fn)
if ((LV*HV)>=0) { Ans1.value="Bad bounds" ; return }
for (j=0; j<40; j++) {
X = (Hi+Lo)/2 ; XV = eval(Fn) ; if (XV==0) break
if ((XV*LV)<0) { Hi = X ; HV = XV } else { Lo = X ; LV = XV }
}
Ans1.value="X = "+SigFigExp((Hi+Lo)/2, 8) } }
It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk IE7 FF2 Op9 Sf3
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
> It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
It's not that I didn't read. I just couldn't find.. Maybe because my
"question" was bad :)
Thanks again
Michael