# Nonlinear solver and interpolation of array data

**URL:** <https://discourse.julialang.org/t/nonlinear-solver-and-interpolation-of-array-data/36187>\
**Category:** General Usage\
**Created:** [March 19, 2020, 2:30pm UTC](https://discourse.julialang.org/t/nonlinear-solver-and-interpolation-of-array-data/36187 "2020-03-19T14:30:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jleman](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jleman](https://discourse.julialang.org/u/jleman)\
**Post date:** [March 19, 2020, 2:30pm UTC](https://discourse.julialang.org/t/nonlinear-solver-and-interpolation-of-array-data/36187/1 "2020-03-19T14:30:57Z")

</div>

I am using NLsolve to solve a single nonlinear function V = f(V,I), where V is the unknown voltage and I is a given current. The equation involves constraint by an arrester volt-current characteristic curve which I am approximating with an exponential function as shown in the plot below:

![ArresterVICurve](https://global.discourse-cdn.com/julialang/original/3X/6/7/673fd31b06395fd685ad0061a1dbe52da4f68106.png)

The functioning code block is:

```julia
using NLsolve

I = 8100 #current
A = 613.05 #constant coefficient = constant x Current
B = 466.811 #constant coefficient
Vguess = 7.0e5 #guess voltage
RL = 10e6 #parallel resistor

#nonlinear solver with exponential curve approximation of VI data
function f!(F, V)
    F[1] = V[1] * (1 + A * I / RL) + (B) * 0.5 * exp(9.7e-6 * V[1]) - A * I    
end

Vout = nlsolve(f!,[Vguess]).zero

```

The result is 990784.145

This works, but as is evident in the plot above, the error for certain regions on the curve is rather high. I would like to use the measured data in the nonlinear solver with the solution obtained by interpolation. Does anyone know how that could be done using NLsolve, some other nonlinear solver, or some other method?

```julia
#Measured Data:
IData = [0,1000,2000,3000,5000,10000,20000,40000]
VData = [0,819300,849500,871000,907000,955000,1052000,1153000]

#Fitted Exponential Curve:
#I = 0.5 * exp(9.7e-6 * V)

```
