No, that is not going to have any closed form solution.
One suggestion in the comments was to try vpaintegral. If it does not exist for you, then you either need to upgrade your version of MATLAB, or convert this to a double precision problem instead, then use integral. But integral will fail to yield anything useful, I predict. Even if it returns a number, that number will surely be random numerical garbage.
Anyway, even vpaintegral has issues with that kernel.
vpaintegral(k213,.5,1)
Error using sym/vpaintegral (line 202)
Failed precision goal. Try using 'MaxFunctionCalls'.
So lets look at what you have.
fun = matlabFunction(k213);
fplot(fun,[.5,1])
When I finally stop laughing at the idea of using a numerical integration to integrate that, I'll just wish you good luck. Perhaps you have a friend, Don Quixote, who may have more success at the effort. He always was good at tilting at windmills.
The point is, all of those singularities are going to drive any numerical integration insane. And since a symbolic integral will surely not exist, perhaps you shoild consider if you really need to solve the problem at all. Not all problems you can pose have solutions.
If you really need to solve this, you might consider trying to identify the singularities. I see only 5 of them in the interval of interest. Isolate tham, then work on each one individually.
Basic calc? I hope this is not homework. But at least you made some effort.
You have formulated the problem as
q = int( int( a*x^2 + b*y^2,0,2*x*k), 0,5)
Where a, b, q are all known. The problem is, you want to solve for k, where k is part of that upper limit on y. We can do this on paper, at last most of it, but easy enough to do entirely in MATLAB too.
syms x y k
q = 125;
a = 0.5;
b = 0.1;
The symbolic toolbox is smart enough to recognize the decimal values 0.5 and 0.1 as their true fractional equivalents.
We can do the inner integral on y easily enough.
int(a*x^2 + b*y^2,y,0,2*x*k)
ans =
(k*x^3*(4*k^2 + 15))/15
So we should see the double integral is simple too.
Now, could I have done that on paper? Yes, except for the last part, where I'd probably have thrown the cubic polynomial into roots to solve.
expand(dubint)
ans =
(125*k^3)/3 + (625*k)/4
>> roots([125/3 0 625/4 -125])
ans =
-0.353057590126266 + 2.03075084287495i
-0.353057590126266 - 2.03075084287495i
0.706115180252531 + 0i
Could you have done it without using the symbolic toolbox? Yes. It is a bit easier to do the integration symbolically, and I am a bit lazy. I'd certainly have done the integrations on paper as calc 101.
Verification step:
k = 0.706115180252531;
ulimy = @(x) 2*x*k;
integral2(@(x,y) a*x.^2 + b*y.^2,0,5,0,ulimy)
ans =
125.000000000043
Ok. Could I have solved it using fzero and integral2? Do I really need to? Sigh.
k = fzero(@(k) integral2(@(x,y) a*x.^2 + b*y.^2,0,5,0,@(x) 2*x*k) - 125,[0.1,5])
k =
0.706115180252333
It seems to have worked this way too. I suppose if the integrand were more complicated, you would have had no choice in the matter.
Best Answer