Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Rearranging inequalities

27 views
Skip to first unread message

Michael Hucka

unread,
Nov 30, 1997, 3:00:00 AM11/30/97
to

I'd like to be able to rearrange some formulas involving inequalities,
to get the inequality in terms of a certain variable. How can this be
done in Mathematica 3.0? For example, I'd like to get 't' in the
equation below on the left side by itself:

lambda^2 t^2 < alpha - (c ( Abs[t] - r)^2)/2

What I thought would be obvious,

Solve[lambda^2 t^2 < alpha - (c ( Abs[t] - r)^2)/2, t]

doesn't work. Nor does Eliminate seem suitable. So what should one do?

Sorry to ask what is probably an ignorant question.

--
Mike Hucka hu...@umich.edu http://www.eecs.umich.edu/~hucka
University
PhD to be, computational models of human visual processing (AI Lab)
of
UNIX systems administrator & programmer/analyst (EECS DCO)
Michigan


Allan Hayes

unread,
Dec 2, 1997, 3:00:00 AM12/2/97
to

Michael Hucka wrote:
>
> I'd like to be able to rearrange some formulas involving inequalities,
> to get the inequality in terms of a certain variable. How can this be
> done in Mathematica 3.0? For example, I'd like to get 't' in the
> equation below on the left side by itself:
>
> lambda^2 t^2 < alpha - (c ( Abs[t] - r)^2)/2
>

Michael:
1) For your example

In[180]:=
$Line=0;

In[1]:=
ineq = (lambda^2 t^2 < alpha - (c ( Abs[t] - r)^2)/2);

In[2]:=
sub = Expand[Subtract @@ ineq]

Out[2]=
2 2
c r 2 2 c Abs[t] -alpha + ---- +
lambda t - c r Abs[t] + ---------
2 2

In[3]:=
lft = Select[sub, !FreeQ[#1, t]& ]

Out[3]=
2
2 2 c Abs[t]
lambda t - c r Abs[t] + ---------
2

In[4]:=
rt = Select[-sub, FreeQ[#1,t]&]

Out[4]=
2
c r
alpha - ----
2

In[5]:=
lft<rt

Out[5]=
2 2
2 2 c Abs[t] c r lambda t - c r
Abs[t] + --------- < alpha - ----
2 2

2) Make a function to the job:
allow for arbitrary binary relations ( ==,<. >,<=.>= ...); allow for
sub not being a sum (not having head Plus).

In[6]:=
ToLeft[reln_, t_] :=
Module[{x,y,sub,rt,lft},
sub = Expand[Subtract@@ineq];
lft = Select[x+y+sub,!FreeQ[#1,t]& ];
rt = Select[x[t]+y[t]-sub,FreeQ[#1,t]&];
Head[reln][lft,rt]
]

Check:

In[7]:=
ToLeft[ineq, t]

Out[7]=
2 2
2 2 c Abs[t] c r lambda t - c r
Abs[t] + --------- < alpha - ----
2 2 --
Allan Hayes
Leicester, UK
h...@haystack.demon.co.uk
http://www.haystack.demon.co.uk
voice: +44 (0)116 271 4198
fax: +44 (0)116 271 4198


Allan Hayes

unread,
Dec 5, 1997, 3:00:00 AM12/5/97
to

Two approaches for the particular problem, reducing it to solving a
quadratic equation:

1) use cases t>=0, t<0

2) make make it a problem in Abs[t]

In[1]:=
lambda^2 t^2 < alpha - (c ( Abs[t] - r)^2)/2;

In[2]:=
%/.t^2->Abs[t]^2

Out[2]=
lambda^2*Abs[t]^2 < alpha - (c*(-r + Abs[t])^2)/2

This problem in Abs[t] is solvable.

Allan Hayes


Michael Hucka wrote:
>
> I'd like to be able to rearrange some formulas involving inequalities,
> to get the inequality in terms of a certain variable. How can this be
> done in Mathematica 3.0? For example, I'd like to get 't' in the
> equation below on the left side by itself:
>
> lambda^2 t^2 < alpha - (c ( Abs[t] - r)^2)/2
>

> What I thought would be obvious,
>
> Solve[lambda^2 t^2 < alpha - (c ( Abs[t] - r)^2)/2, t]
>
> doesn't work. Nor does Eliminate seem suitable. So what should one do?
>
> Sorry to ask what is probably an ignorant question.
>
> --
> Mike Hucka hu...@umich.edu http://www.eecs.umich.edu/~hucka
> University
> PhD to be, computational models of human visual processing (AI Lab)
> of
> UNIX systems administrator & programmer/analyst (EECS DCO)
> Michigan

--
Allan Hayes
Mathematica Training and Consulting

Allan Hayes

unread,
Dec 9, 1997, 3:00:00 AM12/9/97
to

Correction:

ToLeft[reln_, t_] :=
Module[{x,y,sub,rt,lft},
sub = Expand[Subtract@@ineq];
lft = Select[x+y+sub,!FreeQ[#1,t]& ];
rt = Select[x[t]+y[t]-sub,FreeQ[#1,t]&];
Head[reln][lft,rt]
]

should be

ToLeft[reln_, t_] :=
Module[{x,y,sub,rt,lft},

sub = Expand[Subtract@@reln]; (****)


lft = Select[x+y+sub,!FreeQ[#1,t]& ];
rt = Select[x[t]+y[t]-sub,FreeQ[#1,t]&];
Head[reln][lft,rt]
]

Thanks to Seth Chandler for pointing this out.

Allan Hayes

******************


Allan Hayes wrote:
>
> Michael Hucka wrote:
> >
> > I'd like to be able to rearrange some formulas involving inequalities,
> > to get the inequality in terms of a certain variable. How can this be
> > done in Mathematica 3.0? For example, I'd like to get 't' in the
> > equation below on the left side by itself:
> >
> > lambda^2 t^2 < alpha - (c ( Abs[t] - r)^2)/2
> >
>

0 new messages