Skip to content

Convergence error for simple cases. #13

@mcanyucel

Description

@mcanyucel

Thank you for your work on this free library..
I was doing some tests before implementing it to my project, and I kept getting convergence error for simple quadratic functions.
For example, the code below finds the root 10 as expected:

		let x = 20;
		const fn = (x: number): number => Math.pow(x, 2);
		const fnParams = [x];

		try {
			const result = goalSeek({
				fn,
				fnParams,
				percentTolerance: 0.01,
				maxIterations: 1000,
				maxStep: 10,
				goal: 100,
				independentVariableIdx: 0
			});
			console.log("====root: " + result);
			console.log("====fn value: " + fn(result));
			
			
		} catch (e) {
			console.log("----" + e.message);
			
		}

But if I change the goal to 130, I get failed to converge error:

...
	goal: 130,
...

Any ideas or tips for quadratic or higher order polynomials?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions