Need advise: Is my implementation good ?
Info
This question is closed. Reopen it to edit or answer.
Show older comments
Hi, is my MATLAB code (please look below in my EDIT) good for solving this problem?
________________________________________________________________________________
This was the original question:
Hello, I have a question concerning differentiation and integration of multivariate functions. I am tryling to implement this in MATLAB:
1) We have a function in two variables, for example f(x,y):= x^2 exp( -(x-y)^2 )
2) First I want to differentiate it several times wrt to the second variable, lets say g(x,y) := (d/dy)^5 f(x,y)
3) Afterwards I fix y and integrate wrt to x. For example integrate g(x,0) over (-\infty,\infty)
My approach was to calculate the function g by hand and do the integration wrt to x with quadgk. Due to the fact that I need many different orders of derivatives this is really ineffective ... Can anyone please help me out ? Thanks !!
______________________________________________________________________
EDIT: The way I think it should work. MATLAB-Code:
syms x y;
fun = x.^2 exp( -(x-y).^2 );
for j=0:10;
FUNC = inline(diff(fun,y,j));
L = @(x) FUNC(x,0);
quadgk(L, -inf, inf,'RelTol',1e-8,'AbsTol',1e-12)
end;
Is this a good way? Any opinions of advanced MATLAB users ? Thanks
Answers (1)
Alan Weiss
on 23 Jan 2014
0 votes
Do you have Symbolic Math Toolbox?
If not, are you supposed to differentiate and integrate numerically or symbolically?
Alan Weiss
MATLAB mathematical toolbox documentation
1 Comment
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!