acer

32313 Reputation

29 Badges

19 years, 315 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

Presumably you intend,
    root_r <> 0
instead of,
    root_r != 0
in the 1D Maple Notation plaintext code that you provided.

The code originally provided runs without error. But after this (reasonable) edit the code runs amok.

@tomleslie Yes, and I had previously added a zip alternative as a postscript to my Answer.

Please show us your problematic code. It could be inlined as text, or a link that you upload and attach to your Question (or a Reply/Comment to it) using the green up-arrow in the Mapleprimes editor.

@janhardo If you want the direct input treated specially then you'll have to enter it in some special manner.

If you enter it as input in the usual manner then the bracketing is no longer present and recoverable once parsing is done to get an expression.

I have shown you a few possible special manners in which to input the expression. There are other possible syntax choices, including variants of those shown.

@mmcdara Numeric rootfinding -- like much other numeric computation -- involves a balance between functionality, robustness, and speed/memory performance.

Very often there is a give-and-take amongst these qualities, when comparing approaches. Ease of use (versus, say, the need to adjust options) is a related consideration.

Even for a restricted class of problem there will usually be some approach that is faster, and some which is more robust.

Even for the restricted class of problem of finding all real roots of a univariate polynomial this dichotomy arises. (Eg. some examples may be more ill-conditioned. Etc. High accuracy goals mixes in  too.)

The given problem class in this posting is more restricted still. You might find yet more specialized approaches. 

The fsolve command leans toward robustness and ease of use. In my experience NextZero leans toward speed. Comparing them sensibly should involve tightly specifying the problem class and goals.

By default fsolve will compute all the real roots of a univariate polynomial, in a single call.

Calling allvalues of a forced RootOf wastes time. At higher working precision it can also allow (very small) imaginary artefacts to appear unnecessarily in the result.

One can simply compute like,

    fsolve(simplify(ChebyshevT(N, x)))

and get pretty good efficiency (including at higher working precision) without unnecessary imaginary artefacts (at higher working precision).

I'll point out that the OP's mentioned target expression,

   I*ln((-I*z+b)/(I*z+b))

is not equal to his mentioned input expression,

   I*(ln(-I*z+b)-ln(I*z+b))

for all z and b. That's is what member vv has demonstrated, by example.

My point is that it's not the case that combine(...,symbolic) is misbehaving. The difference primarily lies in the fact that the two expressions (input, and target) mentioned by the OP are not equal everywhere. The demonstrated difference (for some b and z) is inherent to the expressions themselves.

There are various ways to force the combining of the ln terms in the original expression, ignoring branch distinctions. If you perform manipulations involving ln(... exp(something) ...) or combine(expr,symbolic) then be aware of possible consequences.

I'm stating all this primarily for the benefit of the OP.

@C_R If you really wanted you could pass additional options to g, so that those were passed on to the Int call.

An option to force the specific (coarser) rounding may be part of that. (Additional cruft digits may actually be detrimental here.)

For what it might be worth to you,

expr := I*( ln(-z*I + b) - ln(z*I + b) );

I*(ln(-I*z+b)-ln(I*z+b))

I*log(simplify(expand(exp(expr/I))));

I*ln((-I*z+b)/(I*z+b))

Download comb_ln_alt.mw

By the way, if you want to spawn off a related conversation you could use the "Branch" button, instead of starting a wholly distint thread. That automatically inserts URL links between parent and child threads, which helps keep the related content easily accessible. The "Branch" button appears at the bottom of an item, eg. next to the Reply Button.

@janhardo Without extras,

expr := I*( ln(-z*I + b) - ln(z*I + b) );

I*(ln(-I*z+b)-ln(I*z+b))

combine(expr, symbolic);

I*ln((-I*z+b)/(I*z+b))

Download combine_symbolic_ex.mw

Why is it not direct enough for you?

You might be confusing that terse approach with additional explanation, manipulation (or leading sign, etc...), and a slightly different starting expression, as shown above.

By the way, in the Reply above you have a typo, so that the expression doesn't agree with your target reformulation. You claim that you want,
    I*ln ((-z*I + b)/(z*I + b))
but you start with,
    I*ln(-z*I + b) - ln(z*I + b)
That's a typo on your part. Presumably you intended to write,
   I*(ln(-z*I + b) - ln(z*I + b))

@janhardo You could also attempt numerical validation.

You could do that for a specific pair of values for b and z.

Or you could plot it, testing many values of b and z.

The following computes for many (here, purely real) values of both b and z. It has some numeric roundoff error but the difference is clearly very nearly zero. That means that there's no sign difference (which concerned you). Of course the value b=0 is problematic, but we already knew that.

plot3d([Re,Im](arctan(z/b)/b-ans),b=-4..4,z=-4..4,
       color=[red,blue],grid=[100,100],view=-1e-14..1e-14);

@Carl Love A starting point...

@Ronan We saw that you might now be using that as a Start Page.

I suppose that you could also (right-click) toggle off that Table's borders, just prior to exporting.

@janhardo Your call diff(%) is invalid syntax, and makes no sense. You've forgotten to tell Maple the name with which to differentiate.

Perhaps you meant to differentiate with respect to x.

simplify(exp(x*alpha)*cos(x*beta)*alpha/(alpha^2 + beta^2)
         + exp(x*alpha)*sin(x*beta)*beta/(alpha^2 + beta^2));

diff(%, x);

simplify(%);

@Christopher2222 Yes, there have been several postings over the years in which it's been shown that `simplify` does not try all (speculative) flavours of calls to `collect` and so can miss the most compact forms.

That is now quite well "known".

There is a balance between power and time, in simplification. Of course it's easy to say that some trivial example (like this one) ought to be handled. But one of the problems is in drawing a line in the sand, because some examples get slowed down tremendously while others are easy. Where a line is drawn will always be unsatisfactory to some people.

The subtleties here are more than most people realize. To make effective progress requires a huge collection of examples, to guard against severe behavioral regression.

However, `collect` is tangential here since it's already been mentioned that internally `simplify` actually produces the desired, partially factored forms under discussion. The central issue seems to be why its not always returned.

First 116 117 118 119 120 121 122 Last Page 118 of 591