acer

32333 Reputation

29 Badges

19 years, 325 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Following insertion of a Question you could right-click in an otherwise empty portion of the outermost Table, and adjust its Properties (eg, width-related properties).

If you really want to be able to programatically emit several Quiz questions (in separate Execution Groups), each with exactly the same "width" settings, then you could (per session only!) clobber the internal procedure which constructs them. See attached (including general warnings).

MyQuiz.mw

If you want to build a more complicated version of the Quiz implementation (timer, running score, etc) then with effort you could re-implement its internal procedures and mechanism entirely. They are not overwhelmingly complicated, though portions are wordy and print verbosely. That would require you to read and understand the documentation of the DocumentTools:-Layout and DocumentTools:-Components packages, as well as the internals of the Quiz package.

The title of your Question mentions output, but the body of your question mentions input. It's unclear whether you want both, or just one.

It's possible to write a customized print-extension procedure so that 2D Output contains the function name displayed in upright Roman instead of italics.

But I suspect that it is not possible to get the GUI to insert automatically the upright Roman of gcd as you are typing your 2D Input. I mean in the same way that the display of the typed input sin automatically switches from italic to Roman as one finishes the word.

You choice of example command, gcd, seems unfortunate. That's because it doesn't return unevaluated when it's arguments are unassigned names. Did you hope to cover the case of how its 2D Math output is displayed when calling it within uneval quotes? See below. Another example might be igcd, which can normally return unevaluated for unknown name arguments. See below. (Again, automatic and on-the-fly handling of keyboard-typed 2D Input may be out of reach.)

restart;

kernelopts(version);

`Maple 2018.0, X86 64 LINUX, Mar 9 2018, Build ID 1298750`

'gcd'(a,b);

gcd(a, b)

igcd(a,b);

igcd(a, b)

`print/gcd`:=proc()
   uses T=Typesetting;
   if IsWorksheetInterface("Standard")
    and interface(':-prettyprint')>1 then
       T:-mrow(T:-mo("gcd"),T:-mo("⁡"),
               T:-mfenced(T:-Typeset(T:-EV(_passed))));
   else ':-gcd'(_passed); end if;
end proc:

`print/igcd`:=proc()
   uses T=Typesetting;
   if IsWorksheetInterface("Standard")
    and interface(':-prettyprint')>1 then
       T:-mrow(T:-mo("igcd"),T:-mo("⁡"),
               T:-mfenced(T:-Typeset(T:-EV(_passed))));
   else ':-igcd'(_passed); end if;
end proc:

c := 'gcd'(a,b);

gcd(a, b)

eval(eval(c,1), [a=12,b=9]);

3

d := igcd(a,b);

igcd(a, b)

eval(d, [a=12,b=9]);

3

 

Download roman_igcd.mw

The extra red chevrons (extra prompts), within a single execution-group, do not affect the parsed meaning, AFAIK.

 

 

Do mean you want something like this?

restart:
f := x->sqrt(2*x-1):                                           

ee := (f(x+h)-f(x))/h:                                         

radnormal(1/rationalize(1/ee));

                           2
           ---------------------------------
                    1/2                  1/2
            (2 x - 1)    + (2 x + 2 h - 1)

For this example the outermost operation in the last line above might also be normal instead of radnormal.

add( `if`(`mod`(10,n)=0,a(n),0), n=1..10 );

            a(1) + a(2) + a(5) + a(10)

If you know the identity of the Code-Edit-Region then you should be able to use the SetProperty command from the DocumentTools package.  Eg,

DocumentTools:-SetProperty("CodeEditRegion0",visible,true);

If you don't know its identity then you could example the .mw file as plaintext, or get back to us and a procedure to return candidate strings could be constructed (it'd take me a bit to write it...).

For your example,

restart;

kernelopts(version);

    Maple 2018.0, X86 64 LINUX, Mar 9 2018, Build ID 1298750

Student:-Calculus1:-Roots( 4^x+1 = x^4, x = -10 .. 10, numeric );

            [-1.053567011, 2.094012853, 3.989728952]

remove(type,[solve( 4^x+1 = x^4.0, x )],nonreal);
Warning, solutions may have been lost

            [-1.053567011, 2.094012853, 3.989728952]

sol := solve(4^x+1 = x^4, x):
remove(is,evalf([allvalues(sol)]),nonreal);
Warning, solutions may have been lost

            [-1.053567011, 2.094012853, 3.989728952]

[RealDomain:-solve( 4^x+1 = x^4.0, x )];

            [-1.053567011, 2.094012853, 3.989728952]

Try using the ImageTools:-Scale command to scale down the number of columns.

Make the Matrix datatype=float[8]. Much better for memory performance would be to make the 50x500000 Matrix with the float[8] datatype when first created. Less great, if numeric Matrix M is datatype=anything, would be to create the copy Matrix(M,datatype=float[8]) .

Eg,

restart;

n:=50000:

M:=Matrix(50,n,(i,j)->evalhf(sin(j*5*Pi/n)),datatype=float[8]):

ImageTools:-Scale(M, 1..500, 1..500);

ImageTools:-Scale(M, 1, 1..500);

In the top right of your web browser window your handle/name should appear. It's a link to your profile page.

Your profile contains a section containing all your posted Question/Answers/Replies.

Here is a link to all the Questions you've asked on this site.

I was only able to reproduce your 2D Input problem if I entered the Unit(s) appearing in that denominator by using the Units palette.

But if I used 2D command-completion then it worked ok. When you have the input cursor in that denominator then instead of using the s from the Units palette then instead type it in as follows. First type in Unit and then hit the Escape key, and then a popup menu of choices should appear. Select the top menu item, to enter a unit. That should enter the typeset template for the unit, with a dummy name like u highlighted. Simply type s to replace the dummy name. Then use the right-arrow to move the cursor to the next entry point.

But why not combine all the units in your expression first, to just J? You can do that programmatically, or in this case mentally.

restart

E__n := proc (n) options operator, arrow; (-1)*6.63*Unit('J')*Unit('s')*3*10^8*Unit('m'/'s')*1.097*10^7*Unit(1/'m')/(10^34*n^2) end proc

combine(E__n(4), units)

-0.1363708125e-18*Units:-Unit(J)

(1)

E__n := unapply(combine(-1.097*(6.63*10^(-34)*Unit('J')*Unit('s')*3)*10^8*Unit('m'/'s')*10^7*Unit(1/'m')/n^2, units), n)

proc (n) options operator, arrow; -0.2181933000e-17*Units:-Unit(J)/n^2 end proc

(2)

E__n(4)

-0.1363708125e-18*Units:-Unit(J)

(3)

kernelopts(version)

`Maple 2018.1, X86 64 LINUX, Jun 8 2018, Build ID 1321769`

(4)

``

Download Maple_prob1_ac.mw

How about just the following, if the file name is test.txt.

M := parse~(ImportMatrix("test.txt",delimiter=" "));

You would replace test.txt with the fully qualified file name, according to its actual location on your machine, or first call currentdir( ) appropriately.

restart:

kernelopts(version);

`Maple 2018.0, X86 64 LINUX, Mar 9 2018, Build ID 1298750`

with(Statistics):
N := 3:
X := RandomVariable(Binomial(N, 1/2)):

F := value(CDF(X, s, inert));

F := sum(piecewise(_t < 0, 0, binomial(3, _t)*(1/2)^_t*(1/2)^(3-_t)), _t = 0 .. s)

plot(F, s=-1..N+1,
     gridlines=true, axis[1]=[gridlines=N+1],
     thickness=3);

Download binomialcdf.mw

It wasn't clear to me whether you also needed the terms to be sorted. So I do it with and without, below.

restart;

 

P:=proc(expr, nm)
  local f, i, j, k, L, s;
  s:=`tools/gensym`(nm);
  f:=proc() `tools/genglobal`(s); end proc:
  f(),f();
  L:=PolynomialTools:-CoefficientList(expr,nm):
  add(add(`*`(seq(f(),j=1..i-1)),k=1..L[i]),i=1..nops(L));
end proc:

 

foo := 2*x + 3*x^3;

3*x^3+2*x

ans1 := P(foo, x);

x10*x11*x9+x3*x4*x5+x6*x7*x8+x1+x2

ans2 := P(foo, x);

x10*x11*x9+x3*x4*x5+x6*x7*x8+x1+x2

ans1-ans2;

0

sort( ans1, order=plex(seq(cat(x,i),i=1..nops(indets(ans1,name)))) );

x1+x2+x3*x4*x5+x6*x7*x8+x9*x10*x11

bar := expand(t*randpoly(t, degree=3, coeffs=rand(1..3), dense));

t^4+3*t^3+3*t^2+2*t

new := P(bar, t);

t18*t19*t20*t21+t10*t11*t9+t12*t13*t14+t15*t16*t17+t3*t4+t5*t6+t7*t8+t1+t2

sort( new, order=plex(seq(cat(t,i),i=1..nops(indets(new,name)))) );

t1+t2+t3*t4+t5*t6+t7*t8+t9*t10*t11+t12*t13*t14+t15*t16*t17+t18*t19*t20*t21

 

Download polygen.mw

Was the restriction on a subsequently added to the Question?

restart;

f := sin(x) / ( ( sin(a*x) )^a * ( sin((1-a)*x) )^(1-a) ):

MultiSeries:-limit(f, x=0, left) assuming a>0, a<1;

-1/((-1+a)^(1-a)*(-a)^a)

MultiSeries:-limit(f, x=0, right) assuming a>0, a<1;

1/((1-a)^(1-a)*a^a)

simplify(evala(%-%%)) assuming a>0, a<1;

0

 

Download limitparam.mw

 

You could have a look at this old discussion thread (and the links to yet older discussions, in my Answer there).

First 172 173 174 175 176 177 178 Last Page 174 of 336