acer

32328 Reputation

29 Badges

19 years, 317 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@tomleslie It wasn't clear (to me, at least) whether the answer is supposed to be in terms of units A^2 or A^2*s. Perhaps the target answer was supposed to be obvious?!

@mmcdara The padding value is in pixels, afaik. (Well, pixels in the usual sense, ie. at 100% zoom. Let's not get into dot-pitch.)

The example mostly works for me in my Maple 2020 GUI. Some things work imperfectly when rendered by this site's considerably older backend engine.

@zphaze You showed two attempts.

The first doesn't make sense to me.

The primary problem with the second is the integrand itself, which as written is already problematic in the Units:-Standard framework, even outside of the int call. The Units:-Simple subpackage was designed with one of its principal themes being to allow that kind of tacit dimension for an unassigned name such as the t in your second example's integrand.

If you don't want the strictures of the Units:-Standard package then don't load it.

You can call it whatever you want.

After normalizing to 0..1 (and prior to scaling), you could subtract from 1.
 

restart;

P1:=plots:-fieldplot([1, y^2 + x], x = -10 .. 10, y = -6 .. 6,
                 fieldstrength = fixed,
                 color = COLOR(HSV, 0.5*sqrt(((y^2+x)^2+1)/((6^2+10)^2+1)),
                                    1.0, 1.0)):

P2:=plots:-fieldplot([1, y^2 + x], x = -10 .. 10, y = -6 .. 6,
                 fieldstrength = fixed,
                 color = COLOR(HSV, 0.5*(1-sqrt(((y^2+x)^2+1)/((6^2+10)^2+1))),
                                    1.0, 1.0)):

plots:-display(Array([P2,P1]),size=[400,400]);

 

 

 

 

 

Download color_formula_rev.mw

@mmcdara I like your Answer (and Tom's, too). I especially like the rowspan use.

For fun, here I get black 2D Input, with numeric formatting of the last column, and alternating background color varying with the k sequence index.

(I don't know why this one doesn't render as nicely as yours on Mapleprimes. It does look much better in the Maple GUI. Was yours a screenshot?)

restart:

with(DocumentTools:-Layout):

f := (x, t) -> x*t:
g := (x, t) -> x^2*t:

val := [seq(i,i=0.125..0.875,0.25)]:
n     := numelems(val):
val_x := [seq(op(val[[k$n]]), k=1..n)]:
val_t := op~([val$n]):
val_f := f~(val_x, val_t):
val_g := g~(val_x, val_t):
res  := convert([val_t, val_f, val_g], Matrix)^+:

res[..,3] := map(p->nprintf(`#mn(\"%1.4e\");`,p),res[..,3]):

cols := Vector[row](4, ["x", "t", "f(x, t)", "g(x, t)"]):

TDI := style=TwoDimInput: FC := fillcolor=piecewise(irem(k,2)=0,"#eeeeff","#eeffee"):
W := Table(seq(Column(), j=1..n), widthmode=pixels, width=500, alignment=center,
           Row( seq( Cell(cols[j], fillcolor="LightGray"), j=1..4) ),
           seq(op([Row(Cell( Textfield(Equation(val[k], TDI)), FC, rowspan=4, padding=50),
                       seq(Cell( Textfield(Equation(res[1+n*(k-1), j], TDI)), FC ),
                           j=1..3)),
                   seq(Row(seq(Cell( Textfield(Equation(res[i, j], TDI)), FC ),
                               j=1..3)),
                       i=2+n*(k-1)..n+n*(k-1))]),
               k=1..n)):
DocumentTools:-InsertContent(Worksheet(Group(W))):

 

x

t

f(x, t)

g(x, t)

.125

.125

0.15625e-1

`#mn("1.9531e-03")`

.375

0.46875e-1

`#mn("5.8594e-03")`

.625

0.78125e-1

`#mn("9.7656e-03")`

.875

.109375

`#mn("1.3672e-02")`

.375

.125

0.46875e-1

`#mn("1.7578e-02")`

.375

.140625

`#mn("5.2734e-02")`

.625

.234375

`#mn("8.7891e-02")`

.875

.328125

`#mn("1.2305e-01")`

.625

.125

0.78125e-1

`#mn("4.8828e-02")`

.375

.234375

`#mn("1.4648e-01")`

.625

.390625

`#mn("2.4414e-01")`

.875

.546875

`#mn("3.4180e-01")`

.875

.125

.109375

`#mn("9.5703e-02")`

.375

.328125

`#mn("2.8711e-01")`

.625

.546875

`#mn("4.7852e-01")`

.875

.765625

`#mn("6.6992e-01")`

 

 

 

Layout_1_ac.mw

@mmcdara If you are using Maple 2015, or if the OP is using Maple 17, then it is significantly faster to do it like so:

restart;

kernelopts(version);

`Maple 17.02, X86 64 LINUX, Sep 5 2013, Build ID 872941`

dsys:={diff(n(t),t)=-2*(n(t)-N)+(u(t)-abs(M)*exp(I*phi))*exp(-2*I*omegap*t/lambda)+conjugate((u(t)-abs(M)*exp(I*phi))*exp(-2*I*omegap*t/lambda)),diff(u(t),t)=-2*(1-I*delta)*u(t)+2*(n(t)-N)*exp(-2*I*omegap*t/lambda)+2*abs(M)*exp(I*phi)}:

dsys := dsys union {n(0)=0,u(0)=0}:
undefined_quantities := indets(dsys, name):
params := convert(undefined_quantities minus {t}, list)

Warning, inserted missing semicolon at end of statement

[M, N, delta, lambda, omegap, phi]

res1 := dsolve(dsys union {n(0)=0,u(0)=0}, numeric, parameters=params);

"res1:=proc(x_rkf45) ... end proc"

# example: the moving param is M
f := proc(s, m)
  local data:
  if rhs(res1(parameters)[1])<>m then
    data := params=~[m, 1, 1, 1, 1, 1]:
    res1(parameters=data):
  end if;
  eval(Re(n(t)), res1(s))
end proc:

CodeTools:-Usage( plot3d('f(s, m)', m=1..2, s=0..1, labels=['M', s, 'n(t)']) );

memory used=331.55MiB, alloc change=36.00MiB, cpu time=2.71s, real time=2.72s

 

Download Try_This_2_ac.mw 

In older versions there is (unnecessary, unwanted) wiping of cached information that occurs even when the parameters are set to their same, extant values. This causes considerable inefficiency, that can be avoid by the simple check that I show here. I believe that inefficiency is fixed in recent versions.

@ahmeng From my Maple 2017.2 for 64bit Linux,

restart;

kernelopts(version);

`Maple 2017.2, X86 64 LINUX, Jul 19 2017, Build ID 1247392`

f := x->18*log10(x):
g := x->1/2*x^3-8*x^2+69/2*x-27:

# This use of maxsols is not documented for univariate
# non-polynomial case, but it works for me regardless.
#
[fsolve(f-g, 0..12, maxsols=5)];

[0.3721465484e-1, 1.000000000, 4.506164928, 10.00000000]

# First call to this below is not fast.
# Duplicating the call is fast (but only due to some
# internal remembering of results).
#
CodeTools:-Usage( sort(remove(type,[solve(f(x)-1.0*g(x))], nonreal)) );

memory used=395.22MiB, alloc change=6.01MiB, cpu time=10.52s, real time=10.52s, gc time=435.14ms

[0.3721465485e-1, 1., 4.506164928, 10.00000000]

 

Download isect.mw

When solve detects the explicit float coefficiant that I introduced into the example it tries to resolve the ensuing approximate RootOfs (via evalf, etc). So it's similar to evalf after allvalues. For me it is not fast on first attempt (and being fast upon repeats means nothing here -- it just remembers some results internally).

The maxsols for fsolve (univariate non-polynomial) usage can be traced through to a iterated use of Rootfinding:-Nextzero, which is yet another approach that one could do up manually.
   showstat(fsolve::scalarmultiple)
It is true that the maxsols option is not documented for the univariate nonpolynomial case. But it is documented for the univariate polynomial case. Your screenshot doesn't show even that, though, since it seems you are citing ?fsolve and not ?fsolve,details .

In your example, L is a table and not a list.

I changed this comment from another thread into its own Question. The subject matter is quite different.

Your Question lacks detail and clarity.

Your Matrix B has 22 rows and 4 columns.

What do you hope to get, when you write terms such as  B[1..1,[17, 18]] ? Do you understand that refers to the (nonexistent) 17th and 18th column entries of the first row?

What parts of B are you trying to plot?

How should we "correct" your code when you didn't tell us anything about what you wanted it to do?!

@dharr I adjusted your Answer slightly, and inlined images (right-click exporting the plots) so that it would be certain that Mapleprime's own rendering wasn't interfering.  I hope that's OK.

@nm You have G as  x*sin(Pi*x)  instead of  x*sin(Pi*y) .

But even if your second result were to attain, it has x restricted to integers and hence not free.

@dondomingo But you won't know home many solutions there are and how many names to use, in general. I don't think that is a good methodology.

I agree, nobody wants to have to re-type or copy&paste from output. It's not good programming to have to do so.

Just assign the full list of solutions to a single name, let's call it Sol, say.

Then you can get at the first solution by indexing, as Sol[1]. And then you evaluate any formula involving x and y using 2-argument eval (as showed in my Answer above). You could even access just the simplest formula x, or y.

Eg,
   eval( x, Sol[1] );
   eval( y, Sol[1] );
   nops(Sol);    # how many solutions there are
   eval(  x^2+sin(y-x),  Sol[3] );
etc.

@alijp I don't understand why you didn't show that when you initially asked the Question.

Now you've introduced the `i` parameter when you already had two (r and phi). So you don't need `i`, now.

Is your problem with the differentiation at symbolic order n?

(I have marked your Question as being for Maple 17.)

I could point out that a function might by undefined on an interval between discontinuities (including a pair returned by discont). And iscont could return true for the test on that open interval. This might matter to you.

First 146 147 148 149 150 151 152 Last Page 148 of 591