# Creating a numerical table of values from an interpolating function resulting from NDSolve [closed]

I am trying to carry out point "Implementing Map" on this paper Interstellar wormholes however I am using my own equations not those given (only the same method).

## Part 1

I am trying to create a numerical table (list) of values of my range of angles $$\phi cs$$ and the resulting numerical output of my numerical differential equations which are dependent on these angles

I have done this so far

Quit

numericalmap = {};
For[i = 1, i < 10, i++,
ϕcsgen = (1 + 0.1 i)*Pi;
Nx = Sin[θcs]*Cos[ϕcsgen];
Ny = Sin[θcs]*Sin[ϕcsgen];
Nz = Cos[θcs];
nr = -Nx;
nϕ = -Ny;
nθ = Nz;
b = rc*Sin[θc]*nϕ/(1 - 2 M/rc)^1/2;
B2 = rc^2/(1 - 2 M/rc)*(nϕ^2 + nθ^2);
prinitial = ((1 - 2 M/rc)^(-1))*nr;
pθinitial = ((1 - 2 M/rc)^(-1/2))*rc*nθ;
M = 1; E0 = 1; θcs = Pi/2;
{rc, θc, ϕc} = {200, Pi/2, 0};
ham =
{t'[λ] + E0/(1 - (2 M)/r[λ]) == 0,
r'[λ] - (1 - (2 M)/r[λ]) pr[λ] == 0,
θ'[λ] - Pθ[λ]/r[λ]^2 == 0,
ϕ'[λ] - b/(r[λ]*Sin[θ[λ]])^2 == 0,
pr'[λ] + M/r[λ]^2 (E0^2/(1 - (2 M)/r[λ])^2 +
pr[λ]^2) - B2/r[λ]^3 == 0,
Pθ'[λ] - (b^2*Cos[θ[λ]])/(r[λ]^2*Sin[θ[λ]]^3) == 0};
haminital =
{t[0] == 0, r[0] == rc, θ[0] == θc, ϕ[0] == ϕc,
pr[0] == prinitial, Pθ[0] == pθinitial};
sol = NDSolveValue[{ham, haminital}, {t, r, θ, ϕ, pr, Pθ}, {λ, -100, 0}][[4]];
ϕ2[λ_] = ϕ[λ] /. sol; (* ##### *)
numericalmap = Append[numericalmap, {ϕcsgen, ϕ2[-100]}]]


This leads to some errors occurring but not entirely sure how to fix it.

I would like to have the numerical value of $$\phi[-100]$$ evaluated in each iteration not have some interpolating function. Note this is the function that results from the numerical integration evaluated at the end of the integration limit

Does anyone know how to get the numerical value of our function for $$\phi[\lambda]$$ from our numerical integration to be listed for each of the for-loop iterations rather than its interpolating function?

## Part 2

Ideally then I would like to use the command Interpolation to interpolate these points and then use ImageTransformation to transform images from these interpolations.

I did this so far

numericalmap = {};
For[i = 1, i < 11, i++, \[Phi]csgen = (1 + 0.1 i)*Pi;
M = 1; E0 = 1; \[Theta]cs = Pi/2;
Nx = Sin[\[Theta]cs]*Cos[\[Phi]csgen];
Ny = Sin[\[Theta]cs]*Sin[\[Phi]csgen];
Nz = Cos[\[Theta]cs];
nr = -Nx;
n\[Phi] = -Ny;
n\[Theta] = Nz;
b = rc*Sin[\[Theta]c]*n\[Phi]/(1 - 2 M/rc)^1/2;
B2 = rc^2/(1 - 2 M/rc)*(n\[Phi]^2 + n\[Theta]^2);
prinitial = ((1 - 2 M/rc)^(-1))*nr;
p\[Theta]initial = ((1 - 2 M/rc)^(-1/2))*rc*n\[Theta];
{rc, \[Theta]c, \[Phi]c} = {200, Pi/2, 0};
ham = {
t'[\[Lambda]] + E0/(1 - (2 M)/r[\[Lambda]]) == 0,
r'[\[Lambda]] - (1 - (2 M)/r[\[Lambda]]) pr[\[Lambda]] == 0,
\[Theta]'[\[Lambda]] - P\[Theta][\[Lambda]]/r[\[Lambda]]^2 == 0,
\[Phi]'[\[Lambda]] - b/(r[\[Lambda]]*Sin[\[Theta][\[Lambda]]])^2 ==
0, pr'[\[Lambda]] +
M/r[\[Lambda]]^2 (E0^2/(1 - (2 M)/r[\[Lambda]])^2 +
pr[\[Lambda]]^2) - B2/r[\[Lambda]]^3 == 0,
P\[Theta]'[\[Lambda]] - (b^2*
Cos[\[Theta][\[Lambda]]])/(r[\[Lambda]]^2*
Sin[\[Theta][\[Lambda]]]^3) == 0
};
haminital = {t[0] == 0,
r[0] == rc, \[Theta][0] == \[Theta]c, \[Phi][0] == \[Phi]c,
pr[0] == prinitial, P\[Theta][0] == p\[Theta]initial};
\[Phi]2 =
NDSolveValue[{ham, haminital}, {t, r, \[Theta], \[Phi], pr,
P\[Theta]}, {\[Lambda], -100, 0}][[4]];
numericalmap = Append[numericalmap, {\[Phi]csgen, \[Phi]2[-100]}]]

Interpolation[numericalmap]

Import["https://goo.gl/images/vYfAwT"]

ImageTransformation[
Import["https://goo.gl/images/vYfAwT"],
Interpolation[numericalmap]
];


After this I also tried using ImageTransformation on this list as follows but am not entirely sure how to input our Interpolation function into it to transform the pixels by this function. Even if this does work surely it would transform every pixel by the same function resulting in a bland image.

If this can't be done not sure whether it's because I haven't used ListInterpolation instead.

## closed as off-topic by m_goldberg, Henrik Schumacher, MarcoB, Öskå, JohuMar 20 at 7:17

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, Henrik Schumacher, MarcoB, Öskå, Johu
If this question can be reworded to fit the rules in the help center, please edit the question.

Your problem actually starts one line above the one you marked. Try this:

numericalmap = {};
For[i = 1, i < 10, i++,
ϕcsgen = (1 + 0.1 i)*Pi;
M = 1; E0 = 1; θcs = Pi/2;
Nx = Sin[θcs]*Cos[ϕcsgen];
Ny = Sin[θcs]*Sin[ϕcsgen];
Nz = Cos[θcs];
nr = -Nx;
nϕ = -Ny;
nθ = Nz;
b = rc*Sin[θc]*nϕ/(1 - 2 M/rc)^1/2;
B2 = rc^2/(1 - 2 M/rc)*(nϕ^2 + nθ^2);
prinitial = ((1 - 2 M/rc)^(-1))*nr;
pθinitial = ((1 - 2 M/rc)^(-1/2))*rc*nθ;
{rc, θc, ϕc} = {200, Pi/2, 0};
ham =
{t'[λ] + E0/(1 - (2 M)/r[λ]) == 0,
r'[λ] - (1 - (2 M)/r[λ]) pr[λ] == 0,
θ'[λ] - Pθ[λ]/r[λ]^2 == 0,
ϕ'[λ] - b/(r[λ]*Sin[θ[λ]])^2 == 0,
pr'[λ] + M/r[λ]^2 (E0^2/(1 - (2 M)/r[λ])^2 + pr[λ]^2) - B2/r[λ]^3 == 0,
Pθ'[λ] - (b^2*Cos[θ[λ]])/(r[λ]^2*Sin[θ[λ]]^3) == 0};
haminital =
{t[0] == 0, r[0] == rc, θ[0] == θc, ϕ[0] == ϕc,
pr[0] == prinitial, Pθ[0] == pθinitial};
ϕ2 = NDSolveValue[{ham, haminital}, {t, r, θ, ϕ, pr, Pθ}, {λ, -100, 0}][[4]];
numericalmap = Append[numericalmap, {ϕcsgen, ϕ2[-100]}]]


Then evaluating numericalmap gives

{{3.45575, -0.144726}, {3.76991, -0.231658}, {4.08407, -0.262885},
{4.39823, -0.258873}, {4.71239, -0.234244}, {5.02655, -0.197373},
{5.34071, -0.153051}, {5.65487, -0.104184}, {5.96903, -0.0526945}}


Notes

1. It is good practice to move the definition of θcs upwards so it will be evaluated before it is used.
2. Since the interpolating function for ϕ is the 4th item in the list returned by NDSolveValue, I use [[4]] to extract it.
• Thank you so much , how could I then use this numerical map (a list of pairs of $(\phi cs, \phi [ -100 ] )$ ) and create an interpolation of it? I tried using ListInterpolation but it said too high order Also, how can I create a chat about this question so not to fill the comments section? – user61882 Mar 3 at 10:14
• @user61882. If you give numericlmap to Interpolation, it will return an interpolation function. – m_goldberg Mar 3 at 18:40
• I added my attempts to the question body. In the paper on page 13 it specifically says ListInterpolation was used. Also how do I then input that into ImageTransformation? – user61882 Mar 3 at 18:45
• @user61882. Use Interpolation not ListInterpolation. – m_goldberg Mar 3 at 18:48
• @user61882. You need 100 or more reputation points to open a chat room. – m_goldberg Mar 3 at 18:50