# Equation solving for approximate solutions when function has numerical integration in it

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?

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.

• thank you sir this works! – Houndbobsaw Aug 24 '19 at 1:22
• I'm glad it helps. – Bill Watts Aug 24 '19 at 1:46