If you don't have any initial guess that works, but it seems reasonable that a solution should exist, then rewriting the problem to solve for one fit variable at a time may also work. If there isn't a solution, this process is a fair bit more likely to show that than FindRoot
is as well.
f[a_,b_,c_] := a-b Exp[-# c]& (* this defines the family of functions of f *)
Solve for b
by implementing the gradient constraint at the first x point.
solb = First@Solve[f[a,b,c]'[x1]==g,b]
Solve for a
by implementing the y value constraint at the first x point and the b constraint.
sola = First@Solve[f[a,b,c][x1]==y1/.solb,a]
Solve for c
by implementing the y value constraint at the second x point and the previous 2 solutions.
solc = First@Solve[f[a,b,c][x2]==y2/.solb/.sola,c]
Now insert the numerical parameters:
params = {x1->1400,x2->4000,y1->0.129417,y2->0.26304,g->0.0002219136};
And expand the previous solutions:
nc = solc/.params;
nb = solb/.params/.nc;
na = sola/.params/.nc/.nb;
nsol = Flatten[{na,nb,nc}]
nsol
should contain {a->0.26496,b->1.3413,c->0.00163721}
.
(f[a,b,c]/.nsol)[x]
will generate the final function in terms of x.
In my experience normally if this process would work, then Solve
is probably able to solve a symbolic version of this problem as well, but that doesn't appear to be true in this case.
FindRoot
. $\endgroup$ – Sumit Oct 27 '17 at 17:29