Skip to main content
Added new attempt of solution.
Source Link
BowPark
  • 315
  • 2
  • 8

I am using Wolfram Mathematica 11. Given these quantities:

v = 3; 
Y = Sqrt[v^2 - X^2];

Ja = BesselJ[0, X]; 
Jap = -BesselJ[1, X];

Ka = BesselK[0, Y]; 
Kap = -BesselK[1, Y];

side1 = Jap / (X*Ja); 
side2 = -Kap / (Y*Ka);

I would like to obtain the same visual output as:

Plot[{side1, side2}, {X, 0, 10}]

but on a .txt file, simply containing a table of values in this notation:

 0.0000000000e+00 -inf -inf
 3.0060120240e-02 -2.3042094212e+00 -2.1217639107e+01
 6.0120240481e-02 -1.8613440179e+00 -1.0654661322e+01

First column should list the X values; second column should list the corresponding side1 values; third column the corresponding side2 values.

How is it possible, with and without adaptive sampling?

Important note: I am not obliged to use Plot. I would like to obtain a .txt output file with the lines in the same format as above. The way it is created (through Plot or any other suitable function) is not important.


Edit: I obtained two separate tables (in the desired format) this way:

pts1 = Cases[Plot[side1[X], {X, 0, 10}, PlotRange -> {-1.6, 1.6}], Line[data_] :> data, All]~Flatten~1; Export["file1.txt",pts1,"Table"]

pts2 = Cases[Plot[side2[X], {X, 0, 10}, PlotRange -> {-1.6, 1.6}], Line[data_] :> data, All]~Flatten~1; Export["file2.txt",pts2,"Table"]

Thanks to @MarcoB for his suggestions in the comments. Each file has only two columns. Note that file1.txt spans from X = 0 to X = 10, while file2.txt from X = 0 to X = 1.778, for the reasons pointed out by @m_golberg.

I was looking for a single table with (from left to right) a column for the abscissa, a column for side1 and a column for side2. This solution instead would demand to the external reader, which uses the table, the task to correctly overlap the two tables. This was not my initial intention, but if this is the only way, it is acceptable as well.

I am using Wolfram Mathematica 11. Given these quantities:

v = 3; 
Y = Sqrt[v^2 - X^2];

Ja = BesselJ[0, X]; 
Jap = -BesselJ[1, X];

Ka = BesselK[0, Y]; 
Kap = -BesselK[1, Y];

side1 = Jap / (X*Ja); 
side2 = -Kap / (Y*Ka);

I would like to obtain the same visual output as:

Plot[{side1, side2}, {X, 0, 10}]

but on a .txt file, simply containing a table of values in this notation:

 0.0000000000e+00 -inf -inf
 3.0060120240e-02 -2.3042094212e+00 -2.1217639107e+01
 6.0120240481e-02 -1.8613440179e+00 -1.0654661322e+01

First column should list the X values; second column should list the corresponding side1 values; third column the corresponding side2 values.

How is it possible, with and without adaptive sampling?

Important note: I am not obliged to use Plot. I would like to obtain a .txt output file with the lines in the same format as above. The way it is created (through Plot or any other suitable function) is not important.


Edit: I obtained two separate tables (in the desired format) this way:

pts1 = Cases[Plot[side1[X], {X, 0, 10}, PlotRange -> {-1.6, 1.6}], Line[data_] :> data, All]~Flatten~1; Export["file1.txt",pts1,"Table"]

pts2 = Cases[Plot[side2[X], {X, 0, 10}, PlotRange -> {-1.6, 1.6}], Line[data_] :> data, All]~Flatten~1; Export["file2.txt",pts2,"Table"]

Thanks to @MarcoB for his suggestions in the comments. Each file has only two columns. Note that file1.txt spans from X = 0 to X = 10, while file2.txt from X = 0 to X = 1.778, for the reasons pointed out by @m_golberg.

I was looking for a single table with (from left to right) a column for the abscissa, a column for side1 and a column for side2. This solution instead would demand to the external reader, which uses the table, the task to correctly overlap the two tables. This was not my initial intention, but if this is the only way, it is acceptable as well.

I am using Wolfram Mathematica 11. Given these quantities:

v = 3; 
Y = Sqrt[v^2 - X^2];

Ja = BesselJ[0, X]; 
Jap = -BesselJ[1, X];

Ka = BesselK[0, Y]; 
Kap = -BesselK[1, Y];

side1 = Jap / (X*Ja); 
side2 = -Kap / (Y*Ka);

I would like to obtain the same visual output as:

Plot[{side1, side2}, {X, 0, 10}]

but on a .txt file, simply containing a table of values in this notation:

 0.0000000000e+00 -inf -inf
 3.0060120240e-02 -2.3042094212e+00 -2.1217639107e+01
 6.0120240481e-02 -1.8613440179e+00 -1.0654661322e+01

First column should list the X values; second column should list the corresponding side1 values; third column the corresponding side2 values.

How is it possible, with and without adaptive sampling?

Important note: I am not obliged to use Plot. I would like to obtain a .txt output file with the lines in the same format as above. The way it is created (through Plot or any other suitable function) is not important.


Edit: I obtained two separate tables (in the desired format) this way:

pts1 = Cases[Plot[side1[X], {X, 0, 10}, PlotRange -> {-1.6, 1.6}], Line[data_] :> data, All]~Flatten~1; Export["file1.txt",pts1,"Table"]

pts2 = Cases[Plot[side2[X], {X, 0, 10}, PlotRange -> {-1.6, 1.6}], Line[data_] :> data, All]~Flatten~1; Export["file2.txt",pts2,"Table"]

Thanks to @MarcoB for his suggestions in the comments. Each file has only two columns. Note that file1.txt spans from X = 0 to X = 10, while file2.txt from X = 0 to X = 1.778, for the reasons pointed out by @m_golberg.

I was looking for a single table. This solution instead would demand to the external reader, which uses the table, the task to correctly overlap the two tables. This was not my initial intention, but if this is the only way, it is acceptable as well.

Added new attempt of solution.
Source Link
BowPark
  • 315
  • 2
  • 8

I am using Wolfram Mathematica 11. Given these quantities:

v = 3; 
Y = Sqrt[v^2 - X^2];

Ja = BesselJ[0, X]; 
Jap = -BesselJ[1, X];

Ka = BesselK[0, Y]; 
Kap = -BesselK[1, Y];

side1 = Jap / (X*Ja); 
side2 = -Kap / (Y*Ka);

I would like to obtain the same visual output as:

Plot[{side1, side2}, {X, 0, 10}]

but on a .txt file, simply containing a table of values in this notation:

 0.0000000000e+00 -inf -inf
 3.0060120240e-02 -2.3042094212e+00 -2.1217639107e+01
 6.0120240481e-02 -1.8613440179e+00 -1.0654661322e+01

First column should list the X values; second column should list the corresponding side1 values; third column the corresponding side2 values.

How is it possible, with and without adaptive sampling?

Important note: I am not obliged to use Plot. I would like to obtain a .txt output file with the lines in the same format as above. The way it is created (through Plot or any other suitable function) is not important.


This is my naive attempt to adapt code fromEdit: I obtained two separate tables this answer, at least for the plot of(in the first function side1desired format) this way:

datapts1 = Cases[Plot[side1@XCases[Plot[side1[X], {X, 0, 10}, PlotRange -> {-1.6, 1.6}], Line[data_] :> data, -4,All]~Flatten~1; Export["file1.txt",pts1,"Table"]

pts2 = Cases[Plot[side2[X], {X, 1][[1]];
Export["file.txt"0, data10}, "Table"]

but it generates an error:

Part:PlotRange Part-> {-1 of.6, {1.6}], doesLine[data_] not:> existdata, All]~Flatten~1; Export["file2.txt",pts2,"Table"]

Thanks to @MarcoB for his suggestions in the comments. Each file has only two columns. Note that file1.txt spans from X = 0 to X = 10, while file2.txt from X = 0 to X = 1.778, for the reasons pointed out by @m_golberg.

I was looking for a single table with (from left to right) a column for the abscissa, a column for side1 and a column for side2. This solution instead would demand to the external reader, which uses the table, the task to correctly overlap the two tables. This was not my initial intention, but if this is the only way, it is acceptable as well.

I am using Wolfram Mathematica 11. Given these quantities:

v = 3; 
Y = Sqrt[v^2 - X^2];

Ja = BesselJ[0, X]; 
Jap = -BesselJ[1, X];

Ka = BesselK[0, Y]; 
Kap = -BesselK[1, Y];

side1 = Jap / (X*Ja); 
side2 = -Kap / (Y*Ka);

I would like to obtain the same visual output as:

Plot[{side1, side2}, {X, 0, 10}]

but on a .txt file, simply containing a table of values in this notation:

 0.0000000000e+00 -inf -inf
 3.0060120240e-02 -2.3042094212e+00 -2.1217639107e+01
 6.0120240481e-02 -1.8613440179e+00 -1.0654661322e+01

First column should list the X values; second column should list the corresponding side1 values; third column the corresponding side2 values.

How is it possible, with and without adaptive sampling?

Important note: I am not obliged to use Plot. I would like to obtain a .txt output file with the lines in the same format as above. The way it is created (through Plot or any other suitable function) is not important.


This is my naive attempt to adapt code from this answer, at least for the plot of the first function side1:

data = Cases[Plot[side1@X, {X, 0, 10}], Line[data_] :> data, -4, 
    1][[1]];
Export["file.txt", data, "Table"]

but it generates an error:

Part: Part 1 of {} does not exist

I am using Wolfram Mathematica 11. Given these quantities:

v = 3; 
Y = Sqrt[v^2 - X^2];

Ja = BesselJ[0, X]; 
Jap = -BesselJ[1, X];

Ka = BesselK[0, Y]; 
Kap = -BesselK[1, Y];

side1 = Jap / (X*Ja); 
side2 = -Kap / (Y*Ka);

I would like to obtain the same visual output as:

Plot[{side1, side2}, {X, 0, 10}]

but on a .txt file, simply containing a table of values in this notation:

 0.0000000000e+00 -inf -inf
 3.0060120240e-02 -2.3042094212e+00 -2.1217639107e+01
 6.0120240481e-02 -1.8613440179e+00 -1.0654661322e+01

First column should list the X values; second column should list the corresponding side1 values; third column the corresponding side2 values.

How is it possible, with and without adaptive sampling?

Important note: I am not obliged to use Plot. I would like to obtain a .txt output file with the lines in the same format as above. The way it is created (through Plot or any other suitable function) is not important.


Edit: I obtained two separate tables (in the desired format) this way:

pts1 = Cases[Plot[side1[X], {X, 0, 10}, PlotRange -> {-1.6, 1.6}], Line[data_] :> data, All]~Flatten~1; Export["file1.txt",pts1,"Table"]

pts2 = Cases[Plot[side2[X], {X, 0, 10}, PlotRange -> {-1.6, 1.6}], Line[data_] :> data, All]~Flatten~1; Export["file2.txt",pts2,"Table"]

Thanks to @MarcoB for his suggestions in the comments. Each file has only two columns. Note that file1.txt spans from X = 0 to X = 10, while file2.txt from X = 0 to X = 1.778, for the reasons pointed out by @m_golberg.

I was looking for a single table with (from left to right) a column for the abscissa, a column for side1 and a column for side2. This solution instead would demand to the external reader, which uses the table, the task to correctly overlap the two tables. This was not my initial intention, but if this is the only way, it is acceptable as well.

Clarified that usage of Plot is not mandatory.
Source Link
BowPark
  • 315
  • 2
  • 8

I am using Wolfram Mathematica 11. Given these quantities:

v = 3; 
Y = Sqrt[v^2 - X^2];

Ja = BesselJ[0, X]; 
Jap = -BesselJ[1, X];

Ka = BesselK[0, Y]; 
Kap = -BesselK[1, Y];

side1 = Jap / (X*Ja); 
side2 = -Kap / (Y*Ka);

I would like to obtain the same visual output as:

Plot[{side1, side2}, {X, 0, 10}]

but on a .txt file, simply containing a table of values in this notation:

 0.0000000000e+00 -inf -inf
 3.0060120240e-02 -2.3042094212e+00 -2.1217639107e+01
 6.0120240481e-02 -1.8613440179e+00 -1.0654661322e+01

First column should list the X values; second column should list the corresponding side1 values; third column the corresponding side2 values.

How is it possible, with and without adaptive sampling?

Important note: I am not obliged to use Plot. I would like to obtain a .txt output file with the lines in the same format as above. The way it is created (through Plot or any other suitable function) is not important.


This is my naive attempt to adapt code from this answer, at least for the plot of the first function side1:

data = Cases[Plot[side1@X, {X, 0, 10}], Line[data_] :> data, -4, 
    1][[1]];
Export["file.txt", data, "Table"]

but it generates an error:

Part: Part 1 of {} does not exist

I am using Wolfram Mathematica 11. Given these quantities:

v = 3; 
Y = Sqrt[v^2 - X^2];

Ja = BesselJ[0, X]; 
Jap = -BesselJ[1, X];

Ka = BesselK[0, Y]; 
Kap = -BesselK[1, Y];

side1 = Jap / (X*Ja); 
side2 = -Kap / (Y*Ka);

I would like to obtain the same as:

Plot[{side1, side2}, {X, 0, 10}]

but on a .txt file, simply containing a table of values in this notation:

 0.0000000000e+00 -inf -inf
 3.0060120240e-02 -2.3042094212e+00 -2.1217639107e+01
 6.0120240481e-02 -1.8613440179e+00 -1.0654661322e+01

First column should list the X values; second column should list the corresponding side1 values; third column the corresponding side2 values.

How is it possible, with and without adaptive sampling?


This is my naive attempt to adapt code from this answer, at least for the plot of the first function side1:

data = Cases[Plot[side1@X, {X, 0, 10}], Line[data_] :> data, -4, 
    1][[1]];
Export["file.txt", data, "Table"]

but it generates an error:

Part: Part 1 of {} does not exist

I am using Wolfram Mathematica 11. Given these quantities:

v = 3; 
Y = Sqrt[v^2 - X^2];

Ja = BesselJ[0, X]; 
Jap = -BesselJ[1, X];

Ka = BesselK[0, Y]; 
Kap = -BesselK[1, Y];

side1 = Jap / (X*Ja); 
side2 = -Kap / (Y*Ka);

I would like to obtain the same visual output as:

Plot[{side1, side2}, {X, 0, 10}]

but on a .txt file, simply containing a table of values in this notation:

 0.0000000000e+00 -inf -inf
 3.0060120240e-02 -2.3042094212e+00 -2.1217639107e+01
 6.0120240481e-02 -1.8613440179e+00 -1.0654661322e+01

First column should list the X values; second column should list the corresponding side1 values; third column the corresponding side2 values.

How is it possible, with and without adaptive sampling?

Important note: I am not obliged to use Plot. I would like to obtain a .txt output file with the lines in the same format as above. The way it is created (through Plot or any other suitable function) is not important.


This is my naive attempt to adapt code from this answer, at least for the plot of the first function side1:

data = Cases[Plot[side1@X, {X, 0, 10}], Line[data_] :> data, -4, 
    1][[1]];
Export["file.txt", data, "Table"]

but it generates an error:

Part: Part 1 of {} does not exist
edited title
Link
m_goldberg
  • 108.1k
  • 16
  • 104
  • 259
Loading
edited tags
Source Link
m_goldberg
  • 108.1k
  • 16
  • 104
  • 259
Loading
edited tags
Link
m_goldberg
  • 108.1k
  • 16
  • 104
  • 259
Loading
Source Link
BowPark
  • 315
  • 2
  • 8
Loading