Plotting



On 3/15/12, Vishnu Rajasekharan <vishraj at gmail.com> wrote:

> I have four functions:
>
> h(t), i(t), j(t), k(t)
>
> Then I have a cubic equation incorporating the four functions
>
> l(t):=(Z^3)*h(t)+(Z^2)*i(t)+(Z)*j(t)+k(t)
>
> I solved it using
>
> P:realroots(l(t))
>
> and selected the root using
>
> z:rhs(%[1]);
>
> Now I need to plot with "t" in the x axis ans "P" in the y axis.
>
> I used
>
> wxplot2d([P(t)],[t,0,100],[xlabel, "t)"],[style,[lines,3,5]],
> [ylabel, "P"],[gnuplot_preamble, "set grid; set key  top left;
> set title P vs. t;  "])$

Without knowing the functions h, i, j, & k, it's hard to say for sure.
But maybe P(t) := (realroots (l (t)), rhs (%% [1])) gives the result you want.
Oh, and you'll want to just put the name of P in the call to the
plotting function, like plot2d (P, [t, 0, 100]) (I don't know if wxplot2d
recognizes function names).

I don't know if realroots is guaranteed to return its results in
increasing order or something like that.
Maybe you need to throw in sort(%%) to impose an order.

best

Robert Dodier