DMUG-Archiv 1998

Frühere

 

Chronologischer Index

 

Spätere

Vorherige

 

Thematischer Index

 

Nächste

Re: Bearbeitung von Gleichungen

Martin Heimann <martin.heimann@XXXXXXX.de> wrote:
Liebe Kollegen,

beim Bearbeiten von Gleichungen möchte man manchmal zwei Gleichungen
addieren oder subtrahieren. Wenn man eq1 + eq2 eingibt, dann addiert MMA
jedoch nicht die linken und rechten Seiten, wie man eigentlich erwarten
könnte. Auch Simplify hilft nicht weiter. Klar, man kann die Summe explizit
erzeugen mit

eq1[[1]]+eq2[[1]] == eq1[[2]]+eq2[[2]]

aber das ist schwerfällig. Gibt es nicht einen eleganteren Weg?

Eine Moeglichkeit ist:

Unprotect[Equal];
HoldPattern[Equal[z__]*(x_) /;
FreeQ[x, Equal]] ^:= Thread[x*eq[z], eq] /. eq -> Equal;
HoldPattern[Equal[z__]*(x_) /; FreeQ[x, Equal]] ^:=
Thread[x*eq[z], eq] /. eq -> Equal;
HoldPattern[Equal[z__] + Equal[v__]] ^:=
Equal @@ ({z} + {v});
HoldPattern[Equal[z__] + (x_) /; FreeQ[x, Equal]] ^:=
Thread[x + eq[z], eq] /. eq -> Equal;
Equal/: HoldPattern[Equal[z__]^(n_Integer)] :=
Thread[eq[z]^n, eq] /. eq -> Equal;
Protect[Equal];

Dann:

In[8]:= (a==b) + (c==d)

Out[8]= a + c == b + d

In[9]:= 2 (a==b)

Out[9]= 2 a == 2 b

In[10]:= (x==y)^2

2 2
Out[10]= x == y

In[11]:= 2 + (a==b)

Out[11]= 2 + a == 2 + b


Unten habe ich obige Definitionen in einen button gebracht
(wobei jedoch nichts mehr im Global` Context definiert wird).

MfG,
Rolf Mertig

P.s.: Natuerlich ist das nur mit Vorsicht zu gebrauchen ...

(***********************************************************************

Mathematica-Compatible Notebook

This notebook can be used on any computer system with Mathematica 3.0,
MathReader 3.0, or any compatible application. The data for the notebook
starts with the line of stars above.

To get the notebook into a Mathematica-compatible application, do one of
the following:

* Save the data starting with the line of stars above into a file
with a name ending in .nb, then open the file inside the application;

* Copy the data starting with the line of stars above to the
clipboard, then use the Paste menu command inside the application.

Data for notebooks contains only printable 7-bit ASCII and can be
sent directly in email or through ftp in text mode. Newlines can be
CR, LF or CRLF (Unix, Macintosh or MS-DOS style).

NOTE: If you modify the data for this notebook not in a Mathematica-
compatible application, you must delete the line below containing the
word CacheID, otherwise Mathematica-compatible applications may try to
use invalid cache data.

For more information on notebooks and Mathematica-compatible
applications, contact Wolfram Research:
web: http://www.wolfram.com
email: info@XXXXXXX.com
phone: +1-217-398-0700 (U.S.)

Notebook reader applications are available free of charge from
Wolfram Research.
***********************************************************************)

(*CacheID: 232*)


(*NotebookFileLineBreakTest
NotebookFileLineBreakTest*)
(*NotebookOptionsPosition[ 5558, 152]*)
(*NotebookOutlinePosition[ 6598, 191]*)
(* CellTagsIndexPosition[ 6554, 187]*)
(*WindowFrame->Palette*)



Notebook[{
Cell[BoxData[
FormBox[
ButtonBox[
RowBox[{
StyleBox[\(Equation\ Manipulation\ Modifier\ \),
FontSize->30,
FontWeight->"Bold",
FontTracking->"Plain",
FontColor->RGBColor[0.100008, 0.100008, 0.4],
Background->RGBColor[1, 0.6, 0]], "\n",


StyleBox[\(\(\ \ \ Click\)\ here\ to\ enable\ \ addition, \
multiplication\ and\ exponentiation\ of\ \(equations . \)\),
"Text",
FontSize->12,
FontWeight->"Bold",
Background->RGBColor[1, 1, 0.900008]]}],
ButtonFunction:>(CompoundExpression[
Unprotect[ Equal],
UpSetDelayed[
HoldPattern[
Condition[
Times[
Equal[
Pattern[ System`Private`z,
BlankSequence[ ]]],
Pattern[ System`Private`x,
Blank[ ]]],
FreeQ[ System`Private`x, Equal]]],
ReplaceAll[
Thread[
Times[ System`Private`x,
System`Private`eq[ System`Private`z]],
System`Private`eq], System`Private`eq -> Equal]],
UpSetDelayed[
HoldPattern[
Condition[
Times[
Equal[
Pattern[ System`Private`z,
BlankSequence[ ]]],
Pattern[ System`Private`x,
Blank[ ]]],
FreeQ[ System`Private`x, Equal]]],
ReplaceAll[
Thread[
Times[ System`Private`x,
System`Private`eq[ System`Private`z]],
System`Private`eq], System`Private`eq -> Equal]],
UpSetDelayed[
HoldPattern[
Plus[
Equal[
Pattern[ System`Private`z,
BlankSequence[ ]]],
Equal[
Pattern[ System`Private`v,
BlankSequence[ ]]]]],
Apply[ Equal,
Plus[ {System`Private`z}, {System`Private`v}]]],
UpSetDelayed[
HoldPattern[
Condition[
Plus[
Equal[
Pattern[ System`Private`z,
BlankSequence[ ]]],
Pattern[ System`Private`x,
Blank[ ]]],
FreeQ[ System`Private`x, Equal]]],
ReplaceAll[
Thread[
Plus[ System`Private`x,
System`Private`eq[ System`Private`z]],
System`Private`eq], System`Private`eq -> Equal]],
TagSetDelayed[ Equal,
HoldPattern[
Power[
Equal[
Pattern[ System`Private`z,
BlankSequence[ ]]],
Pattern[ System`Private`n,
Blank[ Integer]]]],
ReplaceAll[
Thread[
Power[
System`Private`eq[ System`Private`z], System`Private`n],
System`Private`eq], System`Private`eq -> Equal]],
Protect[ Equal]]&),
ButtonEvaluator->Automatic,
Active->True,
ButtonStyle->None], TraditionalForm]], NotebookDefault,
CellMargins->{{Inherited, Inherited}, {7, Inherited}},
PageBreakAbove->True,
TextAlignment->Left,
LineSpacing->{1.25, 0},
ScriptMinSize->9,
SingleLetterItalics->True,
TraditionalFunctionNotation->True,
DelimiterMatching->None,
CounterIncrements->"Text",
StyleMenuListing->None]
},
FrontEndVersion->"X 3.0",
ScreenRectangle->{{0, 1024}, {0, 768}},
Editable->False,
WindowToolbars->{},
PageWidth->643,
WindowSize->{436, 59},
WindowMargins->{{132, Automatic}, {Automatic, 23}},
WindowFrame->"Palette",
WindowElements->{},
WindowFrameElements->"CloseBox",
WindowClickSelect->False,
ScrollingOptions->{"PagewiseScrolling"->True},
ShowCellBracket->False,
CellMargins->{{0, 0}, {Inherited, 0}},
Active->True,
CellOpen->True,
ShowCellLabel->False,
ShowCellTags->False,
ImageMargins->{{0, Inherited}, {Inherited, 0}},
Magnification->1
]


(***********************************************************************
Cached data follows. If you edit this Notebook file directly, not using
Mathematica, you must remove the line containing CacheID at the top of
the file. The cache data will then be recreated when you save this file
from within Mathematica.
***********************************************************************)

(*CellTagsOutline
CellTagsIndex->{}
*)

(*CellTagsIndex
CellTagsIndex->{}
*)

(*NotebookFileOutline
Notebook[{
Cell[1710, 49, 3844, 101, 66, NotebookDefault,
PageBreakAbove->True,
CounterIncrements->"Text"]
}
]
*)




(***********************************************************************
End of Mathematica Notebook file.
***********************************************************************)


Antworten:
Re: Bearbeitung von Gleichungen
Roman Maeder, 05.01.1998
Verweise:
Bearbeitung von Gleichungen
Martin Heimann, 05.01.1998

Frühere

 

Chronologischer Index

 

Spätere

Vorherige

 

Thematischer Index

 

Nächste

DMUG-Archiv, http://www.mathematica.ch/dmug-liste.html; Letzte Änderung: 08.09.2003 20:44