Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
    
@NasserM.Abbasi Please have a look at this –  b.gatessucks Aug 26 '12 at 11:39
    
You could probably use FindAllCrossings2D[] on the system {Tan[2 y t] == 1 + y^2, Tan[2 y] == 1 + t^2}; you already know the ranges of y and t anyway, so... –  J. M. Aug 26 '12 at 11:41
    
There is no solution at T=0 for instance. –  b.gatessucks Aug 26 '12 at 11:47

2 Answers 2

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} *)
share|improve this answer

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}].

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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