3

I need to solve a system similar to the following (Except it is quite large. Solving this ought to do the job):

$$ \tan[2f(t)] = 1+ t^2\ $$

and

$ f(t) $ is $ k $, such that$$ \tan[2kt]-(1+k^2) = 0\ $$

I have used RootSearch for both equations as I also know the range in which $k$ and $T$ lie. The sample of my code is below.

f[T_] := k /. Extract[Flatten[Quiet[RootSearch[Tan[2*k*T] - (1 + k^2) == 0, {k, 0, 1}],
         $MinPrecision::precset]], -1];

Extract[Flatten[Quiet[RootSearch[Tan[2*f[T]] - (1 + T^2) == 0, {T, 0, 1}],
        $MinPrecision::precset]], -1]

and I end up getting the following error

ReplaceAll::reps: {k,0,1} is neither a list of replacement rules nor a valid dispatch table,
and so cannot be used for replacing. >>

Please suggest a solution. It would be preferable to use something as powerful as RootSearch because my other equations seem to be unsolvable via FindRoot or NSolve.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
gpavanb
  • 131
  • 5

2 Answers2

4

FindRoot can be used.

exprs = {Tan[2 k] - 1 + t^2, Tan[2 t k] - 1 + k^2};
rt = FindRoot[exprs == 0, {t, 1}, {k, 2}]

(* Out[127]= {t -> 0.514542275159657, k -> 1.887792150510011} *)

Check result:

In[128]:= exprs /. rt

(* Out[128]= {2.220446049250313*10^-16, -8.881784197001252*10^-16} *)
Daniel Lichtblau
  • 58,970
  • 2
  • 101
  • 199
2

Define the equations:

eq1 = Tan[2 f[t]] == 1 + t^2;
eq2 = Tan[2 t f[t]] == 1 + f[t]^2;

Solve for f[t] - this is multivalued:

Reduce[eq1, f[t]]

Use this result to define a rule that implements the n-th solution for f:

solnf[n_Integer] := f[t] -> 1/2 (ArcTan[1 + t^2] + \[Pi] n);

Then define a rule that implements the n-th set of solutions for t in a predefined range of t:

solnt[n_Integer, {t1_, t2_}] :=
NSolve[((eq2 /. solnf[n]) && t1 <= t <= t2) // Evaluate, t, Reals];

Now you can generate sets of solutions using solnt[n,{t1,t2}].

Stephen Luttrell
  • 5,044
  • 1
  • 19
  • 18