cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

A problem of vectors and functions, please help

LemnosOreoda
5-Regular Member

A problem of vectors and functions, please help

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

1 ACCEPTED SOLUTION

Accepted Solutions

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

 

View solution in original post

9 REPLIES 9

May by so

minimize.png

LemnosOreoda
5-Regular Member
(To:ValeryOchkov)

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

 

Minimize and Maximize work only with Differentiable function!

You can do so:

minimize1.png

LemnosOreoda
5-Regular Member
(To:ValeryOchkov)

thanks for your answer, It seems to me a good alternative way to evaluate the maximum values, but I would like to know why the values of the maximize function varied and did not coincide in an answer

 

LemnosOreoda_0-1597504058621.png

it tells me that a conditional expression cannot be evaluated 😞

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

 

LemnosOreoda
5-Regular Member
(To:Fred_Kohlhepp)

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.

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

Werner_E_0-1597507624334.png

 

Here is another (clumsy and sure not satisfactory) workaround for this Prime bug using the built-in "localmax" function:

Werner_E_0-1597526873671.png

 

LemnosOreoda
5-Regular Member
(To:Werner_E)

Thanks for your answer, it is true there are some errors that the new version has fixed, I was also testing and now it allows me to vectorize the function with a small program evaluating the function in a certain domain and grouping the answers in a vector, this I could not do it in the older version.

Regarding the solution that you propose for maximums and minimums, the localmax function does not seem awkward to me, it is the one required to find not only a maximum point of a range. Thank you

Top Tags