You could also request that the function be updated to handle symbolic variables for the order of integration input. I'd recommend that you file a service request with The MathWorks to report this issue. In my opinion, sym/diff should throw an error if it has this limitation rather than returning garbage. MuPAD's related functions have similar limitations as well unfortunately. The order, n (or i in your code) is also limited to a scalar. In other words, the function doesn't support symbolic variables to specify the order of integration. Why does diff(f,x,i) evaluate to zero even though i is symbolic? From the documentation for sym/diff:ĭiff(S,n), for a positive integer n, differentiates S n times.ĭiff(S,'v',n) and diff(S,n,'v') are also acceptable. % Convert yi back to symfun so output is symfun % Calculate next derivative from previous Yi = % To index into array, yi cannot be symfun N = 0:2 % Increasing orders of differentiation Just use a for loop ( sym/diff is not vectorized in the third argument – see below): syms x y Īlternatively, you could try this form (in this case, for just three indexes, the above will probably be more efficient): syms x y When using symsum, you need to be aware that, like with any Matlab function, the input arguments will be evaluated before being passed in. For real positive numbers, the logarithm of a product equals the sum of the logarithms of its factors. This occurs because diff(f,x,i) evaluates to zero. Combine terms with logarithms by specifying the target argument as log.
0 Comments
Leave a Reply. |