Christopher2222

4960 Reputation

24 Badges

11 years, 141 days

MaplePrimes Activity


These are Posts that have been published by Christopher2222

There was a discussion regarding Maple and two light sources a couple of days ago (unfortunately the content of that conversation has been removed by the original poster so if any of you thought you were getting early signs of alzheimers, rest assured the questions/posts were indeed there and you can all put your memories at ease for a little).

I did indeed go back into Maple to see how far it was that we lost the two light source capability.  I can tell you that as far back as Maple 10.06 dual (or more) light sources was not working.  So I worked my way up - of course the OP of the deleted questions mentioned Maple Vr4 (I think), so I started there.  Maple 6 and Maple 7 is ok.  I was unable to check Maple 8 and 9 as my computers with that software are currently missing (probably buried in my shed somewhere - as long as the wife hasn't got rid of them.. anyways)

So I'll share with you what once was.  From Maple 7, and an animated gif (which hopefully works) to illustrate two light sources (one brown light, and one mauve or purple light) and what it looked like from Maple 7.

with(plots):
setoptions3d(style=patchnogrid,projection=.9):
a:=plot3d(-x^2-y^2-x*y,x=-1..1,y=-1..1,color=[.5,.9,.9],grid=[15,15]):
b:=n->display(a,orientation=[n,60]):
display([seq(b(10*n),n=0..35)],light=[90,-80,1,.2,.1],light=[90,40,1,.5,.8],insequence=true);

The animation is not working so the uploaded gif file is here for you to check out. .. Couldn't upload the gif file so I've zipped it - that worked

twolightsource.zip

I'm only just hearing (haven't experienced) about some serious issues with the 2019.2 updates.  I would recommend waiting for Maplesoft to release an emergency 2019.3 fix update - Maplesoft can NOT leave the last update of 2019 in this state.

macros can be made to work like subs, you just need to know a few tricks to get it to work the same way.  macros just works in a slightly different manner and we can make it useful.

The difference is with subs, one has to keep specifying the substitution with each equation you want subbed, whereas macro will already have it defined.  As an example:

a := v^2*z^3 - 34/(5*x^2*sin(y*v^2)) + 36*v^2 - b*v^2 + 3^(v^2 - cos(v^2 + g))
                            

If we want to substitute h for v^2, then we would normally do this using subs

subs(v^2=h,a)
                          

however, we can also use macro

macro(v^2=h)
                                    

now it doesn't just automatically substitute those values so we need to coax maple a little bit.  We can do that by converting the equation to a string and parsing it.

parse(convert(a,string))
                     

so as you see we arrive at the same result.  Now there is a caveat using macro, if you've already defined a variable in a macro, subs will not work using the same variable sustitution - you first need to reset the variable in the macro back to itself. 

subs(v^2=h,a)
                      #doesn't work since the variable is defined in a macro

macro(v^2=v^2) #reset the variable in the macro

subs(v^2=h,a)
                         # now it works

we could also define a little procedure to simplify our typing, to have the macro variable work on our equation.

mvs:=proc(a) #macro variable substitution
  parse(convert(a,string));
end proc:

macro(v^2=h)
mvs(a)
            

now if we had some other existing equation before defining the macro
aa:=exp(v^2-sin(theta))+v^2*cos(theta)-1/x^sin(v^2-g)
                                   

we just have to simply apply our proc on the equation to apply the variable substitution
mvs(aa)
              


 

 

 

 

Just a simple use of DataFrames.  Looking for a new flashlight, I decided to compile a small selection of flashlights for comparison.
 

interface(rtablesize = 20)

Type := `<,>`(LED, LED, LED, Incandescent, Incandescent)``

BType := `<,>`(AAA, AA, AAA, AA, AAA)

Make := `<,>`(Maglite, Maglite, Maglite, Maglite, Maglite)

Batteries := `<,>`(1, 2, 3, 2, 1)

Lumens := `<,>`(47, 245, 200, 14, 2)

Model := `<,>`(Solitaire, `Pro+`, XL50, mini, Solitaire)

Minutes := `<,>`(105, 135, 405, 315, 225)

Cost := `<,>`(17.49, 41, 46.99, 16.50, 10)

NULL

Note:The values for cost used is in Canadian dollars, and the stores for the prices taken were from the following - MEC, Lowes, Canadian Tire and Amazon.ca

NULL

NULL

NULL

Flashlight := DataFrame(`<|>`(Make, Model, Type, BType, Batteries, Lumens, Minutes, Cost), columns = `<,>`("Make", "Model", "Type", "BType", "Batteries", "Lumens", "Minutes", "Cost"))

_m652460160

(1)

NULL

numelems(Flashlight)

40

(2)

sort(Flashlight, "Cost")

_m653259008

(3)

sort(Flashlight, "Lumens")

_m629071232

(4)

NULL

No surprise that the cheapest and lowest light outputs were incandescent flashlights.  The list isn't very large so lets add a few more flashlights to our list

NULL

new1 := DataFrame(`<,>`(`<|>`(Thrunite, Ti3, LED, AAA, 1, 130, 30, 26.95), `<|>`(Police*Security, Stealth, LED, AA, 1, 80, 60, 7.99), `<|>`(Police*Security, Shield, LED, AA, 1, 120, 90, 15.99), `<|>`(Fenix, E12, LED, AA, 1, 130, 90, 37), `<|>`(Fenix, E20, LED, AA, 2, 265, 30, 50.75), `<|>`(Fenix, E05, LED, AAA, 1, 85, 45, 31.99), `<|>`(Maglite, mini, LED, AAA, 2, 84, 345, 22)), 'columns' = ["Make", "Model", "Type", "BType", "Batteries", "Lumens", "Minutes", "Cost"], 'rows' = [6, 7, 8, 9, 10, 11, 12])

_m624778752

(5)

F1 := Append(Flashlight, new1)

_m647087136

(6)

sort(F1, "Cost")

_m627084608

(7)

F2 := convert(sort(F1, "Cost", `<`), DataFrame)

_m650479744

(8)

Interesting to note that Police Security generally seems to be the cheapest.

 

 

sort(F2, "BType")

_m629097504

(9)

 

 

Adding yet more flashlights

 

new2 := DataFrame(`<,>`(`<|>`(Pelican, 1910*Gen3, LED, AAA, 1, 106, 150, 38), `<|>`(Pelican, 1920*Gen3, LED, AAA, 2, 224, 135, 41)), 'columns' = ["Make", "Model", "Type", "BType", "Batteries", "Lumens", "Minutes", "Cost"], 'rows' = [13, 14])

_m629911872

(10)

F3 := Append(F2, new2)

_m625417184

(11)

sort(F3, "Cost")

_m641386752

(12)

NULL

Now lets select just the Maglite models

 

F3[`~`[`=`](F3[() .. (), "Make"], Maglite)]

_m650462944

(13)

``

Or select the flashlights that have a burn time longer than 100 minutes

 

F3[`~`[`>`](F3[() .. (), "Minutes"], 100)]

_m689998912

(14)

NULL


 

Download flashlight3.mw

Starting the Maple 2019 wishlist.  Anything in particular users would like to see added or upgraded to maple can add it here. 

 

1 2 3 4 5 6 7 Last Page 1 of 36