MathGroup Archive 2010

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

Search the Archive

Re: simple question for mathematica (corrected)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg106893] Re: simple question for mathematica (corrected)
  • From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
  • Date: Tue, 26 Jan 2010 06:35:37 -0500 (EST)
  • References: <hjjqfo$92b$1@smc.vnet.net>

Hi Manolis,

An easy question, so I expect to see at least 12 answers. Here are my
two cents.

4 possible function definitions:

Using piecewise (enter as esc-pw-esc or copy the below lines)
============
g[x_] := \[Piecewise] {
   {150, 0 < x < 15},
   {x^3, 15 < x < 24}
  }

With conditions
===========
g[x_] := 150 /; 0 < x < 15
g[x_] := x^3 /; 15 < x < 24

With If[ ]
======
g[x_] := If[0 < x < 15, 150, If[15 < x < 24, x^3]]

and Boole[ ] (which yields 1 if true and 0 if false
==========================
=========
g[x_] := 150 Boole[0 < x < 15] + x^3 Boole[15 < x < 24]


To Plot:
======
Plot[g[x], {x, 0, 24}, Frame -> True]

Cheers -- Sjoerd

On Jan 25, 12:06 pm, MANOLIS VOSKAKIS <emperor_... at hotmail.com> wrote:
> we have a function that is divided in 2 sub equations
> f=150 when 0<x<15
> f=x^3 when 15<x<24
>
> how can i create a plot of this function in mathematica??
> i want all in 1 graph
>
> thanks alot
> manolis



  • Prev by Date: License terms for free Mathematica Player
  • Next by Date: Can Mathematica interpolate non-uniform scatter data?
  • Previous by thread: Re: simple question for mathematica (corrected)
  • Next by thread: More memory-efficient inner product for large last dimension?