Evaluating double integral with unknown variable in
Mostrar comentarios más antiguos
Hi,
I am trying to evaluate a double integral of x,y with an unkown constant c. The result for c should resemble a binomial distribution. I am trying to solve this using integral2 as follows:
fun = @(x,y)(((c-y+x)^50)*((1-c+y-x)^3280)*(y^50)*((1-y)^130)*((x^16)*((1-x)^3308)))
xmax = @(y)(1-c+y)
xmin = @(y)(y-c)
q = integral2(fun,0,1,xmin,xmax)
But I get a list of errors:
Unrecognized function or variable 'c'.
Error in stupidstupid>@(y)(y-c) (line 3)
xmin = @(y)(y-c)
Error in integral2Calc>integral2t/tensor (line 189)
bottom = YMIN(x);
Error in integral2Calc>integral2t (line 55)
[Qsub,esub] = tensor(thetaL,thetaR,phiB,phiT);
Error in integral2Calc (line 9)
[q,errbnd] = integral2t(fun,xmin,xmax,ymin,ymax,optionstruct);
Error in integral2 (line 106)
Q = integral2Calc(fun,xmin,xmax,yminfun,ymaxfun,opstruct);
Error in stupidstupid (line 4)
q = integral2(fun,0,1,xmin,xmax)
I think this has to do with the fact that I have not define the variable c, but I do now know how to define it. Any help would be greatly appreciated. Thanks in Advance!
3 comentarios
VBBV
el 10 de Oct. de 2020
Editada: Walter Roberson
el 10 de Oct. de 2020
Use syms to define it as symbolic variable
syms c
Tron
el 10 de Oct. de 2020
Walter Roberson
el 10 de Oct. de 2020
integral() and integral2() require that the function returns a numeric value. They are adaptive numeric integrations and need the numeric values to figure out whether they need to refine further.
Respuestas (1)
Walter Roberson
el 10 de Oct. de 2020
0 votos
you can never use integral() or intrgral2() when you have undefined variables. You have to use symbolic integration and hope that matlab can solve it.
3 comentarios
Tron
el 10 de Oct. de 2020
Walter Roberson
el 10 de Oct. de 2020
It is not necessarily impossible to integrate symbolically, but symbolic integration will probably require expanding out the (1-x)^3308 and (1-c+y-x)^3280 and so on, and doing all of the polynomial multiplications, and finally doing the integration.
Those are really large powers... how did they originate ?
Walter Roberson
el 10 de Oct. de 2020
My tests suggest that the final result would be a polynomial of degree 16+3308 = 3324. where those numbers come from ((x^16)*((1-x)^3308))
Categorías
Más información sobre Calculus en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!