Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: derivatives, syms and fsolve
Replies: 5   Last Post: Jul 22, 2013 1:27 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Shubham Gupta

Posts: 1
Registered: 7/2/13
Re: derivatives, syms and fsolve
Posted: Jul 2, 2013 2:50 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi Alan, The link you have replied is not working. could you please give a fresh link for the problem. I have a matrix with 15 symbolic variable and also the equation is in Non-linear form. Could you please suggest something to use FSOLVE for this equation which has syms variable

Thank You
Shubham Gupta

Alan Weiss <aweiss@mathworks.com> wrote in message <h4pcto$srj$1@fred.mathworks.com>...
> The problem you see is because fsolve requires standard floating-point
> numbers as inputs, but D is a symbolic object.
>
> To see an example of converting a problem from symbolic to float, and
> then solving with Optimization Toolbox, see
> http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/brn4nh7.html#brv_i_1
>
> FYI, to find the maximum likelihood solution, you don't need to take
> derivatives. Just minimize -lik. I believe that in general this will be
> more robust, because finding a zero of the gradient might find a
> stationary or even local minimum point.
>
> Alan Weiss
> MATLAB mathematical toolbox documentation
>
> Andrea Asoni wrote:

> > Hi,
> > I would like to define a function, take derivatives of this function and then solve the system of equations formed by putting these derivatives equal to zero. A simplified version of my problem is:
> > --------------------------------------------------
> > age =[12 13 14 15]; age=age';
> > sex =[1 1 0 0]; sex=sex';
> >
> > syms a b;
> > lik= (a^2)*b.*age + (1/b).*sex
> >
> > da=diff(lik,a); db=diff(lik,b)
> > D=[da; db]
> >
> > x=[a b]
> > fun=@(x) D
> >
> > init=[1 2]
> > fsolve(fun,init)
> > ---------------------------------------------------
> >
> > when I run this it gives me the error: "??? Conversion to double from sym is not possible."
> >
> > I tried to add after "D=[da;db]" the line "D=double(D)" but it gives me another error "Error using ==> eval
> > Undefined function or variable 'a'."
> >
> > I tried the function "double" in different places (on x, on D, on fun) but it always gives me an error message.
> >
> > Anyone knows how to deal with this problem? How do I take derivatives and then solve the system?
> >
> > Any help is very appreciated,
> > Andrea




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.