# Question: Least square fitting method for non-linear function

**URL:** <https://discourse.julialang.org/t/question-least-square-fitting-method-for-non-linear-function/97595>\
**Category:** General Usage\
**Tags:** question, lsqfit\
**Created:** [April 18, 2023, 12:46am UTC](https://discourse.julialang.org/t/question-least-square-fitting-method-for-non-linear-function/97595 "2023-04-18T00:46:44Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![manu\_han](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/manu_han/32/47520_2.png) [@manu\_han](https://discourse.julialang.org/u/manu_han)\
**Post date:** [June 6, 2023, 6:47am UTC](https://discourse.julialang.org/t/question-least-square-fitting-method-for-non-linear-function/97595/3 "2023-06-06T06:47:32Z")

</div>

As follow your comment, I put an argument as an array having 4 elements.  
But it doesn’t work with the error as follows: MethodError: no method matching isinf(::Array{Float64, 3}).  
Cite: [How to use the array as the argument for curve-fit?](https://discourse.julialang.org/t/how-to-use-the-array-as-the-argument-for-curve-fit/99802)  
Is there a way to solve this problem?

other posts I cited:

> [@Curve fitting with LsqFit](https://discourse.julialang.org/t/curve-fitting-with-lsqfit/27685/5):
>
> Thank you! It is much clearer now. Yet, there is a new problem. Now i am trying to use a complex function with ternary operator: model1(t, p) = @.(p[1] \* exp(-p[2] \* t) + p[3] \* exp(-p[4] \* t) \* cos(p[5] \* t + p[6])+ p[7] \* (t \> p[8] ? 0 : (1 - t / p[8])^2)) The error i get is the following: ERROR: TypeError: non-boolean (BitArray{1}) used in boolean context Stacktrace: [1] model1(::Array{Int64,1}, ::Array{Float64,1}) at .\REPL[184]:1 [2] top-level scope at none:0 Many thanks in advance f…

> [@\[ANN\] JSON3.jl - Yet another JSON package for Julia](https://discourse.julialang.org/t/ann-json3-jl-yet-another-json-package-for-julia/25625/6):
>
> Nice, in that case the only thing I’d have done differently would be to have it fail more for other types.

---

_[View the full topic](https://discourse.julialang.org/t/question-least-square-fitting-method-for-non-linear-function/97595)._
