Streamlining Mathematica for Education

Itai Seggev, Algorithms R&D, Wolfram Research
Devendra Kapadia, Algorithms R&D, Wolfram Research

Join the Conversation #WolframTechConf

ABSTRACT

Mathematica has long been recognized as a powerful tool for both doing and teaching mathematics.  Its users range from secondary school students to researchers.  This wide range can make it tricky to serve all of them well, and students can sometimes be overwhelmed or confused.  In recent years, we have made a concrete series of steps to make Mathematica more student friendly.  In this talk we will survey these efforts, that include dedicated functions for simple use cases, enhanced presentation of results, and improved documentation. While inspired by the education market, many of these enhancements will benefit the full range of our users.

Enhanced Presentation: Root

A simple example

This is what Solve used to return:

Solve[x^5-2x+17==0,x]

Now you get:

Solve[x^5-2x+17==0,x]

This is pure formatting, old result in new kernel:

Root[17-2 #1+((#1)^5)&,1]

New result in old kernel:

(NumericalApproximation[Root, (RowDefault["-1.83", FEExpressionsNumericalApproximationElider]), Root[17-2 #1+((#1)^5)&,1], ])

More examples

Solve[Sqrt[x]+3x^(1/3)==5,x,Reals]

Solve[Sqrt[x]+3x^(1/3)==5,x,Reals]

A transcendental root:

Solve[Sin[E^x]-Cos[2 x]==1&&-1≤Re[x]≤1&&-1≤Im[x]≤1,x]

Solve[Sin[E^x]-Cos[2 x]==1&&-1≤Re[x]≤1&&-1≤Im[x]≤1,x]

A more complicate transcendental root:

Solve[Cos[Exp[x]]==3 Exp[-x]+1&&0≤Re[x]≤1,x]

Solve[Cos[Exp[x]]==3 Exp[-x]+1&&0≤Re[x]≤1,x]

A couple of details

New formatting not used when symbolic parameters are present:

Solve[x^5-a x+17==0,x]

New roots will evaluate but not display in older versions.  Can control their use via a SystemOption.

SetSystemOptions["TypesetOptions"->"NumericalApproximationForms"->False];
(NumericalApproximation[Root, (RowDefault["-1.83", FEExpressionsNumericalApproximationElider]), Root[17-2 #1+((#1)^5)&,1], ])
SetSystemOptions["TypesetOptions"->"NumericalApproximationForms"->True];

Enhanced Presentation+: C

C in DSolve

Functionality hasn’t changed, but now it looks more friendly:

DSolve[y''[x]==x^2,y[x],x]

DSolve[y''[x]==x^2,y[x],x]

DSolve[y''[x]+y[x]==0,y[x],x]

DSolve[y''[x]+y[x]==0,y[x],x]

Note: TraditionalForm unchanged:

%//TraditionalForm

C in new places

By popular demand:

Integrate[x^2,x,GeneratedParameters->C]

Sometimes in constants aren’t so constant:

Integrate[x^2,x,y,GeneratedParameters->C]

Also in the discrete integral:

Sum[x^2,x,GeneratedParameters->C]

DifferenceDelta[%,x]

And product:

Product[x^2,x,GeneratedParameters->C]

DiscreteRatio[%,x]

For more detail on this and related features, go to What’s New in Calculus and Algebra, Thursday, 10:30—11:00, Fighting Illini

Dedicated Functions: New Number Domains

Basics

The new domains:

reals = {PositiveReals, NonNegativeReals, NonPositiveReals, NegativeReals}

rationals = {PositiveRationals, NonNegativeRationals, NonPositiveRationals, NegativeRationals}

integers = {PositiveIntegers, NonNegativeIntegers, NonPositiveIntegers, NegativeIntegers}

π is a non-negative real, but not any kind of rational:

π∈#& /@ Join[reals,rationals]

-1/2 is a non-positive rational, but not any kind of integer:

((-1)/2)∈#& /@ Join[rationals,integers]

0 is included in the non-strict domains:

0∈#&/@Join[reals,rationals,integers]

Simplification

An elementary simplification:

Simplify[(E^x)∈(PositiveReals),x∈(Reals)]

Equivalently:

Reduce[(E^x)∈(PositiveReals),x,(Reals)]

A quantified statement:

FullSimplify[(Subscript[∀, x,x∈(NegativeReals)])0<(E^x)<1]

Equivalently:

Resolve[(Subscript[∀, x,x∈(NegativeReals)])0<(E^x)<1]

An integer expression:

Simplify[Abs[n]==Floor[n],n∈(PositiveIntegers)]

Simplify[Abs[n]== Floor[n],n∈(NegativeIntegers)]

Equation Manipulation I: AddSides/SubtractSides

Common questions

How do add to both sides of an equation?

How do I “add two equations together”?

Old answer: Thread (possibly Map or Replace)

New answer: dedicated functions

Basic usages

AddSides adds corresponding sides:

AddSides[x==y,5]

AddSides[x==y,a==b]

Can have more than two sides:

AddSides[x==y==z,a==b==2w]

SubtractSides is analogous:

SubtractSides[x==y,5]

SubtractSides[x==y,a==b]

SubtractSides[x==y==z,a==b==2w]

It also has a one-arg form for moving this to the LHS:

SubtractSides[a==b]

Some old answers

Adding a constant to both sides:

Thread[(x==y)+5,Equal]

#+5& /@ (x==y)

Replace[x==y, s_:>s+5,{1}]

Adding corresponding sides:

Thread[(x==y)+(a==b),Equal]

Equal@@MapThread[Plus[##]&,List@@@{x==y,a==b}]

But wait, there’s more!

Who said we had to stick equations?

AddSides[x>y,5]

Or a single relation?

AddSides[x==y,a≤b]

Use inequations:

SubtractSides[x==y,a!=b]

More than 2 sides:

AddSides[x==y==z,a==b>2w]

It knows about Piecewise:

AddSides[({{\[Piecewise], ({{(x^2)>(c/a)+((b x)/a), a>0}, {(x^2)<(c/a)+((b x)/a), a<0}, {a (x^2)>c+b x, True}})}}),-x^2]

And ConditionalExpression:

AddSides[ConditionalExpression[(a/c)==(b/d),c≠0],((-b)/d)]

Equation Manipulation II: MultiplySides/DivideSides

Basic usages

MutiplySides is analogous to AddSides:

MultiplySides[x==y,5]

MultiplySides[x==y,a==b]

MultiplySides[x==y==z,a==b==2w]

DivideSides is analogous to SubtractSides:

DivideSides[x==y,5]

But what is happening here?

DivideSides[x==y,a==b]

DivideSides[a==b]

GenerateConditions

The default setting (RefLink[GenerateConditions, paclet:ref/GenerateConditions])->(RefLink[All, paclet:ref/All]) creates a (RefLink[Piecewise, paclet:ref/Piecewise]) expression if needed:

MultiplySides[a/b>c,b]

(RefLink[GenerateConditions, paclet:ref/GenerateConditions])->(RefLink[True, paclet:ref/True]) returns one valid result with the needed condition:

MultiplySides[a/b>c,b,GenerateConditions->True]

(RefLink[GenerateConditions, paclet:ref/GenerateConditions])->(RefLink[False, paclet:ref/False]) returns one valid result without the needed condition:

MultiplySides[a/b>c,b,GenerateConditions->False]

(RefLink[GenerateConditions, paclet:ref/GenerateConditions])->(RefLink[None, paclet:ref/None]) will fail if conditions are needed:

MultiplySides[a/b>c,b,GenerateConditions->None]

(RefLink[GenerateConditions, paclet:ref/GenerateConditions])->(RefLink[Automatic, paclet:ref/Automatic]) returns conditions that are not generically satisfied:

DivideSides[a x >b,b,GenerateConditions->Automatic]

If the condition only fails for a single point, it is not returned:

DivideSides[a x ==b,b,GenerateConditions->Automatic]

DivideSides[a x ==b,b,GenerateConditions->True]

The values of GenerateConditions (other than All) are consistent with other recent functions.

Some details (bonus)

Equivalence of results

When you multiply by a constant, the result is equivalent to the original relation:

orig=a==b;

MultiplySides[orig,c]

Resolve[(Subscript[∀, {a,b,c}])(orig⧦%)]

The same is true for division:

DivideSides[a==b,c]

Resolve[(Subscript[∀, {a,b,c}])(orig⧦%)]

When you multiply by another relation, the result may not be equivalent to the original relation:

newMultiply=MultiplySides[orig,c==d]

Resolve[(Subscript[∀, {a,b,c,d}])(orig⧦newMultiply)]

What is true is that the result is holds whenever both input equations are true:

Resolve[(Subscript[∀, {a,b,c,d}])(orig&&c==d\[Implies]newMultiply)]

The same considerations apply to apply to division:

newDivide=DivideSides[orig,c==d]

Resolve[(Subscript[∀, {a,b,c,d}])(orig⧦newDivide)]

Resolve[(Subscript[∀, {a,b,c,d}])(orig&&c==d\[Implies]newDivide)]

Note that unlike multiplication, the Piecewise was necessary to make even this one-way implication true:

Resolve[(Subscript[∀, {a,b,c,d}])(orig&&c==d\[Implies](a/c)==(b/d))]

Ordering

When multiply an relation by a negative number, we preserve the inequality and reverse the arguments:

MultiplySides[a>b>c,-1]

Extends to symbolic and more than binary relations:

MultiplySides[a>b,c]

Makes sense if you think about adding a second relation:

AddSides[%,x>y]

You also see this in implicit multiplication:

SubtractSides[a==b==c,x>y>z]

Equation Manipulation III: ApplySides and Putting It All Together

ApplySides

Applies a function to all sides of an equation or inequality:

ApplySides[Exp,Log[x]==2]

ApplySides[Sqrt,x^2+1> 4]

Like the other *Sides functions, knows about Piecewise and ConditionalExpression:

ApplySides[Sinh,({{\[Piecewise], ({{(x^2)>(c/a)+((b x)/a), a>0}, {(x^2)<(c/a)+((b x)/a), a<0}, {a (x^2)>c+b x, True}})}})]

ACHTUNG! It is purely structural and does not check mathematical consistency:

ApplySides[Sin,x>c]

{x>c,Sin[x]>Sin[c]} /. {x->3Pi/2,c->Pi/2}

Deriving the quadratic formula

Derive the quadratic formula:

quadratic=a (x^2)+b x + c==0

Multiply both sides by 4 a:

MultiplySides[quadratic,4a,Assumptions->a≠0]//Expand

Add (b^2)-4 a c to both sides:

AddSides[%,(b^2)-4a c]

Factor the left-hand side:

Factor[%]

Take the positive square root of both sides:

ApplySides[Sqrt,%]

Cancel the square root of the square:

PowerExpand[%]

Subtract b from both sides:

SubtractSides[%, b]

Divide both sides by 2 a to obtain the quadratic formula for x with positive square root:

DivideSides[%,2a,Assumptions->a≠0]

Documentation updates: Calculus

Rewriting documentation pages

Using examples inspired by textbooks (e.g., Stewart, Marsden & Tromba, etc.)

Some new pages:

(RefLink[D, paclet:ref/D])

(RefLink[Limit, paclet:ref/Limit])

(RefLink[Integrate, file:///Users/itais/WolframWorkspaces/Kernel/Documentation/English/System/ReferencePages/Symbols/IntegrateNew.nb]) (forthcoming)

More on Limit (bonus)

Limit used to give this:

Limit[1/x,x->0]

Doesn’t seem quite right:

Plot[1/x,{x,-1,1}]

What setting is needed for the limit from below?

Limit[1/x,x->0,Direction->"?"]

Now gives two sided limit by default:

Limit[1/x,x->0]

Have useful aliases for common directions:

{Limit[1/x,x->0,Direction->"FromAbove"],Limit[1/x,x->0,Direction->"FromBelow"]}

Documentation updates: Linear Algebra

Linear Algebra is the study of linear equations and transformations in two or more dimensions.

It has important applications in engineering, data science, and other fields.

Courses in Linear Algebra are very popular at the University level.

The earlier generation of textbooks focused on vector spaces and were more theoretical:

Modern textbooks usually discuss matrices and real-world applications in detail:

We have prepared a solution manual based on the most popular textbook.

The reference pages for basic Linear Algebra functions are being updated.

Join us at WTC Meetup: The Wolfram Language and Teaching Linear Algebra

Thursday, 13:00—14:00, Homewood

Thanks!

Our team:

Adam Strzebonski          Devendra Kapadia          Itai Seggev          Roger Germundsson

Upcoming team talks:

What’s New in Calculus and Algebra, Thursday, 10:30—11:00, Fighting Illini

Asymptotics Solvers, Thursday, 11:00—11:30, Fighting Illini

WTC Meetup: The Wolfram Language and Teaching Linear Algebra, Thursday, 13:00—14:00, Homewood

Asymptotics Relations, Friday, 14:00—14:30, Fighting Illini

Questions?