I'm trying to find a method in R which allows the parameters (a, b, c) of the general equation a*b^x c which provides the best fit to 3 constrained random coordinates/points (p1, p2, p3 - with coordinates x1/y1, x2/y2 and x3/y3 respectively).
The constraints to these coordinates are:
- x1 and y3 are both equal to 0
- x3 and y1 are randomly both randomly selected, and less than 1
- x2 is assigned a random value less than x3
- y2 is assigned a random value less than y1
I want to find a method which is able to generate values for a, b, and c which produces a line close to p1, p2 and p3. This is simply using desmos (see here for an example -
Now use optimize()
for 1D optimization (we still need to specify a starting interval, although not a specific starting point).
optimize(target, c(-10000, 1000000))
Results:
$minimum
[1] 58928.93
$objective
[1] 2.066598e-20