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

Forcing mathematica to output a certain form

1 view
Skip to first unread message

Geico Caveman

unread,
Mar 7, 2010, 5:13:32 AM3/7/10
to
As a result of an Eliminate function, and subsequent (wrapper)
simplification under some conditions, I am getting a non-linear
differential equation.

It looks like:

f(t)+g(t) y'(t)=h(t) y^2(t)

Is there a way to force mathematica to output this in the way a
differential equation is best written:

y'(t)+h(t)/g(t) y^(t) = -f(t)/g(t)

or

the transposed form with zero on RHS ?

Bob Hanlon

unread,
Mar 8, 2010, 6:22:07 AM3/8/10
to

expr = f[t] + g[t] y'[t] == h[t] y[t]^2;

Reverse[Expand[
Equal @@
Solve[expr /.
f[t] -> -z*g[t], z][[1, 1]]] /.

z -> -f[t]/g[t]]

Derivative[1][y][t] - (h[t]*y[t]^2)/g[t] == -(f[t]/g[t])

Expand[
(First[expr] - Last[expr])/g[t]] == 0

f[t]/g[t] - (h[t]*y[t]^2)/g[t] + Derivative[1][y][t] == 0


Bob Hanlon

---- Geico Caveman <spammers...@spam.invalid> wrote:

=============

Alexei Boulbitch

unread,
Mar 8, 2010, 6:22:29 AM3/8/10
to
(* This is your equation *)
eq1 = f[t] + g[t]*y'[t] == h[t]*y[t]^2;

(* That is how you would transform it also by hand *)
eq2 = (eq1[[1]] - eq1[[1, 1]])/eq1[[1, 2, 1]];
eq3 = (eq1[[2]] + eq1[[1, 1]])/eq1[[1, 2, 1]];

(* That is the result *)
eqRes = eq2 == eq3


\!\(\*SuperscriptBox["y", "\[Prime]",
MultilineFunction->None]\)[t] == (f[t] + h[t] y[t]^2)/g[t]


As a result of an Eliminate function, and subsequent (wrapper)
simplification under some conditions, I am getting a non-linear
differential equation.

It looks like:

f(t)+g(t) y'(t)=h(t) y^2(t)

Is there a way to force mathematica to output this in the way a
differential equation is best written:

y'(t)+h(t)/g(t) y^(t) = -f(t)/g(t)

or

the transposed form with zero on RHS ?

--
Alexei Boulbitch, Dr., habil.
Senior Scientist

IEE S.A.
ZAE Weiergewan
11, rue Edmond Reuter
L-5326 Contern
Luxembourg

Phone: +352 2454 2566
Fax: +352 2454 3566

Website: www.iee.lu

This e-mail may contain trade secrets or privileged, undisclosed or otherwise confidential information. If you are not the intended recipient and have received this e-mail in error, you are hereby notified that any review, copying or distribution of it is strictly prohibited. Please inform us immediately and destroy the original transmittal from your system. Thank you for your co-operation.

Geico Caveman

unread,
Mar 9, 2010, 6:43:34 AM3/9/10
to

Thanks for your response (and the other person's response).

So, I take it that there is no way to tell Mathematica to output it in
a standard form for differential equations, short of "doing it by hand"
?

magma

unread,
Mar 11, 2010, 6:37:07 AM3/11/10
to
On Mar 9, 12:43 pm, Geico Caveman <spammers-go-h...@spam.invalid>
wrote:

> On 2010-03-08 04:22:07 -0700, Bob Hanlon <hanl...@cox.net> said:
>
>
>
>
>
> > expr = f[t] + g[t] y'[t] == h[t] y[t]^2;
>
> > Reverse[Expand[
> > Equal @@
> > Solve[expr /.
> > f[t] -> -z*g[t], z][[1, 1]]] /.
>
> > z -> -f[t]/g[t]]
>
> > Derivative[1][y][t] - (h[t]*y[t]^2)/g[t] == -(f[t]/g[t])
>
> > Expand[
> > (First[expr] - Last[expr])/g[t]] == 0
>
> > f[t]/g[t] - (h[t]*y[t]^2)/g[t] + Derivative[1][y][t] == 0
>
> > Bob Hanlon
>
> > ---- Geico Caveman <spammers-go-h...@spam.invalid> wrote:
>
> > =============
> > As a result of an Eliminate function, and subsequent (wrapper)
> > simplification under some conditions, I am getting a non-linear
> > differential equation.
>
> > It looks like:
>
> > f(t)+g(t) y'(t)=h(t) y^2(t)
>
> > Is there a way to force mathematica to output this in the way a
> > differential equation is best written:
>
> > y'(t)+h(t)/g(t) y^(t) = -f(t)/g(t)
>
> > or
>
> > the transposed form with zero on RHS ?
>
> Thanks for your response (and the other person's response).
>
> So, I take it that there is no way to tell Mathematica to output it in
> a standard form for differential equations, short of "doing it by hand"
> ?

No, you come to the wrong conclusion.
The task you require is not too difficult to program.
You can create a function which takes an equation (== sign) and
rearranges everything as you wish.
You need to learn programming Mathematica a bit. It is well worth.
I have no time to do it for you right now.
Perhaps some other member.
Try yourself. It is a very rewarding experience.

dh

unread,
Mar 12, 2010, 7:13:36 AM3/12/10
to
Hi Geico,
here is a rule that puts all terms containing y to the left and those
not containing y to the right of the equal sign:

t1 = f[t] == h[t] y[t]^2 - g[t] y'[t];
t1 //. {
Equal[x0___, x1___ + Longest[x2_ /; ! FreeQ[x2, y]] + x3___] :>
Equal[-x2 + x0, x1 + x3],
Equal[x1___ + Longest[x2_ /; FreeQ[x2, y]] + x3___, x0___] :>
Equal[x1 + x3, x0 - x2]
}

Daniel


--

Daniel Huber
Metrohm Ltd.
Oberdorfstr. 68
CH-9100 Herisau
Tel. +41 71 353 8585, Fax +41 71 353 8907
E-Mail:<mailto:d...@metrohm.com>
Internet:<http://www.metrohm.com>


0 new messages