0
$\begingroup$

The following codes give solutions of x(t),y(t), and v(t) as interpolating functions. How to transform y(t) to a regular function so that it can be used for function compostion of y(z(T))? Z(T) is a function defined on solutions of x(t) and y(t). Thanks in advance.

ClearAll["Global`*"];
tstar = -5; Br = 2.5; Dr = 20; b = 1.0548612997205005`; c = 1.0282882725739377`; zfl= 
1.27; R0 = 0.51;

sol1 = NDSolve[{y'[t] == -Sin [x[t]]/y[t],x'[t] == -Cos [x[t]] (6  Sin  [x[t]]  
Cos[x[t]] + y[t] (b - c (1 + 3* y[t]^2)))/(2* y[t]^3*(b + c (y[t]^2 - 1))), v'[t] == 
-(b+ c*(y[t]^2 - 1))/(4*y[t]* Cos [x[t]]) + Sin [x[t]]/(2 *y[t]^2), x[tstar] 
==0,y[tstar]== Br, v[tstar] == Log[Dr]}, {x, y, v}, {t, 0, tstar}, Method -> 
{"StiffnessSwitching", Method -> {"ExplicitRungeKutta", Automatic}}]

The function Z(T) is defined as follows:

Z[T_] := 1.88 - NIntegrate[(Cos[x[t] /. sol1])/(y[t] /. sol1), {t, tstar, T}]
$\endgroup$
3
  • $\begingroup$ Does x[Z[1]] /. sol1 achieve what you want? If not, what exactly are you after? $\endgroup$
    – Lukas Lang
    Commented Feb 19, 2023 at 18:26
  • $\begingroup$ Nope. Actually, I want an (approximate) explicit form of interpolationg funtion of x(t) so that it can be used for function composition. $\endgroup$
    – Dibbo123
    Commented Feb 19, 2023 at 18:40
  • $\begingroup$ Then I am not sure what you mean by "function composition". InterpolatingFunction objects can be used just like any other function, e.g. f = x @* Z /. First@sol1; f[1]. If you just want a more or less explicit expression for the function, that's a different question $\endgroup$
    – Lukas Lang
    Commented Feb 19, 2023 at 18:54

1 Answer 1

1
$\begingroup$
$Version

(* "13.2.1 for Mac OS X ARM (64-bit) (January 27, 2023)" *)

ClearAll["Global`*"]

tstar = -5; 
Br = 5/2; 
Dr = 20; 
b = 1.0548612997205005` // Rationalize[#, 0] &; 
c = 1.0282882725739377` // Rationalize[#, 0] &; 
zfl = 127/100; 
R0 = 51/100;

{x, y, v} = NDSolveValue[{
    y'[t] == -Sin[x[t]]/y[t],
    x'[t] == -Cos[x[t]] (6 Sin[x[t]] Cos[x[t]] +
         y[t] (b - c (1 + 3*y[t]^2)))/
       (2*y[t]^3*(b + c (y[t]^2 - 1))),
    v'[t] == -(b + c*(y[t]^2 - 1))/
       (4*y[t]*Cos[x[t]]) + Sin[x[t]]/
       (2*y[t]^2),
    x[tstar] == 0, y[tstar] == Br, v[tstar] == Log[Dr]},
   {x, y, v}, {t, 0, tstar},
   Method -> {"StiffnessSwitching",
     Method -> {"ExplicitRungeKutta", Automatic}}];

Z[T_?NumericQ] := 47/25 - NIntegrate[(Cos[x[t]])/y[t], {t, tstar, T}]

Plot[Z[t], {t, tstar, 0}]

enter image description here

Note that the values of Z[t] are outside of the time range for which x[t] and y[t] are defined, i.e., -5 <= t <= 0.

Plot[{x[Z[t]], y[Z[t]]}, {t, 0, tstar},
 PlotLegends -> Placed["Expressions", {.7, .4}]]

enter image description here

$\endgroup$

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.