Message Boards Message Boards

0
|
5631 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Want 1/0 to be consider as 0 in my equation. How to do it?

Posted 4 years ago
hc = 0.0;

Dxc = 880200;
Exc = Dxc/\!\(
\*SubsuperscriptBox[\(\[Integral]\), \(\(-hc\)/2\), \(hc/2\)]\(
\*SuperscriptBox[\(z\), \(2\)] \[DifferentialD]z\)\)

I want to calculate Dx values for different hc(core height) values. if i substitute the hc value equal to 0 then I am getting error message(1/0 infinite expression ) instead of 0 which is my requirement.

Kindly help me out to get zero instead of error message.

Attachments:
POSTED BY: vin Bha
2 Replies
Posted 4 years ago

You can avoid the singularity by first determining the integral expression and do the division later on

int = \!\(
\*SubsuperscriptBox[\(\[Integral]\), \(\(-hc\)/2\), \(hc/2\)]\(
\*SuperscriptBox[\(z\), \(2\)] \[DifferentialD]z\)\)

Exc = Dxc/ int
POSTED BY: Michael Helmle
Posted 4 years ago

Some other tools and languages provide a Divide(numerator, denominator, default) function that returns the specified default value when the denominator is 0.

So, I created my own version in the Wolfram langage.

Options[tdyDivide] = {
   "default" -> 0., 
   "precision" -> 2
   };
tdyDivide[numerator_?NumericQ, denominator_?NumericQ, 
   OptionsPattern[]] := 
  N[
   If[
    denominator !=  0.,
    numerator / denominator,
    OptionValue["default"]
    ],
   OptionValue["precision"]
   ];

I'm still building unit tests for this. So, if you find any issues, please let me know.

thanks

POSTED BY: Mike Besso
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract