# User-defined objective function with scalar and vector inputs

**URL:** <https://discourse.julialang.org/t/user-defined-objective-function-with-scalar-and-vector-inputs/64218>\
**Category:** Optimization (Mathematical)\
**Created:** [July 7, 2021, 2:50pm UTC](https://discourse.julialang.org/t/user-defined-objective-function-with-scalar-and-vector-inputs/64218 "2021-07-07T14:50:12Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [July 7, 2021, 4:42pm UTC](https://discourse.julialang.org/t/user-defined-objective-function-with-scalar-and-vector-inputs/64218/2 "2021-07-07T16:42:25Z")

</div>

> [@mengxiaoliu](#):
>
> `contributions = zeros(n,1);`

The element type of this vector is `Float64`. See [ForwardDiff cannot assign ForwardDiff.Dual to input array](https://discourse.julialang.org/t/forwarddiff-cannot-assign-forwarddiff-dual-to-input-array/37522).

---

_[View the full topic](https://discourse.julialang.org/t/user-defined-objective-function-with-scalar-and-vector-inputs/64218)._
