0
$\begingroup$

The following codes of ode provides solutions for x1(t),y1(t),and v(t) as interpolating functions.

ClearAll["Global`*"];
tstar = -4.58; Br = 2.2; Dr = 24.58; b = 2.54; c = 1.02; zfl = 1.27; R0 = 0.51;

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

Then the following codes defines some functions that I need to define for other purpose, but they seems not working because of extra curly braket in functions' ouput. How can I get rid of it. Any suggestions would help. Thanks in advance.

Z[x_] := (x + 1.0)/2.0;
z[x_?NumberQ] := zfl/R0 - NIntegrate[Evaluate[(Cos[x1[t] /. sol1])/(y1[t] /. sol1)], 
{t, tstar, (x + 1.0)/2.0}];
R[x_] := y1[z[x]] /. First@sol1
R[zfl/R0]
R[1]
$\endgroup$
1
  • 2
    $\begingroup$ What exactly is not working? No error occurs when running your code. If you want to change {1.93673} to 1.93673, use First. $\endgroup$
    – Domen
    Feb 21 at 19:42

1 Answer 1

1
$\begingroup$

Try this:

R[x_] := (y1[z[x]] /. First@sol1)[[1]]

Have fun!

$\endgroup$
1
  • $\begingroup$ Thanks @Alexei Boulbitch $\endgroup$
    – Dibbo123
    Feb 22 at 0:19

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