Problem in triplequad in matlab

  • MATLAB
  • Thread starter quin
  • Start date
  • Tags
    Matlab
In summary: But it seems likely that trying to do this numerically is going to be really slow. I would find a closed form solution.In summary, the user is attempting to perform a triple integration on a complex symbolic function with two symbols, t and m. However, MATLAB's int() function is unable to calculate the integral and performing the integration numerically is not feasible. The user is seeking a closed form solution for the integration.
  • #1
quin
50
0
Hi friends

I want to get 3variable integral from a function which is in terms of x,y,z,m,a
but I know that a=0.01 and m=3
and want to integrate over x ,y,z
Code:
>> triplequad((4 .*((-2.* a + m).^2 .*(4 .*a + m) +4 .*a.^2 .*(2.*(2.*a - m).* cos(z) + cos(y) .*(4.* a - 2.* m + 4 .*a.* cos(z) - m .*cos(z)) + cos(x) .*(4.* a - 2.* m + 4 .*a.* cos(z) - m .*cos(z) +  cos(y) .*(4 .*a - m + 4 .*a.* cos(z))))))./(m.^4 + 64 .*a.^3 .*m .*(1 + cos(x)) .*(1 + cos(y)) .*(1 + cos(z)) - 8 .*a.^2 .*m.^2 .*(3 + 2 .*cos(z) + cos(y) .*(2 + cos(z)) + cos(x) .*(2 + cos(y) + cos(z))) + 16 .*a.^4 .*(-3 + cos(x).^2 .*(cos(y) - cos(z)).^2 - 4 .*cos(z) + cos(y) .*(-4 + cos(z) .*(-6 + cos(y) .*cos(z))) - 2 .*cos(x) .*(2 + 3 .*cos(z) +  cos(y) .*(3 + cos(z).* (6 + cos(y) + cos(z)))))),-pi,pi,-pi,pi,-pi,pi)

but when I run it MATLAB tells:
? Error using ==> fcnchk at 103
If FUN is a MATLAB object, it must have an feval method.

Error in ==> triplequad at 45
intfcn = fcnchk(intfcn);


So what should I do?

and also I used .* and ./ and .^ because I think x, y, z are matrix

however if I used * and / and ^ ,still Matlab give the same errors


thanks for your help
 
Physics news on Phys.org
  • #2
quin said:
Hi friends

I want to get 3variable integral from a function which is in terms of x,y,z,m,a
but I know that a=0.01 and m=3
and want to integrate over x ,y,z
Code:
>> triplequad((4 .*((-2.* a + m).^2 .*(4 .*a + m) +4 .*a.^2 .*(2.*(2.*a - m).* cos(z) + cos(y) .*(4.* a - 2.* m + 4 .*a.* cos(z) - m .*cos(z)) + cos(x) .*(4.* a - 2.* m + 4 .*a.* cos(z) - m .*cos(z) +  cos(y) .*(4 .*a - m + 4 .*a.* cos(z))))))./(m.^4 + 64 .*a.^3 .*m .*(1 + cos(x)) .*(1 + cos(y)) .*(1 + cos(z)) - 8 .*a.^2 .*m.^2 .*(3 + 2 .*cos(z) + cos(y) .*(2 + cos(z)) + cos(x) .*(2 + cos(y) + cos(z))) + 16 .*a.^4 .*(-3 + cos(x).^2 .*(cos(y) - cos(z)).^2 - 4 .*cos(z) + cos(y) .*(-4 + cos(z) .*(-6 + cos(y) .*cos(z))) - 2 .*cos(x) .*(2 + 3 .*cos(z) +  cos(y) .*(3 + cos(z).* (6 + cos(y) + cos(z)))))),-pi,pi,-pi,pi,-pi,pi)

You really should consider using an "m" file instead of trying to type a function that long in one line. Anyway, it should work if you make it a function of just x,y,z (that's all triplequad expects).
For example:
Code:
a=0.01
m=3
myfun = @(x,y,z) (4 .*((-2.* a + m).^2 .*(4 .*a + m) +4 .*a.^2 .*(2.*(2.*a - m).* cos(z) + cos(y) .*(4.* a - 2.* m + 4 .*a.* cos(z) - m .*cos(z)) + cos(x) .*(4.* a - 2.* m + 4 .*a.* cos(z) - m .*cos(z) +  cos(y) .*(4 .*a - m + 4 .*a.* cos(z))))))./(m.^4 + 64 .*a.^3 .*m .*(1 + cos(x)) .*(1 + cos(y)) .*(1 + cos(z)) - 8 .*a.^2 .*m.^2 .*(3 + 2 .*cos(z) + cos(y) .*(2 + cos(z)) + cos(x) .*(2 + cos(y) + cos(z))) + 16 .*a.^4 .*(-3 + cos(x).^2 .*(cos(y) - cos(z)).^2 - 4 .*cos(z) + cos(y) .*(-4 + cos(z) .*(-6 + cos(y) .*cos(z))) - 2 .*cos(x) .*(2 + 3 .*cos(z) +  cos(y) .*(3 + cos(z).* (6 + cos(y) + cos(z))))))
triplequad("myfun",-pi,pi,-pi,pi,-pi,pi)
 
  • #3
symbolic triple quad

I want to get 3variable integral from a function which is in terms of x,y,z,L,T
but I"T" and "L" are just symbols
and want to integrate over x ,y,z
How can I take triple integration from a symbolic function??
thanks alot
 
  • #4
What version of MATLAB are you using? Do you have access to Symbolic Math Toolbox?

You can solve this numerically using INTEGRAL3 and either loops or sub-functions in the m-file.

Symbolically, the integration function is int(). This attempts to find the antiderivative so that diff(F) = f, int(f) = F.

For ex,

Code:
syms x y n
f = x^n + y^n;
int(f, y)
ans =
x^n*y + (y*y^n)/(n + 1)
 
Last edited:
  • #5
thanks but my function is very complex and in this way MATLAB cannot do anything.In fact it said that the integral cannot be calculated
How can I do the integral numerically but with 2 symbols?
I mean that integrate over x ,y,z with a numerical method but with 2 symbols of t and m .
thanks for your kind attention
 
  • #6
That cannot be done as far as I know. You could probably do a totally symbolic integration and
then evaluate x,y,z leaving the expression in terms of t and m.
 

1. What is a "problem in triplequad" in MATLAB?

In MATLAB, triplequad refers to a function used for numerical integration in three dimensions. A "problem in triplequad" refers to an issue or difficulty encountered while using this function to solve a specific problem or equation.

2. How do I know if I have a problem in triplequad in MATLAB?

If you are using the triplequad function in MATLAB and it is not producing the expected results or is giving you errors, then you may have a problem in triplequad. It is important to carefully check your inputs and the syntax of your code to identify and resolve the issue.

3. What are some common causes of problems in triplequad in MATLAB?

There are several potential causes of problems in triplequad in MATLAB. These can include using incorrect syntax, having incorrect input arguments, or attempting to integrate a function that is not well-behaved or does not have a closed-form solution.

4. How can I troubleshoot a problem in triplequad in MATLAB?

To troubleshoot a problem in triplequad in MATLAB, you can start by carefully reviewing your code and checking for any errors or typos. You can also try breaking down your problem into smaller parts and testing each part separately. Additionally, you can consult MATLAB's documentation or seek help from online forums or communities.

5. Are there any alternative methods to triplequad in MATLAB for solving integration problems in three dimensions?

Yes, there are other functions and methods available in MATLAB for numerical integration in three dimensions, such as quad2d and integral3. Additionally, you can also use symbolic integration or transform your problem into a one-dimensional integration by using change of variables.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
570
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
898
  • MATLAB, Maple, Mathematica, LaTeX
Replies
13
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
620
  • Calculus and Beyond Homework Help
Replies
3
Views
562
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
2K
Back
Top