0
|
5229 Views
|
7 Replies
|
0 Total Likes
View groups...
Share
GROUPS:

# Integration of functions involving If statements

Posted 11 years ago
 I am having trouble with Integrating functions that involve If statements.For example, I can integrate If [Cos[-y] Sin Sin < 0, -1, 1]with x over the range -pi to pi and y over the range 0 to piHowever, trying to integrateIf[(Cos[-y] Sin Sin + Cos) < 0, -1, 1]over the same ranges fails with Mathematica just returning the entered integration command.Is there any way to have Mathematica integrate functions containing If statements of this nature?Thanks in anticipation.
7 Replies
Sort By:
Posted 11 years ago
 I'm not sure I am able to clarify this with words very effectively beyond that statement. If statements are meant for programming. They are meant to help define a program. They aren't meant to be used as a mathematical formalism in the definition of a function.  The symbolic mathematical functions in Mathematica don't handle if statements because If statements aren't meant to be used in the definition of a mathematica formula. If statements are meant to be used in the definition of a program.
Posted 11 years ago
 Thanks Sean
Posted 11 years ago
 Hi Roger,It is not clear from your posts what are the integrant functions. Is the first oneIf[Cos[-y] Sin[x]^2 < 0, -1, 1]orIf[Cos[-y] Sin[Sin[x]] < 0, -1, 1] Is the second one If[(Cos[-y] Sin[x] Sin[x] + Cos[x]) < 0, -1, 1]
Posted 11 years ago
 If[Cos[-y] Sin^2 < 0, -1, 1]is the first one.If[(Cos[-y] Sin Sin + Cos) < 0, -1, 1]is the second one.Sorry for the confusion.
Posted 11 years ago
 If statements are good for programming, but you don't want to define mathematicals functions with it.Instead, try using Piecewise: http://reference.wolfram.com/mathematica/ref/Piecewise.htmlI also find using HeavisideTheta and UnitStep to be useful sometimes: http://reference.wolfram.com/mathematica/ref/HeavisideTheta.htmlIf statements are meant for control flow in a program and aren't meant to be symbolicaly manipulatable parts of the definition of a Mathematical function.
Posted 11 years ago
 Thanks very much for your response Sean.Could you please expand on this:"If statements"  "aren't meant to be symbolicaly manipulatable parts of the definition of a Mathematical function."I think I get into problems with this quite a lot so it would help me to understand better, distinctions with respect to "symbolicaly manipulatable parts".
Posted 11 years ago
 CorrectionCos[-y] Sin Sin should beCos[-y] Sin Sinand Cos[-y] Sin Sin + Cos should beCos[-y] Sin Sin + Cos