ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 12 Sep 2020 05:50:48 -0500Triple integrals in a specific region of spacehttps://ask.sagemath.org/question/53419/triple-integrals-in-a-specific-region-of-space/Can I perform a triple integral in a region of space I define?
I'm trying to migrate from Mathematica to Sage,
and in Mathematica I could go and define a region of space
(with various limitations) and then perform the integral
of a function on it.
In Mathematica:
reg = ImplicitRegion[x + 2 y + 3 z < 2 && -1 < x < y < z < 1, {x, y, z}];
integral[{x, y, z} in reg, (x^2 + 2 y z)]
![mathematica-polyhedral-region-integrate-polynomial](/upfiles/16000472797455741.png)
Is there a way to easily perform this operation even in Sage?Teo7Sat, 12 Sep 2020 05:50:48 -0500https://ask.sagemath.org/question/53419/Plot a curve in the region definedhttps://ask.sagemath.org/question/36282/plot-a-curve-in-the-region-defined/ I have the following region :
p, t= var('p t')
a=(-2*p*t^2-p^2*t)+(2*t*p-p^2)+t+1
b=(p*t^2+2*p^2*t)+(2*t*p-t^2)-p+1
c=(p*t^2-p^2*t)+(t^2+2*t*p+p^2)+t-p #3 sides (a,b,c) in terms of theta and phi
region_plot([a+b>=c, b+c>=a, c+a>=b], (t,-2,2), (p,-2,2))
And I want to plot a curve `C=t*p*(t-p)+t*p+2*(t-p)-1` on the region in first quadrant. How am I suppose to do that.ShaFri, 13 Jan 2017 05:03:27 -0600https://ask.sagemath.org/question/36282/Why region_plot dont work with absolute value of complex numbers?https://ask.sagemath.org/question/35193/why-region_plot-dont-work-with-absolute-value-of-complex-numbers/ Im trying to plot something like
var('y')
region_plot([x*abs(x+y*I)-cos(y) <= 5, y^2+e^x<=3],(x,-5,5), (y,-5,5),incol='lightblue',bordercol='blue')
but I get an errorType because the imaginary unit. I dont know how to fix it, any help would be appreciated.MasacrosoWed, 19 Oct 2016 14:07:09 -0500https://ask.sagemath.org/question/35193/Unable to create a contour_plot of a system of inequalitieshttps://ask.sagemath.org/question/34111/unable-to-create-a-contour_plot-of-a-system-of-inequalities/I am trying to plot a system of inequalities, dependent on a matrix H. Here is my function I am planning to contour_plot: <br>
def reg(x, y):
f1 = H[0,0] * H[0,0] * x + H[1,0] * H[1,0] * y
f2 = H[0,0] * H[0,1] * x + H[1,0] * H[1,1] * y
f3 = H[0,1] * H[0,1] * x + H[1,1] * H[1,1] * y
if f1 < 0 or f2 < 0 or f3 < 0:
return 0
else:
return 1
I then have H be
> H
> [2.220446049250313e-16 -0.9999999999999998]
> [ -0.9999999999999998 2.220446049250313e-16]
However
contour_plot(reg, (x,-Integer(5),Integer(5)), (y,-Integer(5),Integer(5)))
yields an error. It says
zero-size array to reduction operation minimum which has no identity
The strange part is that when
> H
> [-1 0]
> [ 0 1]
the same contour_plot yields exactly what I want without any errors <br>
Help would be much appreciated, I have just picked up SAGE this week and have much to learn
petkusSat, 16 Jul 2016 14:30:45 -0500https://ask.sagemath.org/question/34111/region_plot with "or" expressionshttps://ask.sagemath.org/question/9956/region_plot-with-or-expressions/I'm trying to do a region_plot of a bunch of things that involve an "or" and getting behavior I don't understand.
Here's an example (not so relevant to mine) of the kind of thing I'm encountering:
region_plot([x < y or x < -y], (x,-1,1), (y, -1,1))
If you run this, clearly the output is messed up. It also changes when you switch the order of the two conditions, so it seems to pay attention to just one of them.
I tried carious things like making a function of (x,y) that returns the relevant boolean that works correctly when you just feed it numbers, but exhibits the same odd behavior when you put it in region_plot.
Any idea what's going on here?
Thanks.DrNickFri, 29 Mar 2013 16:59:49 -0500https://ask.sagemath.org/question/9956/multiple region_plots in one plothttps://ask.sagemath.org/question/8792/multiple-region_plots-in-one-plot/Hi,
I want to plot two region_plots into one plot. The idea is if you use different colors for the inequalities you can see how the regions change. A minimal example:
var('x,y')
plot1=region_plot(x<y,(x,0,1),(y,0,1),incol='red')
plot2=region_plot(2*x<y,(x,0,1),(y,0,1),incol='blue')
show(plot2+plot1)
I do not know how to manage this, since zorder or opacity are not working for region_plot. Does anybody know how to make this work (by the way I use sagenb.org)? Thanks in advancegod.oneThu, 15 Mar 2012 03:11:55 -0500https://ask.sagemath.org/question/8792/