0
$\begingroup$

I have an equation that is of one variable lat and has a numerical integration in it t from 0 to 1.

Let's say it's given by NIntegrate[f(lat,t),{t,0,1}]. Now, I want to solve the equation for variable lat given NIntegrate[f(lat,t),{t,0,1}] == c where c is some constant value. Solve[] clearly doesn't work, is there a way to do this without implementing a loop guessing values?

$\endgroup$
2
$\begingroup$

FindRoot might work, but you haven't given an example problem. Making one up:

f[lat_, t_] := lat t^2
c = 5

FindRoot[NIntegrate[f[lat, t], {t, 0, 1}] - c, {lat, 1}]
(* {lat -> 15.} *)

Mathematica complains, but it gives the right answer.

NIntegrate[f[lat /. %, t], {t, 0, 1}]
(* 5. *)

A more complicated f may not work as well and you may have to play around with starting values.

| improve this answer | |
$\endgroup$
  • $\begingroup$ thank you sir this works! $\endgroup$ – Houndbobsaw Aug 24 '19 at 1:22
  • $\begingroup$ I'm glad it helps. $\endgroup$ – Bill Watts Aug 24 '19 at 1:46

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.