I am looking to solve the following equations numerically:

$ax=\frac{d}{dt}(f(x,y,t)\frac{dy}{dt}),\phantom{\rule{1em}{0ex}}by=\frac{d}{dt}(g(x,y,t)\frac{dx}{dt})$

For arbitrary functions f and g and constants a and b. I am struggling to find a way to transform this into a system of first order differential equations that I can pass into a solver. It looks like I will need to define these implicitly, but I'm not sure how to do that.

My best attempt so far is the following:

$\begin{array}{rl}{z}_{1}& =f(x,y,t)\frac{dy}{dt}\\ {z}_{2}& =g(x,y,t)\frac{dx}{dt}\\ {z}_{3}& =ax\\ {z}_{4}& =by\end{array}$

${\left(\begin{array}{c}{z}_{1}\\ {z}_{2}\\ {z}_{3}\\ {z}_{4}\end{array}\right)}^{\prime}=\left(\begin{array}{cccc}0& 0& 1& 0\\ 0& 0& 0& 1\\ 0& \frac{a}{g(t,x,y)}& 0& 0\\ \frac{b}{f(t,x,y)}& 0& 0& 0\end{array}\right)\left(\begin{array}{c}{z}_{1}\\ {z}_{2}\\ {z}_{3}\\ {z}_{4}\end{array}\right)$

However, this seems fairly inelegant and assumes that you are always able to divide by f and g. I'm trying to keep this as general as possible, so don't want to make that assumption. Is there a better way to turn this into a system of first order differential equations implicitly?

$ax=\frac{d}{dt}(f(x,y,t)\frac{dy}{dt}),\phantom{\rule{1em}{0ex}}by=\frac{d}{dt}(g(x,y,t)\frac{dx}{dt})$

For arbitrary functions f and g and constants a and b. I am struggling to find a way to transform this into a system of first order differential equations that I can pass into a solver. It looks like I will need to define these implicitly, but I'm not sure how to do that.

My best attempt so far is the following:

$\begin{array}{rl}{z}_{1}& =f(x,y,t)\frac{dy}{dt}\\ {z}_{2}& =g(x,y,t)\frac{dx}{dt}\\ {z}_{3}& =ax\\ {z}_{4}& =by\end{array}$

${\left(\begin{array}{c}{z}_{1}\\ {z}_{2}\\ {z}_{3}\\ {z}_{4}\end{array}\right)}^{\prime}=\left(\begin{array}{cccc}0& 0& 1& 0\\ 0& 0& 0& 1\\ 0& \frac{a}{g(t,x,y)}& 0& 0\\ \frac{b}{f(t,x,y)}& 0& 0& 0\end{array}\right)\left(\begin{array}{c}{z}_{1}\\ {z}_{2}\\ {z}_{3}\\ {z}_{4}\end{array}\right)$

However, this seems fairly inelegant and assumes that you are always able to divide by f and g. I'm trying to keep this as general as possible, so don't want to make that assumption. Is there a better way to turn this into a system of first order differential equations implicitly?