i have a problem ,
1 次查看(过去 30 天)
显示 更早的评论
A summary of what I want to do . i have function of 3 parameters L=f(x,y,z). i need differential this function with respect to x , y and z , and equality them by zero. Hence we get three equations in three parameters , Give initial values of the three parameters. In the first equation, which is where the differentiation for x we substitute only about y and z to get x value . By this logic with the y and z . what to do ?
2 个评论
John BG
2016-12-24
let the readers work on the equations by making them available here, either copy them or attach the MATLAB script with the equations.
Walter Roberson
2016-12-25
I suspect that this is a duplicate of http://www.mathworks.com/matlabcentral/answers/317954-i-have-function-l-and-initial-values-phi1-phi2-and-seta-i-want-to-be-derivative-this-function-a
回答(2 个)
Roger Stafford
2016-12-24
If the derivatives of f with respect to x, to y, and to z are always zero, that means f must be a constant. Whatever the initial conditions for f(x,y,z), f must remains fixed at that initial condition.
3 个评论
Roger Stafford
2016-12-24
@Star. I interpreted his statement, “i need differential this function with respect to x , y and z , and equality them by zero” to mean “I need to differentiate this function with respect to x, y, and z, and to equate these derivatives all to zero”, which doesn’t sound like a problem in optimization.
Walter Roberson
2016-12-24
I read it as wanting to solve for the point where the three partial derivatives are all zero.
However it is not necessarily a minimization since the partials would also all be zero at maxima or saddle points.
John BG
2017-1-4
1.
try function gradient on the function f(x,y,z) to obtain the 3D function to solve
note that gradients (AKA directional derivatives) vary according to the chosen coordinate systems:
2. to solve the gradient.
define the resulting function out of gradient with gradf(x,y,z) , in example:
function t1=fun1(x)
t1=exp(-x(1).^2-x(2).^2-x(3).^2)
and then
problem.objective=@fun1
problem.x0=[0 0 0]
problem.solver='fsolve'
problem.options = optimoptions('fsolve','Display','none','PlotFcn',@optimplotfirstorderopt);
fsolve(problem)
is it possible for you to supply along your question the function that you want to calculate the gradient and solve?
.
if you find these lines useful would you please mark my answer as Accepted Answer?
To any other reader, if you find this answer of any help please click on the thumbs-up vote link,
thanks in advance for time and attention
John BG
1 个评论
Walter Roberson
2017-1-4
The user is looking to create three equations: 1) the gradient of arbitrary function f with respect to x, in terms of only y and z; 2) the gradient of f with respect to y, in terms of only x and z; and 3) the gradient of f with respect to z, in terms of only x and y. The user then wants to solve those three equations simultaneously.
Unfortunately, in the general case, the gradient of a function with respect to a variable typically involves the variable as well.
A modification would be to take the gradient with respect to x, and solve that gradient equal to 0 with respect to x, and then to substitute that x into the gradient with respect to y. Then that gradient could be solved equal to 0 for the variable y. Then substitute the x found into the gradient with respect to z, and then substitute the y found into that, giving a gradient with respect to z that involves only the variable z; you can then equate that to 0 and solve for z. You can then back substitute to get y, and then back substitute the z then y to get x. There would generally be multiple solutions as the solutions would include all of the maxima, all of the minima, and all of the saddle points.
The procedure I describe is not what the user asked to do: the user expected the x to disappear automatically from the gradient with respect to x, and so on, leaving three equations in two variables each that could then be numerically solved for.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Quadratic Programming and Cone Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!