MathGroup Archive 2012

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

Search the Archive

Re: Executing function on Mathematica 8

  • To: mathgroup at smc.vnet.net
  • Subject: [mg124691] Re: Executing function on Mathematica 8
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Tue, 31 Jan 2012 05:40:40 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201201301007.FAA17508@smc.vnet.net>
  • Reply-to: murray at math.umass.edu

It's not clear what you mean by "how to enter..and then call" the 
function. Are you a total beginner with Mathematica?

Are you working with the usual Mathematica notebook Front End?

If so, then:

(1) click the cursor somewhere to create a new Input cell; you'll see a 
horizontal line there with a + sign at its left.

(2) Type the whole definition, either as you've shown it divided over 
several lines, or else on a single line (and in that case let 
Mathematica automatically wrap it over several lines).

     [The semicolon at the very end is superfluous, since you've used a
      := (SetDelayed) assignment.

     Since the default value of $MaxPrecision is Infinity, the If part
     of your definition is useless unless you explicitly change
     $MaxPrecision.]

Press Shift Enter so as to _evaluate_ that cell.

(3) To "call it", in a new input cell, just type something like, say,

    BinExp[11000.123456789123456789, Infinity]

and press Shift Enter to evaluate what's there.


If, on the other hand, you're just going to be using a command-line 
interface to the Kernel (the Mathematica calculating "engine"), you'll 
have to find out where and what on your system that is. On a Linux 
system that may already be on the search path and then the command to 
invoke it may be something as simple as:

   math

Once the Kernel is started, you'll get a prompt:

   In[1]:=

There you type the function definition, again divided over several lines 
(separated by pressing Return at the end of each) or on a single line.

When you're done, press Shift Enter to evaluate what you've typed.

Next, you'll get a prompt:

   In[2]:=

There type what you want to evaluate, e.g.,

   BinExp[123456789.123456789,50]

and again press Shift Enter to evaluate that expression.


On 1/30/12 5:07 AM, Fadi Mousa wrote:
> Dear mathematica members,
>
> I am new to mathematica and do not know how to enter the following
> function and then call it on mathematica 8:
>
> BinExp[num_,d_] := Module[{n,L},
> If[d>  $MaxPrecision, $MaxPrecision = d];
> n = N[num,d];
> L = First[RealDigits[n,2]]
> ];
>
> Any help is appreciated,
>
> Best Regards,
> Fadi Abu-Amara
>

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305



  • Prev by Date: Re: Function Doesn't Evaluate Local Variables?
  • Next by Date: Re: navigate notebook, further question
  • Previous by thread: Executing function on Mathematica 8
  • Next by thread: Re: Executing function on Mathematica 8