Skip to main content
1-Visitor
August 15, 2020
Solved

A problem of vectors and functions, please help

  • August 15, 2020
  • 2 replies
  • 3976 views

Hello ptc community

I have tried to find the maximum value of a function evaluated in a defined range, however the max or min function can only be applied to vectors. I would like to know if there is a function or some way that allows me to obtain the maximum value of a function. I try to vectorize the results as attached in the example, however this is limited to functions lacking units as far as I could see. I would appreciate any help

LemnosOreoda_0-1597488569573.png

This is the function that I have been working on, it is only referential but with this I wanted to imply that I prefer to use units during the calculation. (for more details see the attached sheet)

LemnosOreoda_1-1597488569579.png

 

here I show how it is possible to vectorize a function already evaluated in a defined range

LemnosOreoda_2-1597488569585.png

but the above is not possible if units are used

Best answer by Fred_Kohlhepp

You cannot use a range with a unit assigned as an index to a vector.  (Ranges are for plotting and indexing!)  But you can create a vector that mimics the same range with your units:

FredKohlhepp_0-1597496808197.png

 

2 replies

24-Ruby IV
August 15, 2020

May by so

minimize.png

1-Visitor
August 15, 2020

well it seems that it was something simple xD, thanks
But since we are here, I would like to know that it takes into account the maximize function, although the first requirement argument is the function, the second argument is a value that remains to be defined by the user that will give me a local maximum of the evaluated function. In the case of evaluating M_k with a parameter between 0 and 10, it gives me a value of 3 that corresponds to the maximum value of the function between that range, but if I wanted the second value that corresponds to 4.
Now if I assign a value between 11 and 20 as a parameter, it should give me 21, which corresponds to the maximum value, however, sometimes it gives me 19.5, sometimes 19. Why is this? Although this is a problem of maximums and minimums in a function, I am not allowed to apply derivatives since the function is generated from conditionals.

LemnosOreoda_0-1597492693833.png

LemnosOreoda_1-1597492726073.png

 

24-Ruby IV
August 15, 2020

Minimize and Maximize work only with Differentiable function!

You can do so:

minimize1.png

23-Emerald I
August 15, 2020

You cannot use a range with a unit assigned as an index to a vector.  (Ranges are for plotting and indexing!)  But you can create a vector that mimics the same range with your units:

FredKohlhepp_0-1597496808197.png

 

1-Visitor
August 15, 2020

Yes, that was my mistake, I was using a range with a unit assigned as the index of a vector, which is meaningless, I didn't understand how this type of vectorization worked. I already understood it, thank you very much. Now I only have the doubt of why the maximize function gave those results.

25-Diamond I
August 15, 2020

Looks like you found a bug in Prime 5 which is already fixed in Prime 6:

Werner_E_0-1597507624334.png