Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.9K Views
|
5 Replies
|
1 Total Like
View groups...
Share
Share this post:

[?] Plot both lines of p (for price) and b (for ad)?

Posted 7 years ago

Consider the following code:

=.
    s =.
    x = 1 - (2 s)^0.5
    \[Alpha] = 0.5
    n = 4
    A = 1 - x^n - \!\(
    \*UnderoverscriptBox[\(\[Sum]\), \(k = 0\), \(\(-1\) + n\)]
    \*FractionBox[\(
    \(\*SuperscriptBox[\(x\), \(k\)]\)[1 - 
    \*SuperscriptBox[\(x\), \(\(-k\) + n\)]]\), \(\(-k\) + n\)]\)
    p = 1 - x
    b = \[Alpha] A*(1 - x)^2/(A + 1 - x^n)
    data = Table[Table[{s, f}, {s, 0, 1, 0.01}], {f, {p, b}}];
    ListLinePlot[data, PlotLegends -> {price, ad}]

In Mathematica, I want to show both lines of p (for price) and b (for ad), but why line of b is missing?enter image description here

POSTED BY: Fangqing Pu
5 Replies

Thank You! There are two errors - square brackets in Sum and zero initial value s, after fix it works

x =.
s =.
x = 1 - (2 s)^0.5
\[Alpha] = 0.5
n = 4
A = 1 - x^n - \!\(
\*UnderoverscriptBox[\(\[Sum]\), \(k = 0\), \(\(-1\) + n\)]
\*FractionBox[\(
\*SuperscriptBox[\(x\), \(k\)] \((1 - 
\*SuperscriptBox[\(x\), \(\(-k\) + n\)])\)\), \(\(-k\) + n\)]\)
p = 1 - x
b = \[Alpha] A*(1 - x)^2/(A + 1 - x^n)
data = Table[Table[{s, f}, {s, 0.0001, 1, 0.01}], {f, {p, b}}];
ListLinePlot[data, PlotLegends -> {price, ad}]

Fig

Posted 7 years ago

thanks a lot

POSTED BY: Fangqing Pu
   x = 1 - (2 s)^0.5;
   \[Alpha] = 0.5;
   n = 4;
   A = 1 - x^n - Sum[(x^k*(1 - x^(-k + n)))/(-k + n), {k, 1, n - 1}];
   p = 1 - x;
   b = \[Alpha]*A*(1 - x)^2/(A + 1 - x^n);
   data = Table[{s, p}, {s, 0, 1, 0.01}];
   data2 = Table[{s, b}, {s, 0.0001, 1, 0.01}];
   ListLinePlot[{data, data2}, PlotLegends -> {price, ad}]

enter image description here

POSTED BY: Mariusz Iwaniuk
Posted 7 years ago

thanks a lot

POSTED BY: Fangqing Pu

Please post actual code (not an image), and a question to go with it.

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