cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

arg-Error when argument is zero

rmix22-disabled
1-Newbie

arg-Error when argument is zero

Hope I found the right forum to post my question.
I am using MC14 an ever so often I encounter a problem with sheets made by previous versions, because various plots ar not shown, because of "arg()" in some function and the use of range-variables which have to include Zero.
While it is true, that arg(0) ist no distinct value it would be valuable if this "error" could be supressed an so the plot beein shown.
My workaround ist inserting a selfdefinded arg-function at the top of these sheets, which return Zero if the Argument is 0 an the originbal arg() otherwise.
Is there a better method to get the behaviour of older Mathcad-Versions without changing the wotksheet?

Tnx
rm
8 REPLIES 8

It seems that the Mathcad 14 Quick plot is a different subcontract than it was at least up to version 11. Prior and up to 11 version, the QuickPlot would, in most cases, ignore the singularities. Obviously enough in your previous creations, you surely have a lot of technically incorrect QuickPlots, managed whatsoever and that now the 14 does not take. You may not have to fabricate that "argument eliminator", but just discretize wisely by assuring no argument will be "singular". You don't seem you have adapted yourself to the "scalar maths" and the "numerical maths" and how to merge them in real projects and how CAS work with these two kinds of maths.

Attach a typical sheet and hope for diligent 14 users to consider.

jmG

...in short but not a feature really:
Restore the previous versions "Mathcad QuickPlot" as it was. In all these discussions, it seems impossible to cope with PTC "green reformatting views" of the numerical maths as working tools.

"Un dialogue de sourds !" [same meaning in english].

jmG

>Prior
>and up to 11 version, the
>QuickPlot would, in most
>cases, ignore the
>singularities. Obviously

Maybe I was not precise enough - sorry about my faulty english.
What I meant was, that a user defined function caused the error and when plotting another function depending on that function (not a quickplot but over a range-variable including Zero) the plot is not done because of the function being singular for one argument.
I found a switch to control the behaviour for 0/0 but no one for ambiguities like arg(0). Maybe a theme for "Feature Suggestions?".
BTW, used arg(x) to be phi(x) in prior versions? Found some worksheet on the net which leds me to that idea.

Regards
rmix

How old a version are you talking about? arg(0) fails in MC11.

You can use the on error construct to catch errors. Or you can use if's in your program to avoid evaluating arg(0).

The 2D plot will ignore invalid points. If you plot an expression, evaluated for multiple values, you should be a plot with holes at the invalid values. If, however, you try to calculate a vector of values to plot then a failure to calculate any element fails the entire calculation.

To provide more specific information I would have to see the actual sheet with the problem.
__________________
� � � � Tom Gutman

OK - think I have to put some things straight.
The worksheet was one I stumbled upon while surfing along, nor my own. It was a selfmade fourierseries-demonstration and for spectrum the Argument of the coeffitents was evaluated by construct similar to

Phi:=(|z|>0.0001)*arg(z)

Its a rather clumsy and not elegant, but I have just thrown it into MathCad 2001 and it worked, when you chose "backward compatibility" at the evaluation speed (in contrast to "quick evaluation"). There ist no such switch in newer Mathcad version. Obviously the backward-compatible way was shortcut-evaluating the expression - finding that the first factor is zero (false) it did not even look at the second.

BTW, I was wrong in assuming, that arg(0) itself worked in former MC-Version. At least it fails in V.2001

I know, how to rewrite the function to work flawless using if-funktion or from the prgramming palette, but as I downloaded quite a bunch of sheets from that site with the same or similar failure, I wondered if there is a switch or option to change the behaviour of Mathcad (like it is possible for 0/0) so it would not be necessary to change the sheets.
Seems there is no such option but looking about it for some while I think it should.

sorry for being long winded and thanks for your patience

RM

Ah, the multiply as a conditional. In older versions of Mathcad if the first operand of a multiply operator was zero, the second operand was not evaluated, the result was simply set to zero. This was removed in later versions, as it is actuallyh incorrect -- if the second operand of the multiply is an array, the result with a zero first operand should not be zero but rather an array of all zeros. IAC, such constructs need to be rewritten using if statements or if functions, or perhaps, depending on the usage, the on error construct.

If all uses of arg are of this form, I would simply redefine arg to allow for a zero argument.
__________________
� � � � Tom Gutman

O
>incorrect -- if the second
>operand of the multiply is an
>array, the result with a zero
>first operand should not be
>zero but rather an array of
>all zeros. IAC, such

Yes, now this makes sense for me too - tnx


>If all uses of arg are of this
>form, I would simply redefine
>arg to allow for a zero
>argument.

Correct - as I wrote in my inital posting exactly that was my first workaround

RM

There is a lotlolot of superb Fourier stuff in the collab and as much knowledge base.



jmG
Top Tags