I am interested in calculating how the roots of an equation change as one of the variables does, when the equation is evaluated numerically rather than symbolically. I have edited this code to be simpler than the original one.

d = 1/1000; mig = 1/500; kappa = 1/10;
N1[x_] = 50*(1 + 17/100*x - mig);
Estar[x_] = (d)/(kappa*mig*N1[x]);
lambda[x_] = mig*N1[x]*(1 - Estar[x]);
I1star[x_] = kappa*Estar[x]*(1 - Estar[x])*mig*N1[x]/d;
M1[q_, t_, z_] = Sum[z^(n)*d*E^(-t*d)*E^(-N1[q]*mig*t)*(N1[q]*mig)^n*t^n/n!, {n, 0, 
Part1[q_, z_] := NIntegrate[M1[q, t, z], {t, 0, Infinity}]
RootFcn[q_, z_] := (1 - Estar[1]) + Estar[1]*((1 - kappa) + kappa*Part1[q, z]) - z

The question I'm interested in is how the solutions for z of (RootFcn[q,z]=0) change as q increases at the point q=1. There are two roots, 1 and a value between 0 and 1; the smaller value is the one that I'm interested in. If one uses Integrate in the above instead of NIntegrate, they can simply take the solution of Solve[RootFcn[q, z] == 0, z], and use D[] to get the derivative where q=1 (which yields -0.00124613). However unfortunately in my actual problem this is not possible to do as it's more complicated and cannot be evaluated symbolically; and NIntegrate must be used. Also I cannot use the definition of a derivative (Solving for RootFcn at arbitrarily close values and divide by some epsilon), because in my problem it is too time-consuming due to the very high precision required to get a reasonable answer. So each time I numerically evaluate Solve[RootFcn[q, z] == 0, z] it takes a few minutes but since I will have to solve an equivalent problem to this derivative question thousands of times, this is prohibitive. It seems like this is probably possible using numerical derivatives, but I'm not sure. Any help would be very appreciated.

  • 3
    $\begingroup$ Is this the simpler example of your problem you could find? $\endgroup$ – Dr. belisarius Feb 19 '14 at 4:44
  • $\begingroup$ I have now simplified the problem. The reason I had not done this before is that it is easy to solve if it can be solved symbolically, but I just stated this in the question that the actual problem can't be. I hope this is more clear. $\endgroup$ – mike Feb 20 '14 at 0:44
  • $\begingroup$ Well done, thanks $\endgroup$ – Dr. belisarius Feb 20 '14 at 0:47
  • $\begingroup$ @mike Let me try to rephrase this in a simple way. Let me know if this is correct: We have a relationship between $x$ and $y$ in implicit form: $f(x,y)=0$. The function $f$ is a numerical black box. $y$ may have multiple solutions in terms of $x$. How can we calculate the derivative $y'(x)$ at a given point $x=x_0$? $\endgroup$ – Szabolcs Feb 20 '14 at 0:49
  • $\begingroup$ Yes that is correct. $\endgroup$ – mike Feb 20 '14 at 1:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.