Skip to main content
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link

I believe this question should eventually be closed as its elements have been addressed before. However since you are new I hope to give a better welcome than merely "go read this" etc. To that end:

  1. If you can solve your equation Symbolically you can use Solve once, then populate values of a as desired.

  2. The output format of Solve is a List of Lists of Rule expressions. Each sublist is a solution. They are in this format for convenience, not to make things difficult. See Assign the results from a Solve to variable(s)Assign the results from a Solve to variable(s) for a few ideas about handling these.

As an example I will perform a symbolic Solve, then extract the first (only) x solution and name it x1, then use Table to create your table of results. You can Export this or display it with TableForm.

sol = Solve[a*x - 10 == 0, x] x1 = x /. sol[[1]] (* see documentation for ReplaceAll and Part *) Table[{a, x1}, {a, 1, 10}] 
{{x -> 10/a}} 10/a {{1, 10}, {2, 5}, {3, 10/3}, {4, 5/2}, {5, 2}, {6, 5/3}, {7, 10/7}, {8, 5/4}, {9, 10/9}, {10, 1}} 

To differentiate this answer from Chen Stats Yu's here is another formulation that in time may interest you:

fx1 = {#, x} & /. First @ Solve[#*x - 10 == 0, x] Array[fx1, 10] 
{{1, 10}, {2, 5}, {3, 10/3}, {4, 5/2}, {5, 2}, {6, 5/3}, {7, 10/7}, {8, 5/4}, {9, 10/9}, {10, 1}} 

I believe this question should eventually be closed as its elements have been addressed before. However since you are new I hope to give a better welcome than merely "go read this" etc. To that end:

  1. If you can solve your equation Symbolically you can use Solve once, then populate values of a as desired.

  2. The output format of Solve is a List of Lists of Rule expressions. Each sublist is a solution. They are in this format for convenience, not to make things difficult. See Assign the results from a Solve to variable(s) for a few ideas about handling these.

As an example I will perform a symbolic Solve, then extract the first (only) x solution and name it x1, then use Table to create your table of results. You can Export this or display it with TableForm.

sol = Solve[a*x - 10 == 0, x] x1 = x /. sol[[1]] (* see documentation for ReplaceAll and Part *) Table[{a, x1}, {a, 1, 10}] 
{{x -> 10/a}} 10/a {{1, 10}, {2, 5}, {3, 10/3}, {4, 5/2}, {5, 2}, {6, 5/3}, {7, 10/7}, {8, 5/4}, {9, 10/9}, {10, 1}} 

To differentiate this answer from Chen Stats Yu's here is another formulation that in time may interest you:

fx1 = {#, x} & /. First @ Solve[#*x - 10 == 0, x] Array[fx1, 10] 
{{1, 10}, {2, 5}, {3, 10/3}, {4, 5/2}, {5, 2}, {6, 5/3}, {7, 10/7}, {8, 5/4}, {9, 10/9}, {10, 1}} 

I believe this question should eventually be closed as its elements have been addressed before. However since you are new I hope to give a better welcome than merely "go read this" etc. To that end:

  1. If you can solve your equation Symbolically you can use Solve once, then populate values of a as desired.

  2. The output format of Solve is a List of Lists of Rule expressions. Each sublist is a solution. They are in this format for convenience, not to make things difficult. See Assign the results from a Solve to variable(s) for a few ideas about handling these.

As an example I will perform a symbolic Solve, then extract the first (only) x solution and name it x1, then use Table to create your table of results. You can Export this or display it with TableForm.

sol = Solve[a*x - 10 == 0, x] x1 = x /. sol[[1]] (* see documentation for ReplaceAll and Part *) Table[{a, x1}, {a, 1, 10}] 
{{x -> 10/a}} 10/a {{1, 10}, {2, 5}, {3, 10/3}, {4, 5/2}, {5, 2}, {6, 5/3}, {7, 10/7}, {8, 5/4}, {9, 10/9}, {10, 1}} 

To differentiate this answer from Chen Stats Yu's here is another formulation that in time may interest you:

fx1 = {#, x} & /. First @ Solve[#*x - 10 == 0, x] Array[fx1, 10] 
{{1, 10}, {2, 5}, {3, 10/3}, {4, 5/2}, {5, 2}, {6, 5/3}, {7, 10/7}, {8, 5/4}, {9, 10/9}, {10, 1}} 
Source Link
Mr.Wizard
  • 275.2k
  • 34
  • 606
  • 1.5k

I believe this question should eventually be closed as its elements have been addressed before. However since you are new I hope to give a better welcome than merely "go read this" etc. To that end:

  1. If you can solve your equation Symbolically you can use Solve once, then populate values of a as desired.

  2. The output format of Solve is a List of Lists of Rule expressions. Each sublist is a solution. They are in this format for convenience, not to make things difficult. See Assign the results from a Solve to variable(s) for a few ideas about handling these.

As an example I will perform a symbolic Solve, then extract the first (only) x solution and name it x1, then use Table to create your table of results. You can Export this or display it with TableForm.

sol = Solve[a*x - 10 == 0, x] x1 = x /. sol[[1]] (* see documentation for ReplaceAll and Part *) Table[{a, x1}, {a, 1, 10}] 
{{x -> 10/a}} 10/a {{1, 10}, {2, 5}, {3, 10/3}, {4, 5/2}, {5, 2}, {6, 5/3}, {7, 10/7}, {8, 5/4}, {9, 10/9}, {10, 1}} 

To differentiate this answer from Chen Stats Yu's here is another formulation that in time may interest you:

fx1 = {#, x} & /. First @ Solve[#*x - 10 == 0, x] Array[fx1, 10] 
{{1, 10}, {2, 5}, {3, 10/3}, {4, 5/2}, {5, 2}, {6, 5/3}, {7, 10/7}, {8, 5/4}, {9, 10/9}, {10, 1}}