acer

32333 Reputation

29 Badges

19 years, 323 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

Please just add followup point-release notices as Replies to your original Post on this topic, or Branch from the original, rather than submit a wholly separate new Post on it.

A newe Reply/Comment bumps the original to the top of the active feeds, indicating some change to be read.

@salim-barzani 

restart

sol3 := (2*(2*k[2]^2*p[2]^2/p[1]^2+2*k[2]^2))/((-x*k[2]*p[2]/p[1]+y*p[1])^2+(x*k[2]+y*p[2])^2+a[0])-2*(-(2*(-x*k[2]*p[2]/p[1]+y*p[1]))*k[2]*p[2]/p[1]+(2*(x*k[2]+y*p[2]))*k[2])^2/((-x*k[2]*p[2]/p[1]+y*p[1])^2+(x*k[2]+y*p[2])^2+a[0])^2

P :=   [  a[0]=1.2, k[2]=0.8, p[1]=-0.8, p[2]=0.4]:

solnum :=subs(P, sol3);

3.200000000/((.4000000000*x-.8*y)^2+(.8*x+.4*y)^2+1.2)-5.120000000*x^2/((.4000000000*x-.8*y)^2+(.8*x+.4*y)^2+1.2)^2

plots:-contourplot(solnum, x = -5 .. 9, y = -10 .. 10,
                   grid = [151, 151], view=[-5 .. 9, -10 .. 10],
                   contourlabels=false, colorbar = false,
                   labels=[x,y],
                   coloring=["Red","Green"],
                   contours = [-0.25, -0.15, 0.006, 0.035, -0.03, 0.2,
                               0.4, 0.6, 1, 1.25, 1.5, 1.75, 2, 2.25, 2.3, 2.4, 2.5])

plots:-contourplot(solnum, x = -5 .. 9, y = -10 .. 10,
                   grid = [151, 151], view=[-5 .. 9, -10 .. 10],
                   contourlabels=false, colorbar = false,
                   labels=[x,y], filled,
                   filled,
                   contours = [-0.25, -0.15, 0.006, 0.035, -0.03, 0.2,
                               0.4, 0.6, 1, 1.25, 1.5, 1.75, 2, 2.25, 2.3, 2.4, 2.5])

 

 

 

Download graph-density-countour_ac2.mw

You should explain clearly what you are trying to obtain.

Your attempted syntax of,
   map(contour,solnum)
and
  map(density,solnum)
do not make sense.

Are you trying to get 3D or 2D plots?

If 3D, then what exactly do you mean by "density"?

@Andiguys Is it reasonable that delta might be always equal to 1, at the optima?

If the difference in scale between your plots is much greater than the variation within them then they may appear like boring straight lines when plotted together. Would you be ok with a dualaxis plot, in such a case?

What happens if you use Grid:-Map?

@segfault Great, if you have it working.

If the value of Var2 is "b", which is a string, then are you sure you wouldn't rather use %s insted of %a. (see notes above)

Here's a shorter example. The abs(1,k) subterm comes from the earlier diff call, regardless of assumptions. This kind of term forms (only) part of your expression.

temp := BesselK(0, k)*abs(1, k);

BesselK(0, k)*abs(1, k)

T1 := Im(temp);

Im(BesselK(0, k))

T2 := Im(temp) assuming k::real;

signum(k)*Im(BesselK(0, k))

eval([T1,T2], k=-1.0);

[-3.977463261, 3.977463261]


Download question_reim_short.mw

@dharr "Learn from this." should get more votes that I can give.

@mmcdara I see, using union was just an experiment.

It's very handy that the HTML entities begin with ampersand (&), so that they can be used in this way. I showed you `≅`, but as dharr mentioned you can used others, many available from the Palettes. Your choice.

A few more notes, just in case. I'm still not quite sure whether you might have wanted to use T, literally. If so, please see the attached.

note. The infix notation is not a consequence of being a binary operator, and that's true mathematically as well as in Maple. Being a binary operator brings extra conditions to a binary function, eg. same domain for each argument, and (depending on who you read) same codomain. But infix notation is not a requirement. (eg. exponentiation). It just happens that some common algebraic operations have infix notation for operators.

restart;

 

`print/T` := proc(x,y)
   uses Typesetting;
   mrow(Typeset(x), mo("⁢"),
        mo("T",fontweight="bold"), mo("⁢"),
        Typeset(y));
end proc:

 

T(a,b);

T(a, b)

T(sqrt(s),t);

T(s^(1/2), t)


You could also get infix input, if you're ok with resorting to
using the &T infix operator.

alias(T=`&T`):
`print/&T`:=`print/T`:

 

a &T b;

T(a, b)

`&T`(a, b)

T(a, b)

Download infix_note.mw

note: I don't see & neutral operators in use so much any more. Physics has its sophisticated own stuff. Once upon a time, evalm used &* commonly for denoting noncommutative matrix multiplication.

@mmcdara Here are a few notes (my interpretations, right or wrong) on trying to force the harder order of the integrations, with nested 1D methods.

Using Maple 2024.1.


We can force specific methods for nested 1D numeric
integrations. We can experiment with doing that the
with the harder order of the variables.

 

This can be a tricky thing to balance.

note: I've put each block in a single execution group,
with restart. That is because even with,
   forget(evalf); forget(`evalf/int`);
I've sometimes seen "remembered" results that differ
from a clean re-run, which is awkward.

restart;
G := proc(x,y)
  if not ( x::numeric and y::numeric ) then
    return 'procname'(x,y);
  else
    piecewise(y<=1/(1+sinh(2*x)*ln(x)^2), 1);
  end if;
end proc:
CodeTools:-Usage(
  evalf[15](Int(Int(G(x,y), x=0.8..3,
                    epsilon=1e-12, method=_d01ajc),
                y=0..3, epsilon=1e-5, method=_Gquad))
);

memory used=53.43MiB, alloc change=34.00MiB, cpu time=1.68s, real time=1.68s, gc time=15.81ms

.676480297813865

 


If the inner integral cannot always succeed then the
outer integration can fail (sometimes quickly).

restart;
G := proc(x,y)
  if not ( x::numeric and y::numeric ) then
    return 'procname'(x,y);
  else
    piecewise(y<=1/(1+sinh(2*x)*ln(x)^2), 1);
  end if;
end proc:
CodeTools:-Usage(
  evalf[15](Int(Int(G(x,y), x=0.8..3,
                    epsilon=1e-13, method=_d01ajc),
                y=0..3, epsilon=1e-5, method=_Gquad))
);

memory used=2.47MiB, alloc change=0 bytes, cpu time=35.00ms, real time=35.00ms, gc time=0ns

Int(Int(G(x, y), x = .8 .. 3.), y = 0. .. 3.)


If the outer integration's accuracy request is tighter, it
may succeed, but more slowly.

restart;
G := proc(x,y)
  if not ( x::numeric and y::numeric ) then
    return 'procname'(x,y);
  else
    piecewise(y<=1/(1+sinh(2*x)*ln(x)^2), 1);
  end if;
end proc:
CodeTools:-Usage(
  evalf[15](Int(Int(G(x,y), x=0.8..3,
                    epsilon=1e-12, method=_d01ajc),
                y=0..3, epsilon=1e-6, method=_Gquad))
);

memory used=188.99MiB, alloc change=36.00MiB, cpu time=5.62s, real time=5.62s, gc time=70.51ms

.676479990641045


If the outer integration's accuracy request is too tight, it
may fail, since the inner integral is not (relatively)
accurate enough.

restart;
G := proc(x,y)
  if not ( x::numeric and y::numeric ) then
    return 'procname'(x,y);
  else
    piecewise(y<=1/(1+sinh(2*x)*ln(x)^2), 1);
  end if;
end proc:
CodeTools:-Usage(
  evalf[15](Int(Int(G(x,y), x=0.8..3,
                    epsilon=1e-12, method=_d01ajc),
                y=0..3, epsilon=1e-8, method=_Gquad))
);

memory used=188.57MiB, alloc change=36.00MiB, cpu time=5.61s, real time=5.62s, gc time=71.51ms

Int(Int(G(x, y), x = .8 .. 3.), y = 0. .. 3.)


In my previous Answer I suggested using a bare piecewise instead
of a black-box (a proc that returns unevaluated for nonnumeric
x and y).

I suggested that only because I prefer to start off simply. But
in practice I find that I often move to a black-box to enforce
control of what `evalf/int` does internally.

Here we see that the first example above (success in 1.67 sec)
takes longer without the black-box veil, though here it happens
to get the very same result.

restart;
G := piecewise(y<=1/(1+sinh(2*x)*ln(x)^2), 1);
CodeTools:-Usage(
  evalf[15](Int(Int(G, x=0.8..3,
                    epsilon=1e-12, method=_d01ajc),
                y=0..3, epsilon=1e-5, method=_Gquad))
);

G := piecewise(y <= 1/(1+sinh(2*x)*ln(x)^2), 1, 0)

memory used=1.15GiB, alloc change=138.00MiB, cpu time=15.99s, real time=15.28s, gc time=1.25s

.676480297813865

 

 

Download integration_issue_ac3.mw

Changing the order of the bounds (ie. which is the "inner" integral) makes a huge difference here.  The other order took so long I interrupted it.

restart;

CodeTools:-Usage(
  evalf(Int(piecewise(y<=1/(1+sinh(2*x)*ln(x)^2), 1),
            [ y=0..3, x=0.8..3 ]))
);

memory used=217.60MiB, alloc change=132.00MiB, cpu time=2.67s, real time=2.59s, gc time=242.09ms

.6768400757


Download Integration_issue_ac2.mw

@Ditteon That first link is just to a youtube page. You don't need any Maplesoft login to watch it.

My Chrome browser lets me watch it without signing in to Google.

Is there a special reason for not using a bare piecewise?

restart;

C := piecewise(x>=0 and x<=1, 1, 0);

C := piecewise(0 <= x and x <= 1, 1, 0)

int(C, x=-1..2);

1

plot(C, x=-1..2, adaptive=true,
     thickness=3, size=[400,200]);

Download charfcn_plot_pw.mw

So that we can compare and double check suggestions, what version of Maple are you using?

Also, how many correct decimal digits do you need in the answer?

@segfault You should provide the actual example.

First 16 17 18 19 20 21 22 Last Page 18 of 591