Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

maximize function over a range of constant

Status
Not open for further replies.

simyotic

Mechanical
Sep 26, 2008
3
Hi all,
I'm trying to find a way to find the maximum of a function for a range of coefficient/s
The simplified function is as follows:

0<x<1
f(x):=ax^3+6*x
I would like to get the x value for that makes f(x) maximum for a different values of "a" lets say a=0.01,0.02,...0.19

I know the function above is very simple there may be other solutions else than using maximize function. However the actual function is too large that it cannot display even the first derivative.

Any ideas?
thanks in advance
 
Replies continue below

Recommended for you

Sounds like you're asking for the symbolic solution; why? Your problem statement reads like a numerical problem.

TTFN

FAQ731-376
 
I'd do something like make the function a function of a and x. Then iterate both a and x to create a matrix. The maximum in each row or column of the matrix could be found with the max() function.
 
Why wouldn't you solve it as you would by hand, ie differentiate it symbolically, find where differential =0 (perhaps by using polyroots), then check whether it is max or min?










Cheers

Greg Locock

SIG:please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
Thanks all for the replies
I'm not asking for a symbolic solution.
The reason I mentioned about taking the first derivative and so on was because, it(derivative=0 ->solve block for a range of constants) is another way to find the maximum of the f(x) for a given "a" value. Which is not feasible for me.

What I'm trying to do is to use maximize function in mathcad with a range of constants Is this possible?

In other words let me write down which is not working
i:=0,0.001..0.19
b:=0.2
f(x):=a(sub i)x^3+6*x
Given
0<x<1

maximize(f,x)
=I would like to get the maximum for different a values as a list instead of changing value of "a" every time.
 
Yes, my approach does just that.

Cheers

Greg Locock

SIG:please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
You assign func(i) := maximize(f,x)
then func(i)= will display results for each i

HOWEVER, subscripts cannot be fractional
so, i := 0;19
a[i := i*.01

TTFN

FAQ731-376
 
I think Greglocock has the right idea.
However...
simyotic said:
The reason I mentioned about taking the first derivative and so on was because, it(derivative=0 ->solve block for a range of constants) is another way to find the maximum of the f(x) for a given "a" value. Which is not feasible for me.
Use the minerr function. Normally the minerr function is used to minimize error. Therefore you must subtract your f(x) from some constant that will not be exceeded. I have found minerr works better than minimize. In your example 'a' will always be bigger at x=1. Do you have a better example? It would be good to know what you are really trying to do.

Here is an example of finding coefficients of a differential equation that minimize the integrate absolute error. This is used in control. Note, I couldn't simply take the derivative of the resulting equation and find the minimum so one must use an optimizer.
ftp://ftp.deltacompsys.com/public/NG/Mathcad%20-%20IAE3.pdf

I have an equations where IAE(A1,A2) = 0. That is because I am trying to get the error close to 0. In your case you need to replace the IAE(A1,A2) with f(a,x) = C. Where C is a constant you will approach but not reach.

Better yet is to convert your f(a,x) to minimize error so you can just use f(a,x) = 0 like I did.

Note, my worksheet allows me to find the coefficients for any linear third order differential equation.









 
Thanks all again,
I'm uploading one of the files that I'm working on, in principle it is the same as a f(x):=a(sub i)x^3+6*x.

IRstuff:
What you wrote in the reply is exactly what I'm looking for but I couldn't manage to get it through would you mind uploading an example file for me? Because this is where I'm puzzled: Can we use a range variable in Maximize function in Mathcad.

GregLocock:
The reason I don't want to use your approach is to avoid large equation size When I substitute x with another function lets say substitute every x with exp(2.32*(x^2-1) etc it would be even larger. Infact I should do it for 16 different functions and that's why I'm trying to avoid it.

PNachtwey:
I'm amazed with your file however I'm a bit newbee and I'm a bit lost in that. Probably the question I'm asking for you (and everyone here) is very simple but as I said I'm at the very begining. On the other hand we are working on the same thing in a sense (this function is the excess flow in a 3 way control valve when you have different circuit pressure ratios and valve authority (alfa and beta) for different opening of the valve x). It is nice to meet you.

Thanks all again.
regards
 
 http://files.engineering.com/getfile.aspx?folder=cdb87de2-e245-4aec-9996-ae2495855d1a&file=maximize.xmcd
Status
Not open for further replies.

Part and Inventory Search

Sponsor