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: Calculating 1st derivative with a parameter
Replies: 4   Last Post: Jun 14, 2012 10:34 AM

Advanced Search

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

Posts: 8
Registered: 5/7/12
Re: Calculating 1st derivative with a parameter
Posted: May 6, 2012 4:14 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Angie" wrote in message <jo68l4$jq1$1@newscl01ah.mathworks.com>...
> "Angie" wrote in message <jo689r$idb$1@newscl01ah.mathworks.com>...
> > "Wojtek" wrote in message <jo61cj$m95$1@newscl01ah.mathworks.com>...
> > > Hello,
> > > in my program I want to calculate the 1st derivative of a function y (it's a function of 'x1'). Let's say I want to check if the 1st derivative of this function in some specific point is smaller then 0.05. I have:
> > >
> > > syms x1;
> > > y = ( x1 - za )*( x1 - zb )*( x1 - zc )*( x1 - zd ); %my function, all the parameters like 'za' were previously declared
> > >
> > > dydx=diff(y,x1,1);
> > >
> > > x_val=1;
> > > dydx_val=subs(dydx,x1,x_val);
> > > k2 = solve(dydx_val);
> > > dydx_val =double(k2);
> > >
> > > if (dydx_val<0.05)
> > > remember=x_val;
> > > end
> > >
> > >
> > > unfortunately the derivative is not calculated. I get information:
> > > Warning: 1 equations in 0 variables.
> > > Warning: Explicit solution could not be found.
> > > and when I try to display dydx_val i get:
> > >
> > > dydx_val =
> > >
> > > []
> > >
> > > I tried different methods, none of them was good (although I could do something wrong). I will be grateful for suggestions how can I calculate 1st derivative in a specific point and have the value of this derivative in double.

> >
> > Hello,
> >
> > If I understood your question correctly, you don't need the line for solve and the following seems to work for me:
> >
> > syms za zb zc zd x1;
> > y = ( x1 - za )*( x1 - zb )*( x1 - zc )*( x1 - zd );
> >
> > xVal = 1;
> >
> > % Take the derivative and substitute the value of x1
> > focValue = subs(diff(y,'x1'),x1,xVal);
> >
> > if focValue < 0.5
> > remember = focValue;
> > end
> >
> > I hope this helps,
> >
> > A.

>
> Correction and I forgot to mention something else:
> 0.05 instead of 0.5 and I assume you have numerical values for your za,zb,zc,zd parameters. In other words, if you put numerical values for za,zb,zc,zd (instead of syms za zb ...) you should be able to get your result.
>
> A.


Hi, thanks for the answer!
Unfortunately when doing it your way I get an error:

??? Error using ==> sym.sym>notimplemented at 2653
Function 'lt' is not implemented for MuPAD symbolic objects.

Error in ==> sym.sym>sym.lt at 812
notimplemented('lt');

Error in ==> myfile at 77
if (dydx_val<0.05)

Additionally when I try to display the value of dydx_val I get:

dydx_val =

-(289129866313728*D(ceil)(965535013052404736/3125))/125



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.