1
$\begingroup$

enter image description hereI have a nonlinear equation in single variable( $x \tan(x)=5$ ) and it have an infinite number of roots , I got some of them and I want to add them in a table this is my code please, tell me how to do this?

(* In[1]:= *) Reduce[x Tan[x] == 5 && 0 <= x <= 100, x] 

then I used a ToRule to convert the || to

(* In[2]:= *) ToRules[Out[1]] 

then I used export to export all roots to excel sheet but i got failed

Export["myfile.xls", Out[2]] 

Export::noelem: {x->Root[{-5+#1 Tan[Slot[<<1>>]]&,4.0335677903399816532}]} is not a valid set of export elements for the XLS format.

(* Out[3] = $Failed *) 
$\endgroup$
6
  • $\begingroup$ "this is my code" - where? $\endgroup$ Commented May 9, 2020 at 3:37
  • 1
    $\begingroup$ Reduce[x Tan[x] == 5 && 0 <= x <= 100, x] $\endgroup$ Commented May 9, 2020 at 3:43
  • 1
    $\begingroup$ n = ToRules[Out[53]] $\endgroup$ Commented May 9, 2020 at 3:44
  • 1
    $\begingroup$ Edit your question to include this information, instead of leaving it in comments. $\endgroup$ Commented May 9, 2020 at 3:44
  • 1
    $\begingroup$ now you can see my code $\endgroup$ Commented May 9, 2020 at 3:48

2 Answers 2

6
$\begingroup$

Actually, the conversion of Sequence into the List can be done easy:

 a=ToRules@Reduce[x Tan[x] == 5 && 0 <= x <= 100, x]; b=x /. List[a]; Export["file.xlsx", b] 

The Export gives you an Excel file with the desired column of numbers

$\endgroup$
1
  • 1
    $\begingroup$ Thank you very much , you did it $\endgroup$ Commented May 9, 2020 at 5:08
6
$\begingroup$

I think you probably want to use NSolve instead of Reduce.

roots = x /. NSolve[x Tan[x] == 5 && 0 <= x <= 100, x] Export["outfile.xls", roots] 

This will produce a column of 32 roots, which I think is what you want.

$\endgroup$
1
  • 1
    $\begingroup$ Thank you very much , you did it $\endgroup$ Commented May 9, 2020 at 5:08

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.