Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #13800 > unrolled thread

How to plot functions

Started byradres <radressss@gmail.com>
First post2013-03-10 05:47 +0000
Last post2013-03-11 05:41 +0000
Articles 4 — 4 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  How to plot functions radres <radressss@gmail.com> - 2013-03-10 05:47 +0000
    Re: How to plot functions "Nasser M. Abbasi" <nma@12000.org> - 2013-03-10 21:06 +0000
    Re: How to plot functions Jak Alof <spamaddress.giveaway@yahoo.com> - 2013-03-11 05:41 +0000
    Re: How to plot functions Helen Read <readhpr@gmail.com> - 2013-03-11 05:41 +0000

#13800 — How to plot functions

Fromradres <radressss@gmail.com>
Date2013-03-10 05:47 +0000
SubjectHow to plot functions
Message-ID<khh6p6$ako$1@smc.vnet.net>
Hi,

Let's say I've defined a function f[c]=c*x^2

when I try to plot this directly,

Plot[ f[3], {x, -10, 10} ] 

it doesn't plot anything.

But when I assign function to a variable,

v1=f[3]; Plot[v1, {x, -10, 10}]

then there is no problem. But I dont want this. Is there any way to plot directly from a function?

[toc] | [next] | [standalone]


#13802

From"Nasser M. Abbasi" <nma@12000.org>
Date2013-03-10 21:06 +0000
Message-ID<khisjr$mk8$1@smc.vnet.net>
In reply to#13800
On 3/9/2013 11:47 PM, radres wrote:
> Hi,
>
> Let's say I've defined a function f[c]=c*x^2

that should be

        f[c_,x_]:=c*x^2

>
> when I try to plot this directly,
>
> Plot[ f[3], {x, -10, 10} ]
>
> it doesn't plot anything.

try

f[c_, x_] := c*x^2;
Plot[f[3, x], {x, -10, 10}]


>
> But when I assign function to a variable,
>
> v1=f[3]; Plot[v1, {x, -10, 10}]
>
> then there is no problem. But I dont want this. Is there any way to plot directly from a function?
>

see above.

[toc] | [prev] | [next] | [standalone]


#13806

FromJak Alof <spamaddress.giveaway@yahoo.com>
Date2013-03-11 05:41 +0000
Message-ID<khjqpf$77j$1@smc.vnet.net>
In reply to#13800
f[c_, x_] := c Power[x, 2]
Plot[f[3, x], {x, -10, 10}]

On Saturday, March 9, 2013 10:47:18 PM UTC-7, radres wrote:
> Hi,
> 
> 
> 
> Let's say I've defined a function f[c]=c*x^2
> 
> 
> 
> when I try to plot this directly,
> 
> 
> 
> Plot[ f[3], {x, -10, 10} ] 
> 
> 
> 
> it doesn't plot anything.
> 
> 
> 
> But when I assign function to a variable,
> 
> 
> 
> v1=f[3]; Plot[v1, {x, -10, 10}]
> 
> 
> 
> then there is no problem. But I dont want this. Is there any way to plot directly from a function?

[toc] | [prev] | [next] | [standalone]


#13808

FromHelen Read <readhpr@gmail.com>
Date2013-03-11 05:41 +0000
Message-ID<khjqpv$77p$1@smc.vnet.net>
In reply to#13800
You need an underscore to indicate that c is a variable.

f[c_]:=c x^2

Plot[f[3],{x,-10,10}]

It is also a good idea to make x a variable, like this.

Clear[f]

f[x_,c_]:=c x^2

Plot[f[x,3],{x,-10,10}]

Manipulate[Plot[f[x, c], {x, -10, 10}, PlotRange -> 500], {c, -5, 5}]


Or like this.

Clear[f]

f[c_][x_] := c x^2

Plot[f[3][x], {x, -10, 10}]

Manipulate[Plot[f[c][x], {x, -10, 10}, PlotRange -> 500], {c, -5, 5}]


I prefer this latter style of notation if I am thinking of one of the 
variables (here c) as a subscript or parameter, as opposed to defining a 
multivariate function that I would plot with Plot3D.

Helen Read
University of Vermont


On 3/10/2013 12:47 AM, radres wrote:
> Hi,
>
> Let's say I've defined a function f[c]=c*x^2
>
> when I try to plot this directly,
>
> Plot[ f[3], {x, -10, 10} ]
>
> it doesn't plot anything.
>
> But when I assign function to a variable,
>
> v1=f[3]; Plot[v1, {x, -10, 10}]
>
> then there is no problem. But I dont want this. Is there any way to plot directly from a function?
>


[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web