NM-Solved(How to plot points from a Maximize[ ] output)

In summary, To plot points from a "Maximize[ ]" output, you can assign the solution to a variable and then use the second element of the solution, which contains the values of the variables, to reference the numbers without manually entering them.
  • #1
Wesleytf
32
0
NM-Solved(How to plot points from a "Maximize[ ]" output)

Hello all,

I'm working with some data sets and I want to make a bar-type graph out of the numbers that result after a series of equations ending in a maximize function. My trouble is that the output of the function gives something like

Code:
{21.0133, {b -> 1, c -> -3., d -> 2., e -> 3, f -> 4}}

How can I reference these numbers without having to manually enter them? I want to make a list plot out of them where each value corresponds to x coordinates 1, 2..., so I need them in a list {1, -3, 2, 3, 4}. Any ideas?

edit: I think I can solve this by flipping the equation and using linear programming. No need to reply, but thanks for looking.
 
Last edited:
Physics news on Phys.org
  • #2


The way I would do it is assign that solution to a variable, like this

Code:
solution = Maximize[...]

Then, you can apply this as you see fit. Here is an example:

Code:
Plot[function[a,b,c] /. solution[[2]]]

The /. tells Mathematica to replace the arguments of function[] with the values of a,b,c from solution.

You use solution[[2]] because the second element of solution is the values of the variables.
 
  • #3


Wesleytf said:
Code:
{21.0133, {b -> 1, c -> -3., d -> 2., e -> 3, f -> 4}}

How can I reference these numbers without having to manually enter them?

myaray = {b -> 1, c -> -3., d -> 2., e -> 3, f -> 4}

#[[2]] & /@ myaray
 

Related to NM-Solved(How to plot points from a Maximize[ ] output)

1. How do I plot points from the output of a Maximize function in NM-Solved?

To plot points from the output of a Maximize function in NM-Solved, you will first need to save the output as a table. Then, you can use a graphing software or tool to plot the points from the table.

2. Can I plot multiple points from a single Maximize function output?

Yes, you can plot multiple points from a single Maximize function output by saving the output as a table and using a graphing software or tool to plot all the points from the table.

3. Do I need to have a specific type of graphing software to plot points from NM-Solved?

No, you can use any graphing software or tool to plot points from NM-Solved. As long as you have the output saved as a table, you can use any software that can plot points from a table.

4. How can I ensure that the plotted points accurately represent the output of the Maximize function?

To ensure accuracy, you can check the table of values from the output of the Maximize function and compare it with the plotted points. If they match, then the plotted points accurately represent the output.

5. Can I customize the plot of points from a Maximize function output in NM-Solved?

Yes, you can customize the plot of points by using different settings and options in your graphing software or tool. You can also edit the table of values to include specific points or ranges that you want to plot.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
313
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
176
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
402
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
937
Back
Top