## Your favorite and most useful code snippets

by:

Hey Everyone:

I was wondering what are your favorite and most useful code snippets that you often use. Maybe ones that are in your initialization code? Maybe ones that speed up something that you often do in maple? Maybe ones that you've seen on this and other websites and adopted for your own purposes?

For fun, I attach my init.mpl (.txt here, as .mpl attachments are not allowed by mapleprimes) here init.txt

Some of the snippets that I use the most are also listed below:

#rearrange curves inside an already created plot, so that certain curves are "on top" of the other ones.
#discussed here:
#http://www.mapleprimes.com/questions/201626-Order-Of-Curves-In-A-Plot
rearrangeCurves:= proc(
v_items::specfunc(anything, PLOT),
v_reorder::list([integer,integer]):= []
)
local p, curves, rest;
(curves,rest):= selectremove(type, v_items, specfunc(anything, CURVES));
curves:= < op(curves) >:
for p in v_reorder do
curves[p]:= curves[p[[2,1]]]
end do;
PLOT(convert(curves,list)[], op(rest))
end proc:

#for numerical differentiation
#based on the idea from:
#http://www.mapleprimes.com/posts/119554-Data-Interpolation
#example use:
#alist:=[seq(i, i=0..10, 0.1)]:
#data:=map(x->evalf(sin(x)), alist):
#plot(alist, data);
#plot([cos(x), 'num_diff(x, LinearAlgebra:-Transpose(Matrix([alist,data])))'], x=1..10, thickness=5, linestyle=[solid, dot], color=[blue, red]);
num_diff:=proc(x, v_data, v_options:=[method=spline, degree=3])
#v_data is a matrix
#TODO: let the data be in a more arbitrary format that ArrayInterpolation understands, but keep x as first var
evalf(D(x->CurveFitting:-ArrayInterpolation(v_data, [x],v_options[])[])(x));
end:

#extract nth columns/rows from a matrix
#these only work if have a 2d object... should be updated to also work
#with 1d row/column vectors
#Example use cases
#A := LinearAlgebra:-RandomMatrix(20, 20, outputoptions = [datatype = float]);
#nthColumns(A, 2); #Every other column
#nthRows(A, 10)[.., 1..3]; #Every 10th row, but show only first 3 columns
nthColumns:=proc(v_m, v_n)
v_m[..,[seq(i, i=1..rtable_size(v_m), v_n)]]
end:
nthRows:=proc(v_m, v_n)
v_m[[seq(i, i=1..rtable_size(v_m), v_n)],..]
end:

#saves a png plot
savePlot:=proc(v_p, v_fileName, v_w:="800", v_h:="500")
plotsetup("png", plotoutput=v_fileName, plotoptions=cat("quality=100,portrait,noborder,width=",v_w,",height=",v_h));
print(plots[display](v_p));
fclose(v_fileName):
plotsetup(default);
end:

## Resize a code edit region

by: Maple 18

This is a very simple suggestion that weights heavily on my enjoyment of Maple.

I'm not sure if it is only me and my students but it is really tricky to resize a code edit region. Trying to get a hold of the contour in an exercise in patience! Can anyone fix this?

Thanks!

Stéphane

## Generalization of combinat[composition] command

by:

The well-known  combinat[composition]  command computes and returns a list containing all distinct ordered  k-tuples of positive integers whose elements sum equals  . These are known as the compositions of  n .  For some applications, additional constraints are required for the elements of these k-tuples, for example, that they are within a certain range.

The  Composition  procedure solves this problem. Required parameters:  n - a nonnegative integer, - a positive integer. The parameter  res  is the optional parameter (by default  res is  ). If  res  is a number, all elements of  k-tuples must be greater than or equal  res .  If  res  is a range  a .. b ,   all elements of  k-tuples must be greater than or equal  a  and  less than or equal  b .  Composition(n,k,1)  is equivalent to  combinat[composition](n,k) .

The code of the procedure:

Composition := proc (n::nonnegint, k::posint, res::{range, nonnegint} := 0)

local a, b, It, L0;

if res::nonnegint then a := res; b := n-(k-1)*a  else a := lhs(res); b := rhs(res) fi;

if b < a or b*k < n then return `No solutions` fi;

It := proc (L)

local m, j, P, R, i, N;

m := nops(L); j := k-m; N := 0;

for i to nops(L) do

R := n-`+`(op(L[i]));

if R <= b*j and a*j <= R then N := N+1;

P[N] := [seq([op(L[i]), s], s = max(a, R-b*(j-1)) .. min(R, b))] fi;

od;

[seq(op(P[s]), s = 1 .. N)];

end proc;

L0 := [[]];

(It@@k)(L0);

end proc:

Three simple examples:

Composition(10,3); ``;   # All terms greater than or equal 0

Composition(10,3, 2);   # All terms greater than or equal 2

Composition(10,3, 2..4);   # All terms greater than or equal 2 and less than or equal to 4 A more complex example. The problem - to find all the numbers in the range  1 .. 99999999  whose digits sum is equal to 21 .

Each number is represented by a list of digits from left to right, replacing missing digits at the left with zeros.

M:=Composition(21,8, 0..9):

nops(M);  # The number of solutions

[seq(M[1+100000*i], i=0..9)]; # 10 solutions from the list M starting the first one

seq(add(%[i,k]*10^(8-k), k=1..8),i=1..nops(%));  # Conversion into numbers Composition.mws

## combstruct package

by:

Greetings to all.

I am writing to alert MaplePrimes users to a Maple package that makes an remarkable contribution to combinatorics and really ought to be part of your discrete math / symbolic combinatorics class if you teach one. The combstruct package was developed at INRIA in Paris, France, by the algorithmics research team of P. Flajolet during the mid 1990s. This software package features a parser for grammars involving combinatorial operators such as sequence, set or multiset and it can derive functional equations from the grammar as well as exponential and ordinary generating functions for labeled and unlabeled enumeration. Coefficients of these generating functions can be computed. All of it easy to use and very powerful. If you are doing research on some type of combinatorial structure definitely check with combstruct first.

My purpose in this message is to advise you of the existence of this package and encourage you to use it in your teaching and research. With this in mind I present five applications of the combstruct package. These are very basic efforts that admit improvement that can perhaps serve as an incentive to deploy combstruct nonetheless. Here they are:

I hope you enjoy reading these and perhaps you might want to feature combstruct as well, which presented the first complete implementation in a computer algebra system of the symbolic method, sometimes called the folklore theorem of combinatorial enumeration, when it initially appeared.

Best regards,

Marko Riedel.

## Mathematical Modeling with Maple Research

Currently calculations: equations, regression analysis, differential equations, etc; to mention a few of them; are developed using traditional methods ie even are proposed and solved by hand and on paper. In teaching our scientists and engineers use the chalkboard as a way to reach students and enable them to solve their calculation. To what extent Maple contributes to research on new mathematical models applied science and engineering ?. Maplesoft appears as a proposal to resolve problems with our traditional proposed intelligent algorithms, development process, embedded components, and not only them but also generates type applications for Apple ipad tablets signature. Based on the computer algebra system Maple Maplesoft gives us the package which works exactly like we were on our work. I will show how mathematics is developed from a purely basic to reach modeling differential equations applied to education and engineering. Also visualizare current techniques for developing applications for mobile devices. ECI_2015.pdf

Atte.

Lenin Araujo Castillo

Physics Pure

Computer Science

We’ve just released a free maintenance release to MapleSim 7. This update includes improvements to MapleSim, the MapleSim Battery Library, and the MapleSim Connector for FMI. For details, see the MapleSim 7.01 update page.

eithne

## Online Courseware with Maplesoft technology

by: Maple , MapleNet

We are happy to announce the first results of a partnership between Maplesoft and the University of Waterloo to provide effective, engaging online education for technical courses.

Combining rich course materials developed by the University with Maple T.A. and Maplesoft technology for developing, managing, and displaying dynamic content, the Secondary School Courseware project supports high school students and teachers from around the world in their Precalculus and Calculus courses. The site includes interactive investigations, videos, and self-assessment questions that provide immediate feedback.

Feel free to take a look. The site is free, and no login is required.

eithne

## correct the API for dsolve with series option

by:

I do not think the current API for dsolve when asking for series solution is done right. If one wants to obtain a series solution for an ODE, but wants different order than the default 6, now one must set this value using a global setting before making the call, like this:

eq:=diff(y(x),x\$2)+y(x)=0;
Order:=10;
dsolve({eq,y(0)=1,D(y)(0)=0},y(x),type='series');

It would be better if options to calls are passed along with the other parameters in the call itself. Something like

dsolve({eq,y(0)=1,D(y)(0)=0},y(x),type='series',order=10);

This should also apply to any command that takes Order, such as series(cos(x),x=0,order=10);

Passing options and values to functions using global and environment variables is not safe and not a good way to go about it as it can cause programming errors.

## Hello Everyone, I am new one in the community..

by:

Hello Everyone, I am new one in the community..

## Programming Embedded Components for Graphics in...

Maple 18

In this work we show you what to do with the programming of Embedded Components applied to graphics in the Cartesian plane; from the visualization of a point up to three-dimensional objects and also using the Maple language generare own interactive applications for touch screen technology in mobile devices techniques. Given that computers use multicore and designed algorithms that solve calculus problems with very good performance in time; this brings programming to more complex mathematical structures such as in the linear algebra, analytic geometry and advanced methods in numerical analysis. The graphics will show real-time results for the correct use of the parallel programming undertook to bear the procedural technique is well suited to the data structure, curves and surfaces. Interaction in a single graphical container allowing the teaching and / or research the rapid change of parameters; giving a quick interpretation of the results.

FAST_UNT_2015.pdf

Programming_Embedded_Components_for_Graphics_in_Maple.mw

Atte.

L.Araujo C.

Physics Pure

Computer Science

## Top 10 Webinars of 2014

Happy New Year! Now that 2014 is behind us, I thought it would be interesting to look back on the year and recap our most popular webinars. I’ve gathered together a list of the top 10 academic webinars from 2014 below. All these webinars are available on-demand, and you can watch the recording by clicking on the webinar titles below.

-----------------------------------------------

See What’s New in Maple 18 for Educators

In this webinar, an expert from Maplesoft will explore new features in Maple 18, including improved tools for developing quizzes, enhanced tools for visualizations, updated user interface, and more.

Introduction to Teaching Calculus with Maple: A Complete Kit

During this webinar you will learn how to boost student engagement with highly interactive lectures, reinforce concepts with built-in “what-if” explorations, consolidate learning with carefully-constructed homework questions, and more.

Maplesoft Solutions for Math Education

In this webinar, you will learn how Maple, The Möbius Project, and Maplesoft’s testing and assessment solutions are redefining mathematics education.

Teaching Concepts with Maple

This webinar will demonstrate the Teaching Concepts with Maple section of our website, including why it exists and how to use it to help students learn concepts more quickly and with greater insight and understanding.

Revised Calculus Study Guide - A Clickable-Calculus Manual

This webinar will provide an overview of the Revised Calculus Study Guide, the most complete guide to how Maple can be used in teaching and learning calculus without first having to learn any commands.

Clickable Engineering Math: Interactive Engineering Problem Solving

In this webinar, general engineering problem-solving methods are presented using clickable techniques in the application areas of mechanics, circuits, control, and more.

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.

In this webinar, learn how to quickly create multi-link robots by simply defining DH parameters in MapleSim. After a model is created, learn to extract the kinematic and dynamic equations symbolically in Maple.

Introduction to Maple T.A. 10

This webinar will demonstrate the key features of Maple T.A. from both the instructor and student viewpoint, including new features in Maple T.A. 10.

The Möbius Project: Bringing STEM Courses Online

View this presentation to better understand the challenges that exist today when moving a STEM course online and to find out how the Maplesoft Teaching Solutions Group can help you realize your online course vision.

-----------------------------------------------

Are there any topics you’d like to see us present in 2015? Make sure to leave us a comment with your ideas!

Kim

## January’s Featured Live Webinars

by:

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

Creating Questions in Maple T.A. – Part #2

This presentation is part of a series of webinars on creating questions in Maple T.A., Maplesoft’s testing and assessment system designed especially for courses involving mathematics. This webinar, which expands on the material offered in Part 1, focuses on using the Question Designer to create many standard types of questions. It will also introduce more advanced question types, such as sketch, free body diagrams, and mathematical formula.

The third and final webinar will wrap up the series with a demonstration of math apps and Maple-graded questions.

Clickable Calculus Series – Part #1: Differential Calculus

In this webinar, Dr. Lopez will apply the techniques of “Clickable Calculus” to standard calculations in Differential Calculus.

Clickable Calculus™, the idea of powerful mathematics delivered using very visual, interactive point-and-click methods, offers educators a new generation of teaching and learning techniques. Clickable Calculus introduces a better way of engaging students so that they fully understand the materials they are being taught. It responds to the most common complaint of faculty who integrate software into the classroom – time is spent teaching the tool, not the concepts.

## Draghilev’s method, F(x)=0. Animation.

by: Maple 15

D_Method.mw

The classical Draghilev’s method.  Example of solving the system of two transcendental equations. For a single the initial approximation are searched 9 approximate solutions of the system.
(4*(x1^2+x2-11))*x1+2*x1+2*x2^2-14+cos(x1)=0;
2*x1^2+2*x2-22+(4*(x1+x2^2-7))*x2-sin(x2)=0;
x01 := -1.; x02 := 1.; ## 3d model of a cam mechanism. Animation.

by: Equation: ((x1+.25)^2+(x2-.2)^2-1)^2+(x3-.1)^2-.999=0;

a_cam_3D.mw

## Cam mechanism. Animation.

by: Cam mechanism animation.   Equation:  (xx2-1.24)^10+5*(xx1-.66)^10-9.=0
a_cam.mw

﻿