From: Virgil Stokes on 22 Apr 2010 03:31 A very simple question on imposing conditions/constraints. I know that a, r, and h must be real and non-negative in the following system of equations: eq1=Pi*r^2+2*Pi*r*x==0; eq2=2*Pi*r*h+(2*Pi*h+4*Pi*r)*x==0; eq3=2*Pi*r^2+2*Pi*r*h-a==0; sols=Solve[{eq1,eq2,eq3},{r,h,x}] How can I impose conditions on this system such that only real solutions are obtained, and r and h are non-negative? Thank you, --V
From: Andrzej Kozlowski on 23 Apr 2010 03:50 Just use Reduce instead of Solve: sols = Reduce[eq1 && eq2 && eq3 && r >= 0 && h >= 0, {r, h, x}, Reals, Backsubstitution -> True] (a == 0 && r == 0 && h == 0) || (a == 0 && r == 0 && h > 0 && x == 0) || (a > 0 && r == Sqrt[a]/Sqrt[6*Pi] && h == Sqrt[2/(3*Pi)]*Sqrt[a] && x == -(Sqrt[a]/(2*Sqrt[6*Pi]))) On 22 Apr 2010, at 16:31, Virgil Stokes wrote: > A very simple question on imposing conditions/constraints. > > I know that a, r, and h must be real and non-negative in the following > system of equations: > > eq1=Pi*r^2+2*Pi*r*x==0; > eq2=2*Pi*r*h+(2*Pi*h+4*Pi*r)*x==0; > eq3=2*Pi*r^2+2*Pi*r*h-a==0; > sols=Solve[{eq1,eq2,eq3},{r,h,x}] > > How can I impose conditions on this system such that only real solutions > are obtained, and r and h are non-negative? > > Thank you, > --V > >
From: Bob Hanlon on 23 Apr 2010 03:49 Use Reduce eq1 = Pi*r^2 + 2*Pi*r*x == 0; eq2 = 2*Pi*r*h + (2*Pi*h + 4*Pi*r)*x == 0; eq3 = 2*Pi*r^2 + 2*Pi*r*h - a == 0; sols = Reduce[{eq1, eq2, eq3, r >= 0, h >= 0}, {r, h, x}, Reals] // ToRules {r -> 1/Sqrt[6*Pi], h -> Sqrt[2/(3*Pi)], x -> -(h/(Sqrt[6*Pi]* (h + Sqrt[2/(3*Pi)])))} Bob Hanlon ---- Virgil Stokes <vs(a)it.uu.se> wrote: ============= A very simple question on imposing conditions/constraints. I know that a, r, and h must be real and non-negative in the following system of equations: eq1=Pi*r^2+2*Pi*r*x==0; eq2=2*Pi*r*h+(2*Pi*h+4*Pi*r)*x==0; eq3=2*Pi*r^2+2*Pi*r*h-a==0; sols=Solve[{eq1,eq2,eq3},{r,h,x}] How can I impose conditions on this system such that only real solutions are obtained, and r and h are non-negative? Thank you, --V
From: DrMajorBob on 24 Apr 2010 04:00 eq1 = Pi*r^2 + 2*Pi*r*x == 0; eq2 = 2*Pi*r*h + (2*Pi*h + 4*Pi*r)*x == 0; eq3 = 2*Pi*r^2 + 2*Pi*r*h - a == 0; sols = Reduce[{eq1, eq2, eq3, r >= 0, h >= 0}, {r, h, x}, Reals] (a == 0 && r == 0 && (h == 0 || (h > 0 && x == 0))) || (a > 0 && r == Sqrt[a]/Sqrt[6 \[Pi]] && h == 2 r && x == -((h r)/(h + 2 r))) Bobby On Thu, 22 Apr 2010 02:31:16 -0500, Virgil Stokes <vs(a)it.uu.se> wrote: > A very simple question on imposing conditions/constraints. > > I know that a, r, and h must be real and non-negative in the following > system of equations: > > eq1=Pi*r^2+2*Pi*r*x==0; > eq2=2*Pi*r*h+(2*Pi*h+4*Pi*r)*x==0; > eq3=2*Pi*r^2+2*Pi*r*h-a==0; > sols=Solve[{eq1,eq2,eq3},{r,h,x}] > > How can I impose conditions on this system such that only real solutions > are obtained, and r and h are non-negative? > > Thank you, > --V > > -- DrMajorBob(a)yahoo.com
|
Pages: 1 Prev: NDSolve cannot solve set of ODEs Next: problems with NMinimize |