# NMinimize not working on custom function?

**URL:** <https://community.wolfram.com/t/nminimize-not-working-on-custom-function/17995>\
**Category:** Questions\
**Tags:** algebra, optimization\
**Created:** [April 20, 2021, 4:52pm UTC](https://community.wolfram.com/t/nminimize-not-working-on-custom-function/17995 "2021-04-20T16:52:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rafaelibanez](https://avatars.discourse-cdn.com/v4/letter/r/9dc877/32.png) [@rafaelibanez](https://community.wolfram.com/u/rafaelibanez)\
**Post date:** [April 20, 2021, 4:52pm UTC](https://community.wolfram.com/t/nminimize-not-working-on-custom-function/17995/1 "2021-04-20T16:52:27Z")

</div>

When defining the values of suma[x] as regression function I 'm able to obtain te true values of suma[x], when entering x manually.

Nevertheless when I try to Nminimize suma[x] it seems that this finction does not take the value of x

I willl thank a lot any suggestion

Thanks

[Open in Wolfram Cloud ↗](https://www.wolframcloud.com/obj/5bc73b34-f66b-4863-9d79-c2ebc536bcb5)

[INTENTO DE AJUSTE DE CONCENTRACION-3.nb](https://community.wolfram.com/uploads/short-url/9ntL7AXggZEgfD8rpd8Hal3VfnH.nb) (35.2 KB)

---

<div class="post-metadata">

**Author:** ![dontdont9](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@dontdont9](https://community.wolfram.com/u/dontdont9)\
**Post date:** [April 20, 2021, 8:51pm UTC](https://community.wolfram.com/t/nminimize-not-working-on-custom-function/17995/2 "2021-04-20T20:51:27Z")

</div>

I Remove the Quiet[]. When something is not working we want to see all warnings.

That shows there is a 1/0 problem that should be tracked down and fixed.

Next there are warnings about inexact, but I think those can be ignored.

Next it prints “Hola Null”

That goes away if I change Print["Hola ",x;]; to Print["Hola ",x];  
But then it only prints “Hola x”

You print “pHcalc { Log[H$257549]/Log[10],…” and that is possibly an  
an issue related to local variables inside of a Module.

If I remove the use of Module then the H$257549 are replaced with H.

Next there are lots of errors about “not a number” when x is negative.  
Those need to be tracked down and fixed.

Can you reproduce all those warnings and errors?

Can you see the reason for any of those and perhaps see a way to fix one or more of those?
