acer

32343 Reputation

29 Badges

19 years, 326 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@tomleslie That exact same variant evalc(expr) (followed by wrapping its result in a call to simplify) was part of my prior answer.

I gave it as an alternative to a longer step-by-step approach, under the hypothesized context that the unknown x might be presumed by the OP to be purely real.

So, I agree that it is a straightforward approach. But I'm confused as to your central point, and perhaps I'm missing something. When you write, "It is often simpler", what are you comparing it to?

There is a recursive example (due to Helmut Kahovec) in this old post.

@Kitonum That procedure doesn't account for the case that the entries of the input lists might themselves have operands. In such cases it can produce the wrong result, eg.

restart:

CartProd:=proc(L::list({set,list}))
local n;
n:=nops(L);
if n=1 then return L[1] else
[seq(seq([op(p),l], l=L[n]), p=thisproc(L[1..n-1]))] fi;
end proc:
Warning, (in CartProd) `p` is implicitly declared local
Warning, (in CartProd) `l` is implicitly declared local

LL:=[seq([seq(x[i,j],j=1..3)],i=1..2)];

   LL := [[x[1, 1], x[1, 2], x[1, 3]], [x[2, 1], x[2, 2], x[2, 3]]]

CartProd(LL);

       [[1, 1, x[2, 1]], [1, 1, x[2, 2]], [1, 1, x[2, 3]], 

       [1, 2, x[2, 1]], [1, 2, x[2, 2]], [1, 2, x[2, 3]], 

       [1, 3, x[2, 1]], [1, 3, x[2, 2]], [1, 3, x[2, 3]]]

[edited] Some (but not all) kinds of correction to that procedure might also benefit in performance by memoization such as adding option remember,system, depending on the entries.

@Carl Love I'm away from a computer for a while, but I believe you, and it's interesting. Thanks! (Historically, the trig/arctrig solvers sometimes suffered from producing some extra, spurious, exact results.)

For the OP's goals, I'd mostly still give the same general advice as before, however. (And, as shown, increased working precision is one way in which the issue can be skirted, even without recourse to purely numeric fsolve).

[edit] It looks as if that generic solution involving the unspecified implicit RootOf is only valid (as a solution for JD) for some restricted range of L. But once you hit that generic implicit solution with allvalues the original fomula for JD is no longer part of what's being computed. I'm going to submit a bug report.

@Carl Love Fascinating.

I can get that -- as purely an effect of the GUI's 2D Output with typesetting=extended -- if the procedure has options operator and arrow, and the Pi/2.2 occurs with and. Then the floatPi automatic simplification kicks in at some point in the pretty-printing.

But the procedure itself seems fine.

proc(x) option operator, arrow; Pi/2.2 < x and x < 10; end proc;

proc (x) options operator, arrow; Pi/2.2 < x and x < 10 end proc

lprint(eval(%));

x -> Pi/2.2 < x and x < 10

 

Please stop posting separate and duplicate Question threads for this example.

If you encounter additional syntax problems (2dmath, etc) then please put them in Comments/Replies here, instead of spawning entirely different Question threads.

Perhaps you are trying to obtain the following:

restart

with(plots)

a := 1

1

r := proc (phi, B, theta) options operator, arrow; sqrt(-B^2+(a^2+B^2)*cos(theta)^2)*f(sqrt((-B^2+(a^2+B^2)*cos(theta)^2)/((a^2+B^2)*cos(theta)^2))*(phi-sqrt(a^2+B^2)*cos(theta)*arcsec(a/sqrt(-B^2+(a^2+B^2)*cos(theta)^2))/sqrt(-B^2+(a^2+B^2)*cos(theta)^2))) end proc

proc (phi, B, theta) options operator, arrow; sqrt(-B^2+(a^2+B^2)*cos(theta)^2)*f(sqrt((-B^2+(a^2+B^2)*cos(theta)^2)/((a^2+B^2)*cos(theta)^2))*(phi-sqrt(a^2+B^2)*cos(theta)*arcsec(a/sqrt(-B^2+(a^2+B^2)*cos(theta)^2))/sqrt(-B^2+(a^2+B^2)*cos(theta)^2))) end proc

f := proc (x) options operator, arrow; piecewise((-1)*Pi/2.2 < x and x < Pi/2.2, sec(x), Pi/2.2 < abs(x), sec(Pi/2.2)) end proc

proc (x) options operator, arrow; piecewise((-1)*Pi/2.2 < x and x < Pi/2.2, sec(x), Pi/2.2 < abs(x), sec(Pi/2.2)) end proc

polarplot([r(phi, 0, 0), r(phi, .48, 0), r(phi, 3, 0), r(phi, 4, 0)], phi = -2*Pi .. 0, color = [red, black, green, blue])

NULL

Download maple1.mw

What is the argument that is supposed to be passed to the f operator, inside the definition of the r operator? You have it as merely f, stand-alone. Is that supposed to be f(phi), f(theta), or...?

Also, check for missing multiplication signs. I detected a few.

I am unsure whether the brackets are all placed as you intend.

@quoteswindy0 

In Maple you assign some value to a name using  :=  not just the = symbol.

I deleted it, as a duplicate of the earlier Question's line. I used the particular moderator facility with the drop-menu item labeled "Duplicate".

I had previously politely asked the submitter (twice) to stop posting separate duplicates of the thread, and instead to add any additional details or followups in the earlier thread.

At least one other duplicate of the thread had been previously deleted (and accompanied by the mentioned kind of request).

Please don't repost this in additonal, separate Question threads.

Instead, please put your followup queries and additional details in Replies/Comments in this thread.

Please put your additional details on this problem here, instead of in a separate Question thread.

@lcz The attached worksheet has code in its Startup Region which alters some GraphTheory routines. Hopefull it'll let you pass that stylesheet spec along to the interactive facility, as well as the earlier change to allow a Matrix/Table of interactive graph renderings.

I put it in a conditional to test for Maple 2021 or 2022, as I don't know whether the code edits are valid in other versions. It relies heavily on particular forms of the procedures (though I didn't put in a flag to prevent anyone accidentally rerunning the initial editing process twice).

GTinterstyle.mw

How large (typically) is Matrix A, and how fast do you need it to be?

Does Matrix A have special structure, eg. symmetric (real), etc?

Do you also need to optimize for doing this computation very many times for modest size?

@ijuptilk In versions 18 (and older) of Maple you would have to apply the evalf command to get arithmetic involving Pi and floats to produce a float result by default. Eg,

p[1] := evalf( 38.01/(Pi^2*(1-1.31/Pi)) );

Imagine the time that could be saved if you had bothered to inform us as to your specific old Maple version.

First 110 111 112 113 114 115 116 Last Page 112 of 592