Derivativ of a function including if statements and consisting of multiple other functions

1 view (last 30 days)
Hey guys,
I have a problem derivating a very large function.
My function is very huge (9 variables, 40+ parameters, all deposited in structs) and very confusing which is why I cut it into pieces.
For the moment my function is written as a sum of those pieces, each representing a polynomial, whose individual results are added together in the end or in between
First Question: I wanted to derivate (partial) it with a symbolic function, but I am not sure wether it is possible to set up a sumbolic function wich consist of mulitple other function, or has the symbolic function to represent the whole function in one piece? In this case it would be very confusing writing the function which consists of like 200 lines of individual functions.
Many of this individual functions can be equal zero since the variables can be zero.
But one of the individual fucntions has the form of x*log(x)+y*log(y)+..... which leads to log(0)=-Inf and 0*log(0)=NaN. In my piecewise defined function I circumnavigate this problem with an if statement which sets x*log(x) equal 0 in the case x is 0.
Second question: If i want to derivate my function now, it is not possible to include this if statement into the symbolic function. So i have no glue how i would handle this case.
As I said a lot of parameters also do appear.
Third and last question: Do I have to define those parameters as symbolic parameters first, or is it somehow possible for the symbolic function to take thos parameters derictly from an array or struct defined outside of the symbolic function?
I hope that there is a way to solve this problem analyticaly with your help.
For now i tried to do it numerically but the double precision is not insufficient which leads to a "noisy" derivation.
Many thanks in advance.
Best regards
Marc

Answers (0)

Categories

Find more on Structures in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!