lplex

20 Reputation

One Badge

4 years, 202 days

MaplePrimes Activity


These are questions asked by lplex

I had difficulty in making my latest post.  It would fail at Submit.

I had success when I saved a draft post.  I was able to edit the draft to submit.

 

Lee


 

I am interested in how easy it is to work with formulae in the Maple language.  For example, you can easily add two equations together with '+'.

 

e1:=x^2+1=2*x;

x^2+1 = 2*x

(1)

e2:=x^3+x=5;

x^3+x = 5

(2)

e1+e2;

x^3+x^2+x+1 = 2*x+5

(3)

 

I was pleased when the following example added (x+1) to both sides of an equation,

 

e3:=x+1;

x+1

(4)

e1+e3;

x^2+x+2 = 3*x+1

(5)

Some other algebraic operations work.

e1-e3;

x^2-x = x-1

(6)

e1*e3;

(x+1)*(x^2+1) = 2*(x+1)*x

(7)

e1/e3;

(x^2+1)/(x+1) = 2*x/(x+1)

(8)

e1^(1/2);

(x^2+1)^(1/2) = 2^(1/2)*x^(1/2)

(9)

 

Build-in functions do not work, though, but there is a simple solution.

exp(e1);

Error, invalid input: exp expects its 1st argument, x, to be of type algebraic, but received x^2+1 = 2*x

 

exp(rhs(e1))=exp(lhs(e1));

exp(2*x) = exp(x^2+1)

(10)

map(exp,e1);

exp(x^2+1) = exp(2*x)

(11)

 

The methods also apply to inequality formulae.  I'm not as pleased about how it does '*' and '/' for inequalities.  You can get more control using rhs and lhs functions.  Here are some examples:  

e4:=x^3<5*(x+1);

x^3 < 5*x+5

(12)

e4+e3;

x^3+x < 6*x+5

(13)

e4-e3;

x^3-x < 4*x+5

(14)

e4*e3;

(x^3 < 5*x+5)*(x+1)

(15)

e4/e3;

(x^3 < 5*x+5)*(1/(x+1))

(16)

eval(%,x=4);

64/5 < 5

(17)

evalb(%);

false

(18)

(16)/x^2;

((x^3 < 5*x+5)*(1/(x+1)))/x^2

(19)

simplify(%);

((x^3 < 5*x+5)*(1/(x+1)))/x^2

(20)

lhs(e4)/e3/x^2 < rhs(e4)/e3/x^2;

x/(x+1) < (5*x+5)/((x+1)*x^2)

(21)

simplify(%);

x/(x+1) < 5/x^2

(22)

 


 

Download equations.mw

I was reviewing the StringTools features and I'm curious about some parts of it.

(1)     Here is a section from the StringTools[Length] help topic:

Notice that, like length, the Length command counts the number of bytes in the string, not the number of characters.
Length("d303251cembre");
                               9
 
When I execute the command in Maple 2020, it actually returns 13 instead of 9.  The length command also returns 13.  I do not understand the information from StringTools[Length] help.  I looked back to Maple 18 and it did not include these lines in the help topic.
 
(2)   I am confused about the rng argument in StringTools commands of LowerCase, UpperCase and OtherCase.  It seems that these commands consider -2 as the last character in the string.  The help topic shows this:
 
UpperCase("abcdefghij", 3 .. -2);
                          "abCDEFGHIJ"
 
I'm expected to use -1 as the last character such as:
 
S:="This is a test";
S[-4..-1];
                       "test"
 
(3)  Next, I looked at StingTools[SubString].  The help topic gives the following example:
 
SubString("abcdef", -5 .. -3);
                             "bcd"
That works like I expected.  So, -1 is the last character for SubString.
 
Thanks,
Lee
 
Page 1 of 1