acer

32363 Reputation

29 Badges

19 years, 333 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

@Mac Dude There is a hidden character at the start of your .tst data file.

It looks like <feff> inside my vi editor in binary mode. It is also known as a "Byte Order Mark" (BOM), or "Zero Width No Break Space"  See here

It I get rid of that, and assign the ImportMatrix result to the name `data`, and add in your AddProperty, then all seems to go well.

restart;

#interface(rtablesize=30):

data :=ImportMatrix(cat(kernelopts(homedir),"/mapleprimes/","Radiation_Length_Table_ac.txt")):

test:=data[1][1]:

ScientificConstants:-AddProperty(radiationlength);

ScientificConstants:-ModifyElement(convert(test,'name'),radiationlength=[value=data[1,4],units=g/cm^2]);

ScientificConstants:-GetElement(H);

 

1, symbol = H, name = hydrogen, names = {hydrogen}, ionizationenergy = [value = 13.5984, uncertainty = undefined, units = eV], meltingpoint = [value = 13.81, uncertainty = undefined, units = K], density = [value = proc () option `Copyright (c) 2002 Waterloo Maple Inc. All rights reserved.`; if nargs = 0 then error "element is a gas, access ideal density with parameter 'gas'" elif args[1] = 'gas' then 0.88e-1 else error "incorrect parameters" end if end proc, uncertainty = undefined, units = kg/L], electronegativity = [value = 2.1, uncertainty = undefined, units = 1], boilingpoint = [value = 20.28, uncertainty = undefined, units = K], electronaffinity = [value = proc () option `Copyright (c) 2002 Waterloo Maple Inc. All rights reserved.`; error "access isotopic property electronaffinityisotopic of H[1] and H[2]" end proc, uncertainty = undefined, units = 1], atomicweight = [value = 1.00794, uncertainty = 0.7e-4, units = amu], radiationlength = [value = 63.04, uncertainty = undefined, units = g/cm^2]

(1)

restart;

#interface(rtablesize=30):

data :=ImportMatrix(cat(kernelopts(homedir),"/mapleprimes/","Radiation_Length_Table_ac.txt")):

test:=data[1][1]:

ScientificConstants:-AddProperty(radiationlength);

ScientificConstants:-ModifyElement(parse(test),radiationlength=[value=data[1,4],units=g/cm^2]);

ScientificConstants:-GetElement(H);

1, symbol = H, name = hydrogen, names = {hydrogen}, ionizationenergy = [value = 13.5984, uncertainty = undefined, units = eV], meltingpoint = [value = 13.81, uncertainty = undefined, units = K], density = [value = proc () option `Copyright (c) 2002 Waterloo Maple Inc. All rights reserved.`; if nargs = 0 then error "element is a gas, access ideal density with parameter 'gas'" elif args[1] = 'gas' then 0.88e-1 else error "incorrect parameters" end if end proc, uncertainty = undefined, units = kg/L], electronegativity = [value = 2.1, uncertainty = undefined, units = 1], boilingpoint = [value = 20.28, uncertainty = undefined, units = K], electronaffinity = [value = proc () option `Copyright (c) 2002 Waterloo Maple Inc. All rights reserved.`; error "access isotopic property electronaffinityisotopic of H[1] and H[2]" end proc, uncertainty = undefined, units = 1], atomicweight = [value = 1.00794, uncertainty = 0.7e-4, units = amu], radiationlength = [value = 63.04, uncertainty = undefined, units = g/cm^2]

(2)

 

Download ModifyElementMWE_ac.mw

ps. If data is a Matrix then accessing entries with the syntax like data[1][1] is less efficient that accessing it like data[1,1].  The former creates a temporary Vector unncessarily. If you do it many times then you might see an impact on performance.

 

First, let's consider the case of having all output for "Maple Output" be left-aligned, automatically.

The alignment doesn't seem to show up as an editable property when doing the main menubar choice:  Format->Styles...->(select "Maple Output" from list) Modify.  But it's still possible to modify all "Layout" properties of the "Maple Output" style in an otherwise empty .mw file, using a text editor. Such a file could be saved somewhere out-of-the-way, and even marked as read-only in your OS if you'd like. Here is such a template file: outputleft.mw

That template file can then be used as a new default template, following either of these mechanisms:

  • menubar choice Format->Manage Style Sets->User-defined Style Set (choose that same new file as the template).  This can make all output, in all new worksheets, be left-aligned by default. You might find this too heavy-handed, as it makes it awkward to open a new sheet without the custom style.
  • menubar choice Tools->Options->Interface->"Open worksheet at startup:" and in the combo-box select "Specified worksheet:", and then set it to that template file. Then close with "Apply Globally". Doing this sets the template that will be opened whenever the "open the start page" icon (looks like a house) is chosen from the menubar.

Now let's consider the case of making only some 2D Math output be left aligned. That's trickier.

You cannot get typeset 2D Math displayed using the printf command (which left-aligns), since that line-prints.

The attached worksheet (which won't inline properly here on Mapleprimes) contains some ideas for programmatically displaying some expressions as if it were left-aligned 2D output.  left_tools.mw

You can find the degree symbol in the Common Symbols palette.

You can also insert it, or conjoin it to some other name, programmatically. Here are a few ways, which look better in actual Maple but might not all render properly when inlined here on Mapleprimes.

restart;

kernelopts(version);

`Maple 2015.2, X86 64 LINUX, Dec 20 2015, Build ID 1097895`

deg := `&deg;`;

`&deg;`

N := 45;

45

N^deg;

45^`&deg;`

N*deg;

45*`&deg;`

cat(convert(N,name),deg);

`45&deg;`

cat(`result of number in degrees: `, N, deg);

`result of number in degrees: 45&deg;`

convert(%, string);

"result of number in degrees: 45&deg;"

sprintf("result of number in degrees: %s", cat(convert(N,name),deg));

"result of number in degrees: 45&deg;"

sprintf("result of number in degrees: %a%s", N, deg );

"result of number in degrees: 45&deg;"

 

Download degsymb.mw

Your code for assuming something 'real' is incorrect.

It should be lambda::'real' and not lambda='real' , within the context of assume (or assuming).

I'll mention that you don't generally need to assume that lambda is 'real' if you're going to additionally assume that it's less than zero. But you have also messed up the syntax for assuming mu as 'real', and omitted any 'real' assumption on nu.

If you are having trouble exporting a densityplot to Postscript then you could also try a thick line.

In Maple 2018 you can use that same colorscheme option.

restart;
(grad_min, grad_max) := 0.0, 2.7:

P:=plot([0.1, t, t=grad_min..grad_max],thickness=70,
     numpoints=2,adaptive=false,
     colorscheme=["zgradient", ["Red","Blue"]],
     view=[0.06..0.12,default],size=[100,400],axis[1]=[tickmarks=[]]):

plotsetup(cps,
          plotoutput = cat(kernelopts(homedir),kernelopts(dirsep),"eps_2.ps"),
          plotoptions = `portrait, noborder, width=100, height=400`);
print(P);
plotsetup(default);

The above I did on Maple 2018.0 on 64bit Linux. You might have to fiddle a little with the width and centering.

Results seem best when the number of y-points is very low, ie. two. Otherwise faint horizontal light lines appear as artefacts in the Postscript image.

It's possible that this also relates to your line artefacts in the Postscript export of the densityplot. So, you might also try the densityplot but with the addtional grid=[2,3] option.

[edited] ...and with axes=boxed

(grad_min, grad_max) := 0.0, 2.7:
P:=plot([0.1, t, t=grad_min..grad_max],thickness=46,
     numpoints=2,adaptive=false,
     colorscheme=["zgradient", ["Red","Blue"]],
     view=[0.06..0.14,default],size=[100,400],
     axes=boxed,axis[1]=[tickmarks=[]]);

BTW, what is your rationale for choosing .eps export over other graphic formats? I don't see that .eps export of such a 2D surface is going to give you higher resolution (or better fidelity) than all other formats.

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("&ApplyFunction;"),
               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("&ApplyFunction;"),
               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

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