The subject is a bit cryptic, I know, but here is what I'd like to do: Let's say I am solving an ODE like this:

s = DSolve[{x'[t] == 1, y'[t] == x[t] t, x[0] == x0, 
   y[0] == y0}, {x[t], y[t]}, t]

which gives

{{x(t)->t+x0,y(t)->1/6 (2 t^3+3 t^2 x0+6 y0)}}

I could then apply the new rule to the second one that comes out of the DSolve to obtain y[t] as a function of x[t].

Now I'd like to convert the first of the replacement rules with one that replaces t, so the rule should look like this:

t -> -x0 + x[t]

I think the way to accomplish this would be to convert the Head Rule of my first rule to an Equal, and feed that into Solve. I tried to do that, but I can't get this to work.


1 Answer 1


This works for me:

Solve[Hold[s[[1, 1, 1]]] == s[[1, 1, 2]], t] // ReleaseHold

One needs the Hold because without it Solve will not work with x[t].

EDIT: Another way would be

Solve[(Equal @@@ Flatten[s])[[1]] /. x[t] -> xt, t] /. xt -> x[t]

this works more like the OP suggested by "replacing" the rules of s by equations. The problem with that however is that I do not know how to get Solve to work with implicit functions like x[t], this is why I needed those two replacements.

In general the issue with both solutions will be expressions like x[t] for both methods it would be nice to find an automatic solution for this. Maybe there is a way to tell solve to see all expressions just as variables not as functions but I have not found one.

  • $\begingroup$ Of course! I was hell-bent on using a rule to replace the -> with a ==, but I can just do it manually as you did. Thanks! $\endgroup$
    – Pirx
    Sep 21, 2016 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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