Re: A simple quetion
- To: mathgroup at smc.vnet.net
- Subject: [mg17690] Re: A simple quetion
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Fri, 21 May 1999 23:59:04 -0400
- References: <7i3487$bdr@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Nikos,
Your code
P[a[x]_ y'[x]_+b[x]_ y[x]_+d[x]_,x_]:=
Module[{a1,a2},
a1=If[a[x]==x,p[x]==b[x]/a[x];q[x]==d[x]/a[x],y[x]==-d[x]/b[x]];
a2=y[x]==Exp[-
Integrate[p[x],x] [c+Integrate[q[x] Exp[Integrate[p[x],x]],x]]]]
Requires, for example, the coefficient of y'[x] to be of the form
FullForm[a[x]_]
Times[a[x],Blank[]]
Also names of blanks must be symbols.
The following is less demanding, and works
Clear["`*"]
P[a_ y_'[x_]+b_ y_ [x_]+d_,x_]:=Module[{a1,a2},
a1=If[a==x,p==b/a;q==d/a,y==-d/b];
a2=y==Exp[-Integrate[p,x] [c+Integrate[q Exp[Integrate[p,x]],x]]]]
P[x y'[x]+2 y[x]+x^2,x]
y == E^(-(p*x)[c + (E^(p*x)*q)/p])
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565
Nikos Skordelis <ma05451 at socrates.cc.uoi.gr> wrote in message
news:7i3487$bdr at smc.vnet.net...
>
> Why the program does not running? It's a simple program about solving
> first linear equations. When i call it back with a specific equation it
> doesn't returns the solution. Any suggestions about what my mistake is?
> Thanks in advance
> Skordelis Nikos email:ma05451 at socrates.cc.uoi.gr
>
> (***********************************************************************
>
> 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 at wolfram.com
> phone: +1-217-398-0700 (U.S.)
>
> Notebook reader applications are available free of charge from
> Wolfram Research.
> ***********************************************************************)
>
> (*CacheID: 232*)
>
>
> (*NotebookFileLineBreakTest
> NotebookFileLineBreakTest*)
> (*NotebookOptionsPosition[ 2577, 82]*)
> (*NotebookOutlinePosition[ 3225, 105]*)
> (* CellTagsIndexPosition[ 3181, 101]*)
> (*WindowFrame->Normal*)
>
>
>
> Notebook[{
> Cell[BoxData[
> \(Clear[P]\)], "Input"],
>
> Cell[BoxData[
> \(P[a[x] _\ \(y'\)[x] _ + b[x] _\ y[x] _ + d[x] _, x_] :=
> Module[{a1, a2},
> a1 = If[a[x] == x, p[x] == b[x]/a[x]; q[x] == d[x]/a[x],
> y[x] == \(-d[x]\)/b[x]];
> a2 = y[x] ==
> Exp[\(-\(Integrate[p[x], x]\)\ [
> c + Integrate[q[x]\ Exp[Integrate[p[x], x]], x]]\)]]\)],
> "Input"],
>
> Cell[BoxData[""], "Input"],
>
> Cell[BoxData[""], "Input"],
>
> Cell[CellGroupData[{
>
> Cell[BoxData[
> \(P[x\ \(y'\)[x] - 2\ y[x] + x^2, x]\)], "Input"],
>
> Cell[BoxData[
> RowBox[{"P", "[",
> RowBox[{
> RowBox[{\(x\^2\), "-", \(2\ y[x]\), "+",
> RowBox[{"x", " ",
> RowBox[{
> SuperscriptBox["y", "\[Prime]",
> MultilineFunction->None], "[", "x", "]"}]}]}], ",", "x"}],
> "]"}]], "Output"]
> }, Open ]]
> },
> FrontEndVersion->"Microsoft Windows 3.0",
> ScreenRectangle->{{0, 640}, {0, 424}},
> WindowSize->{480, 300},
> WindowMargins->{{0, Automatic}, {Automatic, 5}}
> ]
>
>
> (***********************************************************************
> 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[1709, 49, 41, 1, 30, "Input"],
> Cell[1753, 52, 358, 8, 110, "Input"],
> Cell[2114, 62, 26, 0, 30, "Input"],
> Cell[2143, 64, 26, 0, 30, "Input"],
>
> Cell[CellGroupData[{
> Cell[2194, 68, 67, 1, 30, "Input"],
> Cell[2264, 71, 297, 8, 29, "Output"]
> }, Open ]]
> }
> ]
> *)
>
>
>
>
> (***********************************************************************
> End of Mathematica Notebook file.
> ***********************************************************************)