FullSimply Inequalities and then rearranging them in Mathematica 7 - wolfram-mathematica

I am using Mathematica 7 in the notebook interface and I want to rearrange an inequality so that I get a certain variable on one side. For eg.
FullSimplify[x^3+L+r>3x^3+2r]
Gives
L > r + 2 x^3
However, I want :
r < L-2x^3
Is there anyway we can instruct FullSimplify to order variables in a particular way? I am using Mathematica for presentation as well so, the way I arrange the variables is important to me.
Thanks
SR
Edit: I tried Reduce, while that works for this example, it does not work for the actual expression I have, I get an error saying,
This system cannot be solved with the methods available to Reduce.
Edit: here is the actual expression:
{L - (m^2 ((-2 + e)^2 \[Delta] + (5 +
2 e (-7 + 4 e)) \[Tau]) \[Omega])/(36 (2 - 3 e + e^2)^2)} > {0}
I want this to be displayed in the form of \[delta]< *something*
Thanks!

First of all, getting Mathematica to output something exactly as you would like it is something of a black art, and requires a lot of patience. That said, if you apply Reduce to your original expression, as per Belisarius, you'd get
In[1]:=Reduce[x^3 + L + r > 3 x^3 + 2 r, r, Reals]
Out[1]:= r < L - 2 x^3
However, as you pointed out, this isn't the full expression, and Reduce produces what can only be described as a less than helpful answer when applied to it. It is at this point where patience and a lot of extra processing is required. I'd start with
In[2]:=Reduce[ <full expression>, Delta, Reals] // LogicalExpand // Simplify
While this doesn't give you a clean answer, it is better than before and reveals more of the structure of your solution. (I would not use FullSimplify as that mixes Delta in with the other terms.) At this point, we need to know more about the terms themselves, and the output from In[2] is not quite as useful as we want.
I'd re-expand this with LogicalExpand which gives you twelve terms that are significantly simpler than the what Reduce alone gives. (You'll note that only the last six terms actually involve Delta, so I'd check that the variable conditions actually match those.) Selecting those last six terms only,
In[3]:=%2[[-6;;]] // Simplify
Out[3]:= m != 0
&& ((Omega > 0 && Delta < something) || (Omega > 0 && Delta < something else)
&& (1 < e < 2 || e < 1 || e > 2)
The third term is tautological, but Simplify nor FullSimplify can't seem to remove it. And we're really only interested in the middle term anyway. If Omega > 0 your expression can then be extracted via %[[2,1,2]].
Putting this all together in one expression:
In[4]:=Simplify[LogicalExpand[Reduce[<expression>, Delta, Reals]]][[-6;;]] //
Simplify // #[[2,1,2]]&
Out[4]:= Delta < something
After writing that out, I realized that there is a much simpler way to approach this. I'd redo line 2, above, as follows:
In[5]:= Reduce[ <full expression>, Delta, Reals] // LogicalExpand // Simplify //
Cases[#, ___ && Delta < _ && ___, Infinity]&
Out[5]:= {Omega > 0 && Delta < something}
Or, provided you really do know that m != 0 and Omega > 0 you can do
In[6]:= Reduce[ <expr> && m!=0 && Omega > 0, Delta, Reals ] // LogicalExpand //
Simplify // #[[2]]&

Reduce[x^3 + L + r > 3 x^3 + 2 r, r, Reals]
Will do.
As I don't use Mathematica for editing or presentation, perhaps someone else may come with some extra advice.
Edit
based on your comment, you may try:
Reduce[{L - (m^2 ((-2 + e)^2 Delta + (5 +
2 e (-7 + 4 e)) Tau) Omega)/(36 (2 - 3 e + e^2)^2) > 0}, Delta, Reals]
Where I corrected some syntax errors. But you'll find that the resulting expression is rather unpleasant. To simplify it further you need to know the valid ranges for your vars. Please post that info if you have it.
HTH!

Inspect the output of
r=Simplify[Reduce[L-(m^2((-2+e)^2\\[Delta]+(5+2e(-7+4e))\\[Tau])\\[Omega])/(36(2-3e+e^2)^2)>0,\\[Delta],Reals]]
to see that
r[[2,1,1,1]] gives \\[Delta]>expr,
but
r[[2, 1, 2, 2]] gives \\[Delta]< expr,
because the sign of \[Omega] in the denominator of expr. All this ignores the other conditions on the values of L, e, m and \[Omega] that will change the result and different versions of Mathematica may change the form of the result from Simplify[Reduce[]] which will invalidate all of this.

Part of the difficulty in reducing the expressions returned by Reduce[] and LogicalExpand[] is that the supplied expression involves division by zero when e=1 or =2.
I get something bearably compact with
Assuming[{
(L | m | e | Tau | Omega | Delta) \[Element] Reals
},
FullSimplify[
LogicalExpand[
Reduce[{L - (m^2 ((-2 + e)^2 Delta + (5 +
2 e (-7 + 4 e)) Tau) Omega)/(36 (2 - 3 e + e^2)^2) >
0}, Delta, Reals]
]
]
]
Out[]:= (L > 0 && (1 < e < 2 || e < 1 || e > 2) && (m == 0 || Omega == 0)) ||
(m != 0 && (
(Omega > 0 &&
Delta < (36 (-1 + e)^2 L)/(m^2 Omega) + ((-5 + 2 (7 - 4 e) e) Tau)/(-2 + e)^2) ||
(Delta > (36 (-1 + e)^2 L)/(m^2 Omega) + ((-5 + 2 (7 - 4 e) e) Tau)/(-2 + e)^2 &&
Omega < 0)) &&
(e > 2 || e < 1 || 1 < e < 2))
where I've expended no effort to replace symbol names with symbols.
(Why Assuming[...]? Because I'm too lazy to remember to get the same assumptions jammed into each simplification step.)

Related

How can I ask Wolfram Alpha to rearrange an equation?

I have an equation (parentheses are used because of VBA code)
Y=(P/(12E((bt^3)/12))*A
and i know every variables but not "b". Is there any way how to ask Wolfram Alpha to "redefine" (not solve) equation so I can see something like following: I tried to do it manually (but result is not OK)
b=((P/EY)*12A))/t^3
I wish to see how right equation will look.
Original equation is on picture below
where
equation in [,] I simplified by A
I'm not sure if there's a way to tell Wolfram|Alpha to rearrange for a particular variable; in general it will usually try to rearrange for x or y.
If I substitute b for x in your equation and use the following query:
solve Y - (P/(12E((xt^3)/12))*A) = 0
then Wolfram Alpha returns the result you're looking for: x (b) expressed in terms of the other variables. Specifically:
x = A P / (E t^3 Y) for tY != 0 and AP != 0
I know that your question was about Wolfram Alpha, that you do not want to "solve", but here is one way you could do it in Mathematica using your real question. I renamed I into J because I is a reserved symbol in Mathematica for the imaginary unit.
J = b t^3/12;
expr = (P / (12 E J) ) (4 L1^3 + 3 R ( 2 Pi L1^2 + Pi R^2 + 8 L1 R ) + 12 L2 (L1 + R)^2)
Solve[ Y == expr , b]
Result
{{b -> (P (4 L1^3 + 12 L1^2 L2 + 24 L1 L2 R + 6 L1^2 \[Pi] R + 24 L1 R^2 + 12 L2 R^2 + 3 \[Pi] R^3))/(E t^3 Y)}}

Maxima: how to reform a equation in a defined format

In Maxima, I want to change the following equation:
ax+b-c-d=0
into the following format
(ax+b)/(c+d)=1
Note:
something like ax+b-c-d+1=1 is not what I want.
Basically I want to have positive elements in one side and negative elements in another side, then divide the positive elements by the negative elements.
Here is a quick attempt. It handles some equations of the form you described, but it's probably easy to find some which it can't handle. Maybe it works well enough, or at least provides some inspiration.
ptermp (e) := symbolp(e) or (numberp(e) and e > 0)
or ((op(e) = "+" or op(e) = "*") and every (ptermp, args(e)));
matchdeclare (pterm, ptermp);
matchdeclare (otherterm, all);
defrule (r1, pterm + otherterm = 0, ratsimp (pterm/(-otherterm)) = 1);
NOTE: the catch-all otherterm must be precede pterm alphabetically! This is a useful, but obscure, consequence of the simplification of "+" expressions and the pattern-matching process ... sorry for the obscurity.
Examples:
apply1 (a*x - b - c + d = 0, r1);
a x + d
------- = 1
c + b
apply1 (a*x - (b + g) - 2*c + d*e*f = 0, r1);
a x + d e f
----------- = 1
g + 2 c + b

Question on "smart" replacing in mathematica

How do I tell mathematica to do this replacement smartly? (or how do I get smarter at telling mathematica to do what i want)
expr = b + c d + ec + 2 a;
expr /. a + b :> 1
Out = 2 a + b + c d + ec
I expect the answer to be a + cd + ec + 1. And before someone suggests, I don't want to do a :> 1 - b, because for aesthetic purposes, I'd like to have both a and b in my equation as long as the a+b = 1 simplification cannot be made.
In addition, how do I get it to replace all instances of 1-b, -b+1 or -1+b, b-1 with a or -a respectively and vice versa?
Here's an example for this part:
expr = b + c (1 - a) + (-1 + b)(a - 1) + (1 -a -b) d + 2 a
You can use a customised version of FullSimplify by supplying your own transformations to FullSimplify and let it figure out the details:
In[1]:= MySimplify[expr_,equivs_]:= FullSimplify[expr,
TransformationFunctions ->
Prepend[
Function[x,x-#]&/#Flatten#Map[{#,-#}&,equivs/.Equal->Subtract],
Automatic
]
]
In[2]:= MySimplify[2a+b+c*d+e*c, {a+b==1}]
Out[2]= a + c(d + e) + 1
equivs/.Equal->Subtract turns given equations into expressions equal to zero (e.g. a+b==1 -> a+b-1). Flatten#Map[{#,-#}&, ] then constructs also negated versions and flattens them into a single list. Function[x,x-#]& /# turns the zero expressions into functions, which subtract the zero expressions (the #) from what is later given to them (x) by FullSimplify.
It may be necessary to specify your own ComplexityFunction for FullSimplify, too, if your idea of simple differs from FullSimplify's default ComplexityFunction (which is roughly equivalent to LeafCount), e.g.:
MySimplify[expr_, equivs_] := FullSimplify[expr,
TransformationFunctions ->
Prepend[
Function[x,x-#]&/#Flatten#Map[{#,-#}&,equivs/.Equal->Subtract],
Automatic
],
ComplexityFunction -> (
1000 LeafCount[#] +
Composition[
Total,Flatten,Map[ArrayDepth[#]#&,#]&,CoefficientArrays
][#] &
)
]
In your example case, the default ComplexityFunction works fine, though.
For the first case, you might consider:
expr = b + c d + ec + 2 a
PolynomialReduce[expr, {a + b - 1}, {b, a}][[2]]
For the second case, consider:
expr = b + c (1 - a) + (-1 + b) (a - 1) + (1 - a - b) d + 2 a;
PolynomialReduce[expr, {x + b - 1}][[2]]
(% /. x -> 1 - b) == expr // Simplify
and:
PolynomialReduce[expr, {a + b - 1}][[2]]
Simplify[% == expr /. a -> 1 - b]

mathematica, Simplify trig function

if say i have a function given :
singlepattern = Cosh[theta] + Cosh[3theta]
How do i get a rational expression in terms of x of the function if i want to substitute Cosh[theta] by
"Cosh[theta] = ( x )/ 2 "
expression?
I retagged the question as a homework. You should look into ChebyshevT polynomials. It has the property that ChebyshevT[3, Cos[th] ]==Cos[3*th]. So for your problem the answer is
In[236]:= x/2 + ChebyshevT[3, x/2]
Out[236]= -x + x^3/2
Alternatively, you could use TrigExpand:
In[237]:= Cos[th] + Cos[3*th] // TrigExpand
Out[237]= Cos[th] + Cos[th]^3 - 3 Cos[th] Sin[th]^2
In[238]:= % /. Sin[th]^2 -> 1 - Cos[th]^2 // Expand
Out[238]= -2 Cos[th] + 4 Cos[th]^3
In[239]:= % /. Cos[th] -> x/2
Out[239]= -x + x^3/2
EDIT The reason the above has to do with the explicit question, is that Cosh[theta] == Cos[I*u] for some u. And since u or theta are formal, results will hold true.
Use Solve to solve for theta, then substitute, Expand, and Simplify:
In[16]:= TrigExpand[Cosh[3 theta] + Cosh[theta]] /.
Solve[Cosh[theta] == (x)/2, theta] // FullSimplify
During evaluation of In[16]:= Solve::ifun: Inverse functions are being used by Solve,
so some solutions may not be found; use Reduce for complete solution information. >>
Out[16]= {1/2 x (-2 + x^2), 1/2 x (-2 + x^2)}
This might interest you:
http://www.wolframalpha.com/input/?i=cosh%28x%29+%2B+cosh%283*x%29

How to get rid of denominator in numerator and denominator in mathematica

I have the following expression
(-1 + 1/p)^B/(-1 + (-1 + 1/p)^(A + B))
How can I multiply both the denominator and numberator by p^(A+B), i.e. to get rid of the denominators in both numerator and denominator? I tried varous Expand, Factor, Simplify etc. but none of them worked.
Thanks!
I must say I did not understand the original question. However, while trying to understand the intriguing solution given by belisarius I came up with the following:
expr = (-1 + 1/p)^B/(-1 + (-1 + 1/p)^(A + B));
Together#(PowerExpand#FunctionExpand#Numerator#expr/
PowerExpand#FunctionExpand#Denominator#expr)
Output (as given by belisarius):
Alternatively:
PowerExpand#FunctionExpand#Numerator#expr/PowerExpand#
FunctionExpand#Denominator#expr
gives
or
FunctionExpand#Numerator#expr/FunctionExpand#Denominator#expr
Thanks to belisarius for another nice lesson in the power of Mma.
If I understand you question, you may teach Mma some algebra:
r = {(k__ + Power[a_, b_]) Power[c_, b_] -> (k Power[c, b] + Power[a c, b]),
p_^(a_ + b_) q_^a_ -> p^b ( q p)^(a),
(a_ + b_) c_ -> (a c + b c)
}
and then define
s1 = ((-1 + 1/p)^B/(-1 + (-1 + 1/p)^(A + B)))
f[a_, c_] := (Numerator[a ] c //. r)/(Denominator[a ] c //. r)
So that
f[s1, p^(A + B)]
is
((1 - p)^B*p^A)/((1 - p)^(A + B) - p^(A + B))
Simplify should work, but in your case it doesn't make sense to multiply numerator and denominator by p^(A+B), it doesn't cancel denominators

Resources