MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: plot several functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg35900] RE: plot several functions
  • From: "DrBob" <majort at cox-internet.com>
  • Date: Wed, 7 Aug 2002 05:59:18 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

You can redefine the functions to take advantage of their commonality,
something like this:

(I'm using Sin[x] as the LARGE BLOCK)

helper[x_] := Sin[x]
fun1[large_, x_] := Cos[x]large
fun2[large_, x_] := Exp[x]large
fun3[large_, x_] := x large

Plot[Evaluate@{h = helper[t]; fun1[h, t], fun2[h, t], fun3[h, t]}, {t,
0, Pi}]

or

helper[x_] := Sin[x]
fun1[large_, x_] := Cos[x]large
fun2[large_, x_] := Exp[x]large
fun3[large_, x_] := x large
vector[x_] := (h = helper[t]; {fun1[h, t], fun2[h, t], fun3[h, t]})

Plot[Evaluate@vector@t, {t, 0, Pi}]

For other purposes, you can still define

fun1[arg_]:=fun1[helper@arg,arg]

et cetera.

In case you haven't seen this before, f@x is the same as f[x].

Bobby

-----Original Message-----
From: Mihajlo Vanevic [mailto:mvane at eunet.yu] 
To: mathgroup at smc.vnet.net
Subject: [mg35900] plot several functions

I have the following problem:

I have to plot several functions at once, like

Plot[{fun1[t], fun2[t], fun3[t]},{t,0,1}]


where fun1,2,3  consists of the same (large!!) block,
something like:

fun1[arg_]:=Module[... LARGE BLOCK; result1];
fun2[arg_]:=Module[... LARGE BLOCK(same as above); result2];
fun3[arg_]:=Module[... LARGE BLOCK(same as above); result3];

When I do the plot, this block is evaluated three times for every t,
and the plot takes very long time...
Is there any way to make my plot faster, by evaluating
LARGE BLOCK (in Plot) only once, for every t??








  • Prev by Date: Re: Using % in ; separated commands
  • Next by Date: RE: Using % in ; separated commands
  • Previous by thread: Re: Re: Reading/Writing files across networks
  • Next by thread: RE: RE: plot several functions