## Random numbers

by: Maple

Erik Postma from Maplesoft has recently posted a Maple application going through some of the ways how to produce random numbers in Maple: http://www.maplesoft.com/applications/view.aspx?SID=153662&P=TC-4444

Doing a fair bit of work involving random numbers (i.e. simulations) myself, I was naturally drawn to it. The document is a nice extension of the relevant help pages, making practical use of some of the procs in RandomTools easier and clearer.

One particular issue I recently ran into, however, is not covered. I needed a random generator for a particular custom pdf (not one of the already recognized pdfs) that happens to be 3-dimensional. And I needed to do this >twice<, with the second generation using the result of the first one as a parameter. the problem is not unlike the last example in the help page for Statistics:-Sample.

Here is what I did:

The pdf looks graphically like this (and note that in this plot it is not normalized):

plot3d(Triangle63:-Trianglef(CrystalAngle,DeflectionAngle),\
CrystalAngle=-0.8..0.2,DeflectionAngle=-0.6..0.6,projection=0.7);

The first set of random numbers is generated by setting CrystalAngle to a fixed number (-0.1 in this case), normalizing the pdf to the integral over DeflectionAngle and then generating the random numbers. Note that evaluation of the integral is relatively time-consuming (seconds).

trianglepdf:=(CrystalAngle,DeflectionAngle) ->\
Triangle63:-Trianglef(CrystalAngle,DeflectionAngle)/\
'evalf(Int(Triangle63:-Trianglef(CrystalAngle,Da),Da=-0.6..0.6,method = _d01akc))':
triangle0pdf:=(t) -> trianglepdf(-0.1,t):
Cr1:=Distribution(PDF=triangle0pdf);
Y:=RandomVariable(Cr1);

samples:=Sample(Y,[1..600],method=[envelope,range=-0.6..0.6]);

This looks as it should; and the random number generation is reasonably fast once the initial setup has been done (i.e. the time used scales only relatively weakly with the count of random numbers generated.

The issue now is the second stage, where for each new random number, the number generated above is a new input parameter for CrystalAngle. So I can no longer define the pdf once since the pdf is different for each number generated.

The pedestrian way to do this is like the following:

samples2:=Vector(1..numelems(samples),datatype=float):
CrystalOffset:=0.3;

for ii from 1 to numelems(samples) do
triangleiipdf:=(t) -> (trianglepdf(samples[ii]-~CrystalOffset,t)); # subtract (VR peak -> 0)
Crii:=Distribution(PDF=triangleiipdf);
samples2[ii]:=evalf(Sample(RandomVariable(Crii),1,method=[envelope,range=-0.6..0.6])[1]+CrystalOffset);
end do:

This works, but only sort-of. First, it is very slow, since the whole sertup happens for each number generated (Sample()). Secondly, it tends to hang at a certain number of steps through the loop. The value of ii where it hangs is arbitrary and changes with the other parameters and CrystalOffset. It is however consistent for identical runs.

The last example in help for Statistics:-Sample would indicate that one needs to setup the pdf as a function of t as well as the parameter, call Distribution() only once and then assign the value to the parameter and call Sample() to get the random number(s) drawn from the pdf with the parameter being set to the wanted value. While this works in the example which uses a built-in pdf, I find that I cannot make it work with my pdf. Either the parameter gets ignored (i.e. stuck at the first value) or the thing runs just as slowly as my procedure above.

Ultimately I programmed my own random generator for an arbitrary pdf which, while not as efficient as Maple's built-in generator, does produce the expected set of random numbers for the 2nd path in a reasonable time. It is a simple-minded envelope-rejection method, that works fo reasonably well-behaved pdfs:

Rarbit:=proc(pdf,xmin,xmax,pdfmax)
local dx:=xmax-xmin;
local x1,x2;
x1:=RandomTools[MersenneTwister]:-GenerateFloat64()*dx+xmin; # pick location on x axis
x2:=RandomTools[MersenneTwister]:-GenerateFloat64()*pdfmax; # y axis, probability of returning x1

while (x2>evalf(pdf(x1))) do # if above pdf, reject
x1:=RandomTools[MersenneTwister]:-GenerateFloat64()*dx+xmin; # new x-axis value
x2:=RandomTools[MersenneTwister]:-GenerateFloat64()*pdfmax; # check value
end do; # eventually we'll succeed and return one.

x1;
end proc;

Using this routine I get my second and final set of randome:

for ii from 1 to numelems(samples) do
newpdf:=(DefAng) -> Triangle63:-Trianglef(samples[ii]-CrystalOffset,DefAng);
samples2[ii]:=Random:-Rarbit(newpdf,-0.6,0.6,28);
DocumentTools:-SetProperty(ProgressBar,'value',ii,refresh);
end do:
CrystalOffset := 0.3
Histogram(samples2+~samples,view=[-0.6..0.6,default]);

I would be interested in Erik's comment on this.

Mac Dude

## Maple T.A. course materials – Introductory Mathema...

by:

Several Maple T.A. users have developed comprehensive sets of question content and assignments to support full courses in Maple T.A. These questions are available through the Maple T.A. Cloud, and we have decided to also post the associated course modules on Maple Primes as an alternative way of accessing this content.

Below you will find a link to the Introductory Mathematical Economics Maple T.A.. course module developed by the University of Guelph.

This testing content is freely distributed, and can be used in your own Maple T.A. tests either as-is, or with edits.

The Introductory Mathematical Economics course module is designed to cover a single-semester course in mathematical economics for economics and commerce students at the second-year university level. The questions are designed to span the topics listed below, allowing for practice, homework or testing throughout the semester.

Topics include:

• Rules of Differentiation
• First Order Differential Equations
• Higher Order Derivatives
• Optimization in One Variable
• Second Order Conditions for Optimization
• Systems of Linear Equations
• Optimization with Direct Restrictions on Variables
• Over Determined and Under Determined Systems
• Matrix Representation of Systems
• Gauss Jordan
• Matrix Operations
• Types of Matrices
• Determinants and Inverses
• Partial Differentiation
• Second Order Partial Derivatives
• Multivariate Optimization
• Second Order Conditions for Multivariate Optimization
• Multivariate Optimization with Direct Restrictions of Variables
• Constrained Optimization and the Lagrangean Method
• Second Order Conditions for Constrained Optimization

Jonny Zivku
Maplesoft Product Manager, Maple T.A.

## Maple T.A. course materials – Introductory Electricity...

by:

Several Maple T.A. users have developed comprehensive sets of question content and assignments to support full courses in Maple T.A. These questions are available through the Maple T.A. Cloud, and we have decided to also post the associated course modules on Maple Primes as an alternative way of accessing this content.

Below you will find a link to the Introductory Electricity & Magnetism Maple T.A.. course module developed by the University of Guelph.

This testing content is freely distributed, and can be used in your own Maple T.A. tests either as-is, or with edits.

The Introductory Electricity & Magnetism course module is designed to cover a single-semester course in electricity and magnetism for physical sciences students at the first-year university level. The questions are designed to span the topics listed below, allowing for practice, homework or testing throughout the semester. Using the Maple engine that is part of Maple TA, a custom grading engine has been developed to provide even more flexible grading of scalar and vector responses. This partial grading engine can be configured to, among other things, assign part marks for missing units, transposed or missing vector components or missing algebraic terms.

Topics include:

• Cross Products
• Coulomb’s Law
• Electric Fields
• Point Charge Distributions
• Continuous Charge Distributions (Integration)
• Electric Potential
• Electric Potential Energy
• Electromotive Force
• Resistance
• Capacitance
• Kirchhoff’s Laws
• Magnetic Fields
• Magnetic Fields Due to Current Carrying Wires
• Forces on Wires in Magnetic Fields
• Forces on Charges in Electric and/or Magnetic Fields
• EM Waves
• Two Source Interference
• Double Slit Interference
• Single Slit Diffraction
• Diffraction Gratings

Jonny Zivku
Maplesoft Product Manager, Maple T.A.

## Ten commands(package) need to be enhanced in the...

by: Maple

Did Maplesoft make a statistics about questions on MaplePrimes?

There must be some commands frequently meet problems.

I listed 10 commands or packages need to be enhanced much more.

1.fsolve.

eg, roots of transcendental equation on complex plane & system of nonlinear equations.

2.int.

Both numerical integration & symbolic integration need further developed.

3.Eigenvalues&LinearSolve.

large scale computing, everyone needs it.

4.dsolve&pdsolve.

dsolve needs to be enhanced for solve more equations in parallel.

As mathematica 10 contains the FEM package, I think Maple needs to do something, develop a new package needs more time than make the existing pdsolve command better.

parallel programing is the future. BTW, why don't make the task model much easier to use, like the mathematica, just a command?

6.plot&plot3d

there is much space to go further about the two commands.

7.Optimization package or Statistics package.

In fact, both packages need to be further enhanced, especially for Optimization package.

Although some modern algorithms about optimization&statistics is much easier to see on the internet, the

Maplesoft should not stop, but go further, add them in Maple.

Above is just my opinion.

## Maple T.A. course materials – Statistics (University...

by:

Several Maple T.A. users have developed comprehensive sets of question content and assignments to support full courses in Maple T.A. These questions are available through the Maple T.A. Cloud, and we have decided to also post the associated course modules on Maple Primes as an alternative way of accessing this content.

Below you will find a link to the Statistics Maple T.A.. course module developed by the University of Guelph.

This testing content is freely distributed, and can be used in your own Maple T.A. tests either as-is, or with edits.

The Statistics course module is designed to cover a single-semester course in statistics for science students at the second-year university level. The questions are designed to span the topics listed below, allowing for practice, homework or testing throughout the semester. The questions are mainly of an applied nature and do not delve very deeply into the underlying mathematical theory.

Topics:

• Introduction to Statistics
• Descriptive Statistics
• Basic Probability
• Discrete Random Variables
• Continuous Random Variables
• Sampling Distributions
• Inference for Means
• Inference for Proportions
• Inference for Variances
• Chi-square Tests for Count Data
• One-Way ANOVA
• Simple Linear Regression and Correlation

Jonny Zivku
Maplesoft Product Manager, Maple T.A.

## Maple T.A. course materials – Statistics (University...

by:

Several Maple T.A. users have developed comprehensive sets of question content and assignments to support full courses in Maple T.A. These questions are available through the Maple T.A. Cloud, and we have decided to also post the associated course modules on Maple Primes as an alternative way of accessing this content.

Below you will find a link to the Statistics Maple T.A.. course module developed by the University of Waterloo.

This testing content is freely distributed, and can be used in your own Maple T.A. tests either as-is, or with edits.

The Statistics content is used in introductory statistics courses at the University of Waterloo, and has been used regularly over several years. The over 700 questions are clearly organized by topic, and provide extensive feedback to students.

Topics include:

• Basics
• Confidence Intervals
• Continuous Distribution
• Discrete Multivariate
• Discrete Probability
• Graphical Analysis
• Hypothesis Testing
• Numerical Analysis for Statistics
• Probability
• Sampling Distributions

Jonny Zivku
Maplesoft Product Manager, Maple T.A.

## Maple T.A. course materials – Calculus 1 and 2

by:

Several Maple T.A. users have developed comprehensive sets of question content and assignments to support full courses in Maple T.A. These questions are available through the Maple T.A. Cloud, and we have decided to also post the associated course modules on Maple Primes as an alternative way of accessing this content.

Below you will find a link to the Calculus 1 Maple T.A.. course module developed by the University of Guelph. This course material also forms part of Teaching Calculus with Maple: A Complete Kit, which provides lectures notes, Maple demonstrations, Maple T.A. assignments, and more for teaching both Calculus 1 and Calculus 2.

This testing content is freely distributed, and can be used in your own Maple T.A. tests either as-is, or with edits.

The Calculus 1 course module is designed to accompany the first semester of an introductory honours calculus course. The course is intended primarily for students who need or expect to pursue further studies in mathematics, physics, chemistry, engineering and computer science.

Topics include:

• trigonometry including the compound angle formulas
• inequalities and absolute values
• limits and continuity using rigorous definitions, the derivative and various applications (extreme, related rates, graph sketching)
• Rolle's Theorem and the Mean Value Theorem for derivatives
• the differential and anti-differentiation
• the definite integral with application to area problems
• the Fundamental Theorem of Calculus
• logarithmic and exponential functions
• the Mean Value Theorem for Integrals

The Calculus 2 course module is designed to accompany the second semester of an introductory honours calculus course.

Topics include:

• inverse trigonometric functions
• hyperbolic functions
• L'Hôpital's Rule
• techniques of integration
• parametric equations
• polar coordinates
• Taylor and MacLaurin series
• functions or two or more variables
• partial derivatives
• multiple integration

Jonny Zivku
Maplesoft Product Manager, Maple T.A.

## Packing of circles: touchstone for global optimize...

Maple , Maple Toolboxes

I would like to pay attention to a series of applications by Samir Khan
http://www.maplesoft.com/applications/view.aspx?SID=153600
http://www.maplesoft.com/applications/view.aspx?SID=153599
http://www.maplesoft.com/applications/view.aspx?SID=153596
http://www.maplesoft.com/applications/view.aspx?SID=153598
My congratulations to the author on his work well done. New capacities of Global Optimization Toolbox are spectacular. For example, in the first application  an optimization
problem in 101 variables under 5050 nonlinear  constraints
(other than 202 bounds) is solved.
I think it requires a very powerful comp and much time.
I tried that  problem for n=20 with the good old DirectSearch
on my comp (4 GB RAM, Pentium Dual-Core CPU E5700@3GHz) by

soln2 := DirectSearch:-GlobalSearch(rc, {cons1, cons2, rc >= 0,
seq(`and`(vars[i] >= -70, vars[i] <= 70), i = 1 .. 2*n), rc <= 70},
variables = vars, method = quadratic, number = 140, solutions = 1,
evaluationlimit = 20000)

and obtained not so bad rc=69.9609360106765 (whereas www.packomania.com gives rc=58.4005674790451137175957) in about one hour.

Packing_by_DS.mw
For n=50 the memory of my comp cannot allocate calculations or the obtained result by the Search command is far away from the one in packomania.

## Beginner compares Maple to Mathematica and Maxima...

by:

It presents a linear algebra problem, then writes a program to solve it in Maple, Mathematica, and Maxima to see which one is better. What do you think?

## August Live Webinar

by: Maple

Maplesoft regularly hosts live webinars on a variety of topics. Below you will find details on an upcoming webinar we think may be of interest to the MaplePrimes community.  For the complete list of upcoming webinars, visit our website.

Hollywood Math 2

In this second installment of the Hollywood Math webinar series, we will present some more examples of mathematics being used in Hollywood films and popular hit TV series. For instance, have you wondered how Ben Campbell solved his professor’s challenge so easily in the movie “21”? Or about the details of the Nash equilibrium that John Nash first developed in a “A Beautiful Mind”? We’ve got the answers! These relevant, and exciting examples can be used as material to engage your students with examples familiar to them, or you can just attend the webinar for its entertainment value.

Anyone with an interest in mathematics, especially high school and early college math educators, will be both entertained and informed by attending this webinar. At the end of the webinar you’ll be given an opportunity to download an application containing all of the examples that we demonstrate.

If you missed the first webinar in this two part series, you can view the 'Hollywood Math' recording on our website.

## Pixel Conversion

by: Maple 18

Here is an example of manipulating an Array of pixels. I chose the x-rite ColorChecker as a model so there would be published results to check my work. A number of details about color spaces have become clear through this exercise. The color adaptation process was modeled by converting betweenXYZ and LMS. Different black points may be selected depending on how close to zero illuminance one would accept as a good model.

I look forward to extending this work to verify and improve the color calibration of my photography. Also some experimentation with demosaicing should be possible.

 Initialization

x-rite Colorchecker xyY Matrix

=

=

 Convert xyY to XYZ

=

 XYZ D50 to XYZ D65

=

Convert XYZ to Lab (D50 or D65 White Point)

 Reference White Point for D50  =  =  = Lab Conversion Constants; Reference White Point for D65  =  =  =

=

Convert XYZ to aRGB (XYZ D50 or D65 to aRGB D65)

XYZ Scaling for aRGB Ymax,Ymin (Ref. Adobe RGB (1998) Color Image Encoding Section 4.3.2.2 and 4.3.8)

 White Point (Luminance=160Cd/m^2) D65 Black Point (Luminance=0.5557Cd/m^2) D65 White Point (Luminance=160Cd/m^2) D50 Black Point (Luminance=0.5557Cd/m^2) D50 =  =  = =  =  =

aRGB Expansion for 8bits

Combine Steps

Note: The aRGB values published for ColorChecker assume a black point of 0cd/m^2.

=

=

 Convert XYZ to ProPhoto RGB (D50)

=

 Convert XYZ to sRGB (XYZ D50 or D65 to sRGB D65)

Note: The sRGB values published for ColorChecker assume a black point of 0cd/m^2.

=

=

Corrections to the original version of theis document;
 Make the scaling for a nonzero black point the same for all RGB color spaces.
 Clip negative RGB values to zero.
 Remove the redundant Array container from matrix multiplications.
Use map in place of the \$ to apply a function to each element of an Array.

## Interactive Embedded Components in Physics

The Interactive Embedded Components in Physics are of great importance today and will be even more in the future. Hereand leave a small tutorial of Embedded Components in Physics applied to physics. I hope that somehow you motives to continue the development of science.

Interactive_Embedded_Components_in_Physics.mw      (in spanish)

Atte.

Lenin Araujo Castillo

Physics Pure

Computer Science

## Procedure to calculate the day of the week for...

by:

To calculate the day of the week for a given date, first of all we need to find out the number of odd days.

Today I thought of sharing a beautiful problem I learned in my school, though it is easy, it is tricky too.
Odd Days are number of days more than the complete number of weeks in given period.
Leap Year is the year which is divisible by 4.
A normal year has 365 days
A leap year has 366 days
One normal year = 365 days = 52weeks + 1day
One normal year has one odd day

One leap year = 366 days = 52weeks + 2days
One leap year has two odd days

100 years = 76 ordinary years + 24 leap years = 5200 weeks + 124 days = 5217 weeks + 5 days
100 years have 5 odd days

400 years have (20+1) 0 odd days

The number of odd days and the corresponding day of the week is given below

0-Sunday
1-Monday
2-Tuesday
3-Wednesday
4-Thursday
5-Friday
6-Saturday

So by finding out the number of odd days you can find out the day of the week. I hope this procedure Will be helpful in solving math problems in exams.

Thanks.

## Search Doesn't Work, & Double Request for login...

by: Maple

The search operation on both questions and posts doesn't work. I get the same set of results for both, and the same results regardless of the search term.

When I login and then create a question or post and click submit (or preview), I get a new request to login, and, after I do that login, the originally entered message body has been erased.

## Update to Maple 18 for Mac and 64-bit Linux

by: Maple

We have issued an update to correct a problem a small number of Mac and 64-bit Linux users have experienced when doing certain types of floating point computations on very recent hardware (such as this report on MaplePrimes: http://www.mapleprimes.com/questions/201815-Problem-Loading-MKL-In-Maple-18). When the problem occurs, instead of giving the result, Maple issues a “lost kernel connection” error message and must be restarted.

While this issue does not occur on most computers, we recommend that all Maple 18 customers running on Mac or 64-bit Linux install this update to ensure they do not encounter this problem. This update can be safely applied to any Mac or 64-bit Linux computer. Windows and 32-bit Linux users do not need, and cannot install, this update.

To get this update, you can use Tools>Check for Updates from within Maple, or visit Maple 18.01a Downloads.

eithne

 First 73 74 75 76 77 78 79 Last Page 75 of 296
﻿