3
$\begingroup$

I want to rearrange an equation of the form

a*f'[x] + b*f[x] +g[x]+h[x]==0

into

a*f'[x]+b*f[x] == - g[x] - h[x]

I've tried using rules but I can't arrive to something working correctly...

$\endgroup$
3
$\begingroup$

march's answer is correct but perhaps one could do this in stages to make the generality of the method for transforming algebraic equations more transparent. First step is the same:

eqn = a*f'[x] + b*f[x] + g[x] + h[x] == 0

Then use the pure function and slot to do the first algebraic step of subtracting g[x] from both sides:

eqn1 = # - g[x] & /@ eqn

Repeat for the second function:

eqn2 = # - h[x] & /@ eqn1

(* a f'(x)+b f(x)=-g(x)-h(x) *)

This produces the result and these transformations can be used to perform operations on equations that follow textbooks etc. Sorry if this is overly simplistic.

|improve this answer|||||
$\endgroup$
2
$\begingroup$
eqn = a*f'[x] + b*f[x] + g[x] + h[x] == 0;
# - Select[eqn[[1]], ! FreeQ[#, g | h] &] & /@ eqn
(* b f[x] + a f'[x] == -g[x] - h[x] *)
|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.