## 19 Badges

10 years, 253 days

## reply...

It seems due to build-in immediate simplifications.

a<=b and b>=a are immediately simplified to same thing and placed in same memory location before it reaches the set command.

addressof(a<=b)
36893490551756576564

addressof(b>=a)
36893490551756576564

But this is not the case for a=b and b=a. These remain internally as different objects in different memory locations

addressof(a=b)
36893490551757501180

addressof(b=a)
36893490551757501204



Also set does not do simplification either.

{a=b,2*a=2*b}

gives {a = b, 2*a = 2*b}  and not {a=b}

## reply...

I would use sprintf also myself, but an answer is given using that method.

You could also use StringTools to do all of this.

fix_number:=proc(n::numeric,k::posint,\$)
local L::list:=StringTools:-Split(String(n),".");
local s::string,s0::string,N::integer;

if nops(L)=1 then
RETURN(n);
fi;

if StringTools:-Length(L[2])>k then
L[2]:=L[2][1..k];
fi;

s:=StringTools:-Reverse(L[2]);
N:=0;
#count how many trailing zeros there are
for s0 in s  do
if s0="0" then
N:=N+1;
else
break;
fi;
od;
L[2]:=L[2][1..StringTools:-Length(L[2])-N];
RETURN(parse(cat(L[1],".",L[2])))

end proc:


The above takes in a number and does the conversion on it as needed. For example

Now to use this function simply map it on the matrix. Using given Matrix in the answer below to compare with:

A := Matrix(3,3, (i,j) -> 1.0/(i+j));
map(X->fix_number(X,4),A)


## reply...

expr:=a*b+c*(d+e)+f+g+h*(k*p+l)
[op(expr)]

I see now you said the input is string? In this case

expr:="a*b+c*(d+e)+f+g+h*(k*p+l)";
expr:=parse(expr);
map(X->String(X),[op(expr)])



If you do not like map, you can use ~

expr:="a*b+c*(d+e)+f+g+h*(k*p+l)";
expr:=parse(expr);
String~([op(expr)])


## reply...

In earlier versions of Maple 2023, it did not. Need to use convert to force the conversion

Compare to

## reply...

ps. converted your post to question.

To do what you want do the following

with(Student[Calculus1]):
res:=ShowSolution(Diff(ln(x),x));
latex(res)

Copy the latex output generated to your latex editor and put it inside $...$ to make the following file and then compile the file using either pdflatex or lualatex (need to install these on your PC. On Linux, use TexLive, on windows use MikeTex, the mac also has its own Latex, google it to find the right one to use).

\documentclass[12pt]{book}
\usepackage{amsmath}
\usepackage{hyperref}
\usepackage{maple}
\begin{document}
$%make sure to add this \begin{array}{ccc} & {} & \textrm{Differentiation Steps} \\ {} & {} & \frac{d}{d x}\ln \! \left(x \right) \\ \textrm{▫} & {} & \textrm{1. Apply the}\textrm{natural logarithm}\textrm{rule} \\ {} & \textrm{◦} & \textrm{Recall the definition of the}\textrm{natural logarithm}\textrm{rule} \\ {} & {} & \frac{d}{d x}\ln \! \left(x \right)=\frac{1}{x} \\ & {} & \textrm{This gives:} \\ {} & {} & \frac{1}{x} \end{array}$%make sure to add this

\end{document}


Which will give

Since you are running this from command line, you can't really save worksheet as Latex. But you can simply modify your .mpl to automatically do the above. i,e. generate the latex, save the latex to a latex file, then at the end, just add a compile command to your script to compile the latex to pdf. If you also call tex4ht, you can also convert it to HTML.

 > with(Student[Calculus1]): res:=ShowSolution(Diff(ln(x),x));

 > latex(res)

\begin{array}{ccc}
& {} & \textrm{Differentiation Steps}
\\
{} & {} & \frac{d}{d x}\ln \! \left(x \right)
\\
\textrm{▫} & {} & \textrm{1. Apply the}\textrm{natural logarithm}\textrm{rule}
\\
{} & \textrm{◦} & \textrm{Recall the definition of the}\textrm{natural logarithm}\textrm{rule}
\\
{} & {} & \frac{d}{d x}\ln \! \left(x \right)=\frac{1}{x}
\\
& {} & \textrm{This gives:}
\\
{} & {} & \frac{1}{x}
\end{array}

 >

Download convert_steps_to_latex.mw

## reply...

It should return k1

Try

restart;
fa := unapply(piecewise(0 < x and x < a, k1, a < x and x < b, k2), x):
simplify(fa(x),assume=[0 < x,x < a])


## reply...

in worksheet, the command I use is

interface(rtablesize=30);

to make it show 30 rows. You can changes this as needed. I do not know if this works in document mode or Maple learn and other environments. It works for me in worksheet mode.

## reply...

two possible ways. If you want the result to have the variable name in it, use PDEtools:-Solve(). If you just want the value itself, use solve().

restart;

eq:=(3*y - 2)/3 + (2*y + 3)/3 = (y + 7)/6
solve(eq,y)
PDEtools:-Solve(eq,y)


## reply...

seq(if(L[i,1]="H",i,NULL),i=1..nops(L));
{%}

## reply...

expr:=(4*n-1)/9-7/16*n;
latex(expr);

\frac{\left(4 n -1\right)}{9}-\frac{7 n}{16}

To remove the  use expand()

expand(expr)

n/144 - 1/9

## reply...

b := exp(-I*varphi)*sin(theta/2)*cos(theta/2) + cos(theta/2)*exp(I*varphi)*sin(theta/2);
evalc(combine(b));


## reply...

Only for -Pi/2<=x and x<=Pi/2

evalb(simplify(arcsin(sin(x)) = sin(arcsin(x)))) assuming -Pi/2<=x and x<=Pi/2

true

## reply...

data:=ssystem("systeminfo"):
data[2];

Issue similar command for Linux and mac.

## reply...

Is there a simple way to do that without having examine the plots?

May be there is a build in way to this using using DynamicSystems (i.e. give it transfer function and omega (rad/sec), and it gives back the gain in db unit at that frequency).

I do not know now.  I do not use DS very much these days.

But you could always just apply the definition of the gain itself. Given TF = f(s), just replace s by I*w and find the absolute value at the specific w you want, then do 20*log10 of he result. This gives the gain in db at that specific w.  Here is an example

restart;
DS:=DynamicSystems;
sys:=s/(s^2+s+1);
tf:=DS:-TransferFunction(sys):
fr:=DS:-FrequencyResponseSystem(tf);
DS:-MagnitudePlot(fr)


Let us verify by evaluating the gain in db at say w=0.1 and w=0.2 and w=0.6 and w=1 to see if we get same result as show in the above

sysI:=eval(sys,s=I*w):
mag:=abs(eval(sysI,w=0.1)):
20*log10(mag);

mag:=abs(eval(sysI,w=0.2)):
20*log10(mag);

mag:=abs(eval(sysI,w=0.6)):
20*log10(mag);

mag:=abs(eval(sysI,w=1)):
20*log10(mag);


which gives

Which matches the plot.

You can make small function and put the above code in it. somethging like

restart; #we do not need DS
getGainAtFreq:=proc(sys,s::symbol,w)
eval(sys,s=I*w):
abs(eval(%,w=0.1)):
20*log10(%);
end proc:



And now do

sys:=s/(s^2+s+1);

getGainAtFreq(sys,s,0.1);
getGainAtFreq(sys,s,0.2);
getGainAtFreq(sys,s,0.6);


## reply...

If numbers have no decimal points, as you show in your example, then one possibility might be to convert it to string and get the length.

number:=22;
number_binary:=convert(number,binary);
length(String(number_binary))

5

does Maple not have build in functions to do this similar to these in Mathematica? https://reference.wolfram.com/language/ref/IntegerDigits.html  it probably does but I could not find them searching. May be they are in some package.

 1 2 3 4 5 6 7 Last Page 1 of 14
﻿