# Replace expression with part of InterpolatingFunction

I have an InterpolatingFunction which returns a 4 dimensional List as output. Let's call it f. Then I have a mapping such that my variables {x,y,z,w} correspond to each of the four elements of the output of the function. I have some complex expressions in x,y,z,w, which I want to want to plot using ParametricPlot, with {x,y,z,w} replaced with f. I'm trying something a bit like this:

ParametricPlot[
{
x^ y - z w^4,
Sin[x y z w]
},
/. {x -> f[t][[1]], y -> f[t][[2]], z -> f[t][[3]], w -> f[t][[4]]},
{t, 0, range}]


This is not a correct syntax for what I want to do. Can someone advise me how to get this to work? The expressions x^ y - z w^4 and Sin[x y z w] are less complex than in my real use case.

I would also be interested to know how to convert such a $$d$$-dimensional InterpolatingFunction into $$d$$ one-dimensional InterpolatingFunctions, in case someone comes up with a solution that works differently to this.

Let us create some data and interpolate it

data = Table[{{t}, {Sin[1 t], Sin[2 t], Sin[3 t], Sin[4 t]}}, {t, 0, 1, 0.01}];
f = Interpolation[data]


Now you can do some ParametricPlots

ParametricPlot[{x^y - z w^4, Sin[x y z w]} /. {x -> f[t][[1]],
y -> f[t][[2]], z -> f[t][[3]], w -> f[t][[4]]}, {t, 0, 1}]


or simply plot

Plot[f[t], {t, 0, 1}]


To answer the second part of your question. You can convert such a four-dimensional InterpolatingFunction into four one-dimensional ones as follows

Extract data

tmesh = f["Coordinates"][[1]];
values = f["ValuesOnGrid"];


Re-interpolate

Do[
g[i] = Interpolation[{tmesh, values[[ ;; , i]]} // Transpose],
{i, Last[Dimensions[values]]}]


Plot

Plot[{g[1][t], g[2][t], g[3][t], g[4][t]}, {t, 0, 1}]


• Oh so my syntax was correct? I got a bunch of errors when I tried it, maybe they were coming from somewhere else
– Joe
Nov 3 '21 at 20:10
• @Joe You had one superfluous comma :) But I decided to answer rather than comment your post because of the second part, where you ask about the re-interpolation. This comes often and I hope it will be useful to others too. Nov 3 '21 at 20:19
• Oh I didn't actually run the code in my post I just wrote roughly the same as my actual usage case. Hopefully it is just a typo in that too. Thanks for your answer
– Joe
Nov 3 '21 at 20:36
• Or use Thread[{x, y, z, w} -> f[t]] Nov 4 '21 at 2:43