how to integrate functions with conditions using Maxima?

how to integrate functions with conditions using Maxima? - 消息

#1 已发布: 2021/7/13 13:52:18
an10

an10

1个赞,共15个帖子。

组: User

Maxima breaks whenever I try to integrate a function that is defined using if-else statement, does anyone know a solution for this?
1位用户喜欢此帖子
Martin Kraska 2021/7/13 14:25:00
#2 已发布: 2021/7/13 14:24:56
Martin Kraska

Martin Kraska

1,362个赞,共2,276个帖子。

组: Moderator

Handling of boolean expressions is a missing feature in the maxima plugin, see SS 99.

Freezing with "if" is a separate error, I'll add this to the BTS. Thanks for pointing it out.
Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
#3 已发布: 2021/7/13 15:23:36
an10

an10

1个赞,共15个帖子。

组: User

Wrote

Wrote

Maxima breaks whenever I try to integrate a function that is defined using if-else statement, does anyone know a solution for this ?


Use native Smath.

Integrate Discontinuous [min(x)].sm (16.04 KiB)已下载 1153 次。
Integrate Discontinuous.sm (31.07 KiB)已下载 1290 次。



no thanks I need double integrals
#4 已发布: 2021/7/13 16:11:20
Alvaro

Alvaro

1,139个赞,共1,805个帖子。

组: User

Wrote

Maxima breaks whenever I try to integrate a function that is defined using if-else statement, does anyone know a solution for this?



Traditionally, CAS software cannot handle if to derive or integrate.

Clipboard02.jpg

Maple can integrate functions defined with if, if previously they are converted to piecewise functions, which have a syntax very similar to the cases in SMath.

Clipboard03.jpg

The most convenient way to integrate piecewise functions in Maxima is by converting the conditionals in your functions to expressions involving sign, abs or unit steps functions, which Maxima can sometimes find an expression with elementary functions.

Clipboard01.jpg

Wrote


no thanks I need double integrals



Clipboard05.jpg

Alvaro.
#5 已发布: 2021/7/13 17:39:40
Alvaro

Alvaro

1,139个赞,共1,805个帖子。

组: User

A practical example.

example_if.sm (11.17 KiB)已下载 1268 次。

Clipboard01.jpg

Best regards.
Alvaro.
#6 已发布: 2021/7/14 02:49:13
an10

an10

1个赞,共15个帖子。

组: User

So I tried maple and symbolic evaluation and now I don't know what to do with this, obviously there are holes in this function when denominators evaluate to zero.

1.png
#7 已发布: 2021/7/14 03:07:08
Alvaro

Alvaro

1,139个赞,共1,805个帖子。

组: User

Wrote

So I tried maple and symbolic evaluation and now I don't know what to do with this, obviously there are holes in this function when denominators evaluate to zero.



Max (with uppercase) is a function from CustomFunctions, not recognized by Maxima or Maple. Here, max(a, b ) is from Maxima or Maple (native SMath is with only one arg max(A) )

Clipboard01.jpg

The answer is the same: use sign, abs or unit step with maxima, and piecewise with maple.

Alvaro.
#8 已发布: 2021/7/14 03:31:49
an10

an10

1个赞,共15个帖子。

组: User

Wrote

Wrote

So I tried maple and symbolic evaluation and now I don't know what to do with this, obviously there are holes in this function when denominators evaluate to zero.



Max (with uppercase) is a function from CustomFunctions, not recognized by Maxima or Maple. Here, max(a, b ) is from Maxima or Maple (native SMath is with only one arg max(A) )

Clipboard01.jpg

The answer is the same: use sign, abs or unit step with maxima, and piecewise with maple.

Alvaro.



how do I convert a function to piecewise representation?
#9 已发布: 2021/7/14 03:39:24
Alvaro

Alvaro

1,139个赞,共1,805个帖子。

组: User

Wrote


how do I convert a function to piecewise representation?



Use the function If_GT defined above:

Clipboard01.jpg

Alvaro
#10 已发布: 2021/7/14 03:48:07
an10

an10

1个赞,共15个帖子。

组: User

Wrote

Use the function If_GT defined above:



but I need a x != 0 condition, I don't think I can stitch together x > N conditions without a boolean OR to represent x != 0 somehow. (or at least I can't think of a way to do so)
#11 已发布: 2021/7/14 04:09:50
Alvaro

Alvaro

1,139个赞,共1,805个帖子。

组: User

Wrote

Wrote

Use the function If_GT defined above:



but I need a x != 0 condition, I don't think I can stitch together x > N conditions without a boolean OR to represent x != 0 somehow. (or at least I can't think of a way to do so)



Traditional way in CAS for handle isolate points is using Dirac's Delta "function". But that have some numerical issues, bigger one is that it is not a function but a distribution. Because you can take out a numerable infinity set of points from an integral without change its value, you don't need to exclude cases in the integrand, except for numerical evaluations, and that could be handled in SMath with try function.

So, you can read about Dirac in maple or maxima, and see how to implement an approximation for numerical evaluations looking how to approximate a limit of a succession of functions (that's what a distribution is, and this way is very useful in mathcad 11), or discard some few points or try to symbolic evaluating the integrals with maxima or maple and use try to catch numerical errors.

Alvaro.
#12 已发布: 2021/7/17 06:55:43
overlord

overlord

600个赞,共1,381个帖子。

组: Moderator

Original post was about using integrate functions with conditions using Maxima.
Some seems to ignore "with conditions using Maxima".
I understood from mkraska and Razonar this is not possible yet, using Maxima.
And there are some tricks for it to use with other plugins/functions.
Mkraska said he will add this feature to Maxima.
That answers should be enough for this question.

Regards
#13 已发布: 2021/7/17 07:53:39
Alvaro

Alvaro

1,139个赞,共1,805个帖子。

组: User

Wrote

Original post was about using integrate functions with conditions using Maxima.
Some seems to ignore "with conditions using Maxima".
I understood from mkraska and Razonar this is not possible yet, using Maxima.
And there are some tricks for it to use with other plugins/functions.
Mkraska said he will add this feature to Maxima.
That answers should be enough for this question.

Regards



Hi. But actually what I try to show is that it is possible, without plugins and only with simple and short SMath's definitions.

MaximaPiecwiseIntDif.sm (33.28 KiB)已下载 1285 次。
MaximaPiecwiseIntDif.pdf (192.85 KiB)已下载 842 次。

Best regards
Alvaro
#14 已发布: 2021/7/17 08:11:41
overlord

overlord

600个赞,共1,381个帖子。

组: Moderator

Wrote

Hi. But actually what I try to show is that it is possible, without plugins and only with simple and short SMath's definitions.

Best regards
Alvaro


Yeah I got that, which I appreciate it too.
And I have no grievance against your answers too.
Main question is "with conditions using Maxima".
You have answered the question without drifting apart from main issue.
Mkraska even replied conditions are not added to maxima plugin yet.
Your point is "It is not possible with Maxima and you can use these functions".
It is possible with integrated functions as you have shown.
But the some replies are either same with previous ones.
Or not related with the subject. This is what I had tried to complain.

Regards
2位用户喜欢此帖子
Alvaro 2021/7/17 08:32:00, Oscar Campo 2021/7/17 09:30:00
#15 已发布: 2021/7/17 09:32:51
Oscar Campo

Oscar Campo

135个赞,共309个帖子。

组: Moderator

Wrote


Yeah I got that, which I appreciate it too.
And I have no grievance against your answers too.
Main question is "with conditions using Maxima".
Mkraska even replied conditions are not added to maxima plugin yet.
You have answered the question without drifting apart from main issue.
Your point is "It is not possible with Maxima and you can use these functions".
It is possible with integrated functions as you have shown.
But the some replies are either same with previous ones.
Or not related with the subject. This is what I had tried to complain.

Regards



I completely agree with you. Answers in a forum must be concrete and specific for the forum's health and traceability
#16 已发布: 2021/7/18 10:09:06
Jean Giraud

Jean Giraud

983个赞,共6,866个帖子。

组: User

Wrote

how do I convert a function to piecewise representation ?



PieceWise.PNG

#17 已发布: 2021/7/18 11:05:53
Jean Giraud

Jean Giraud

983个赞,共6,866个帖子。

组: User

Wrote

no thanks I need double integrals


Native Smath integrator supports double ... very slow.
Thus, convert/transit for end production.
Give your double integration for inspection.
#18 已发布: 2021/7/18 13:14:52
an10

an10

1个赞,共15个帖子。

组: User

Wrote

Give your double integration for inspection.



I don't really understand your way of speaking, but if you mean that you want me to post what exactly I want to integrate then I already posted it. It's Smith shadowing masking function somewhere in there. All I ever wanted is to handle cases where denominator evaluates to zero to prevent undefined results so I used if-else statement, but it ended up not working with Maxima. I gave up using Smath, I'll integrate everything using C++ with Monte-Carlo estimator instead. Much less painful than trying to beat this mess and actually much more flexible which is ridiculous if you ask me. Thank you all for trying to help.
#19 已发布: 2021/7/18 14:04:29
Jean Giraud

Jean Giraud

983个赞,共6,866个帖子。

组: User

Wrote

but if you mean that you want me to post what exactly I want to integrate then I already posted it. It's Smith shadowing masking function somewhere in there.


Post the double integration again.
Sometimes Forum misses attachment.
If you mean the RHS is the double integration
result of the LHS, then make it productive.
As it looks, it should produce complex RHS.
#20 已发布: 2021/7/18 14:19:34
an10

an10

1个赞,共15个帖子。

组: User

Wrote

Wrote

but if you mean that you want me to post what exactly I want to integrate then I already posted it. It's Smith shadowing masking function somewhere in there.


Post the double integration again.
Sometimes Forum misses attachment.
If you mean the RHS is the double integration
result of the LHS, then make it productive.
As it looks, it should produce complex RHS.



https://en.smath.com/forum/yaf_postsm71566_how-to-integrate-functions-with-conditions-using-Maxima.aspx#post71566
  • 有新帖
  • 无新帖