       Re: Division by Zero (Error Handling)

• To: mathgroup at smc.vnet.net
• Subject: [mg66974] Re: [mg66950] Division by Zero (Error Handling)
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Tue, 6 Jun 2006 06:26:56 -0400 (EDT)
• Reply-to: hanlonr at cox.net
• Sender: owner-wri-mathgroup at wolfram.com

```For the first part:

f[x_List,y_List]:=
x/(y/.(0->Infinity))/;
Dimensions[x]==Dimensions[y];

A=Table[Random[Integer,{1,3}],{3},{3}]

{{3, 1, 2}, {1, 3, 2}, {1, 3, 1}}

B=Table[Random[Integer,{0,3}],{3},{3}]

{{1, 2, 2}, {0, 3, 1}, {3, 1, 3}}

f[A,B]

{{3, 1/2, 1}, {0, 1, 2}, {1/3, 3, 1/3}}

Bob Hanlon

---- Bruce Colletti <vze269bv at verizon.net> wrote:
> When dividing (elementwise) two matrices of similar dimension (e.g., A/B), zero-elements in B cause a "division by zero" error message.  In such a case, regardless of numerator, I want the pair's ratio to be zero.
>
> Without building a module that defines modified matrix division, how can I establish that whenever (throughout the notebook) division by zero occurs (regardless of numerator), that the result can be zero?
>
> Thanks.
>
> Bruce
>

--

Bob Hanlon
hanlonr at cox.net

```

• Prev by Date: Re: Function argument
• Next by Date: RE: Function argument
• Previous by thread: Re: Division by Zero (Error Handling)
• Next by thread: Function argument