Message Boards Message Boards

Plot with and without `Table` produce different results

Posted 1 year ago
POSTED BY: Ian P
6 Replies
POSTED BY: Michael Rogers
Posted 1 year ago

@Michael Rogers, I tried your first suggested code and it worked producing the same plot as the first plot! And it didn't take too long. Thank you so much!! May I ask one more question? Looking at the first plot, I would like to truncate the curve at where it touches the x-axis from the right (that's somewhere around 2.7) to remove the flat portion and spike portion of the curve, eventually leaving that nice curve. Do you know how to do this?

POSTED BY: Ian P
Posted 1 year ago

Hi, If the number where you want the plot to start is 2.7, then change the plot command to

Plot[brf[w], {w, 2.7, 12}, PlotRange -> {{0, 12}, {0, 1}}]

Plot[] will automatically choose the axes origin. If it's not (0,0) and you would like it to be, then you can control the placement of the axes with the option AxesOrigin. For instance,

Plot[brf[w], {w, 0, 12}, PlotRange -> {{0, 12}, {0, 1}}, AxesOrigin -> {0, 0}]
POSTED BY: Updating Name
Posted 1 year ago

@Michael Rogers, I have posted another related question here. If possible, may I ask for your help once more? Thank you very much in advance!

POSTED BY: Ian P

The second version has a Simplify which may raise numerical issues, which I have not tried to investigate.

A curious feature that I noticed in your code is that in your function definition brf[w_]:=rhs the right hand side has no explicit w. This way for example brf[1] does not evaluate to a number, while brf[w] /. w -> 1 does.

A simplified version of the issue is with the "function" x = a; f[a_] := x. Perhaps surprisingly, the following gives False:

{f[0], f[1]} === Table[f[a], {a, 0, 1}]
POSTED BY: Gianluca Gorni
Posted 1 year ago

@Gianluca Gorni, thanks for the comment. In brf[w_]:=rhs, the right hand side does have w; note that the objective function v has w through Uem.

POSTED BY: Ian P
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract