Given ode where \(y\) is dependent variable and \(x\) is independent variable, how to normalize the ode so that all terms with \(y(x)\) are on left side and everything is on the RHS? This makes it easier to see what the forcing function is. i.e. we want to write the ode as
Here is function to do this. This works for any ode or any expression.
export move_y_x_to_each_side:=proc(expr_in::`=`,y::symbol,x::symbol)::`=`; local expr:=expr_in; local stuff_with_y,stuff_not_with_y; expr := lhs(expr)-rhs(expr); if not expr::`+` then RETURN(expr_in); fi; expr := numer(normal(expr)); stuff_with_y,stuff_not_with_y := selectremove(has,expr,y); stuff_not_with_y := convert(stuff_not_with_y,diff); RETURN(stuff_with_y = -stuff_not_with_y); end proc:
Examples
ode:=diff(y(x),x$2)+x*y(x)+sin(x)-3=tan(x); expr:=move_y_x_to_each_side(ode,y,x); # diff(y(x), x, x) + x*y(x) = 3 - sin(x) + tan(x)
And
ode:=diff(y(x),x$2)+x*y(x)+sin(x)-3=tan(x)+y(x)+Pi; expr:=move_y_x_to_each_side(ode,y,x); # diff(y(x), x, x) + x*y(x) - y(x) = 3 - sin(x) + tan(x) + Pi
And