## 9718 Reputation

12 years, 61 days

## MaplePrimes Activity

### These are answers submitted by nm

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.

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)
```

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

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

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

Issue similar command for Linux and mac.

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);
```

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)

```S:={{a,b},{a,b,c},{b,c},{c}};
select(Z->member(a,Z),S)
```

2)

```X:=[a,b,c];
cartProdSeq:= proc(L::seq(list))
local Seq::nothing,i::nothing,j;
eval([subs(Seq= seq, foldl(Seq, [cat(i, 1..nargs)],
seq(cat(i,j)= L[j], j= nargs..1, -1)))])
end proc:
cartProdSeq(X,X);
select(Z->member(a,Z) and member(b,Z),%)
```

Need to tell it from where you are approaching 0

`limit( log(x)/x,x=0,right)`

There are many ways,. Here are two

 > restart;
 > ode:=diff(y(x),x\$2)+diff(y(x),x)+y(x)=0; sol:=dsolve(ode);

 > diff(rhs(sol),x)

 > sol := unapply(rhs(sol),x);

 > diff(sol(x),x)

 > diff(sol(x),x\$2)

 >

You can also make y(x) itself a function. But I think it is better to use sol and keep y as free variable.

 > restart;
 > ode:=diff(y(x),x\$2)+diff(y(x),x)+y(x)=0; sol:=dsolve(ode);

 > y := unapply(rhs(sol),x); diff(y(x),x)

 >

looks like numerical issue. Try

```restart;
sol:=[solve((20 + 20*T + 2*T*(T + 1))*exp(-T) - 10*exp(-2*T) - 2*T - 10 = 0,T)];
evalf~(sol)
```

Gives

[-10.0000000000, -0.0000000000]

PDEtools gives just zero as answer

```restart;
sol:=PDEtools:-Solve((20 + 20*T + 2*T*(T + 1))*exp(-T) - 10*exp(-2*T) - 2*T - 10 = 0,T);
evalf(sol)
```

This is hard to solve exactly, so use root finder

```restart;
eq:=(20 + 20*T + 2*T*(T + 1))*exp(-T) - 10*exp(-2*T) - 2*T - 10 = 0;
Student:-Calculus1:-Roots(eq, 0..2);

```

[0, 1.4114548230]

Maple 2022.1 on windows 10.

Try to see if this works for you.   Maple 2022.1

```restart;
with(Statistics):
with(stats):
y_a:=t->piecewise(0<=t and t<=1,DynamicSystems:-Sine(1.5*t,10*Pi,0,0),1<=t and t<=2,DynamicSystems:-Sine(1.5*(2-t),10*Pi,0,0));
plot(y_a(t),t=0..2);
mu:=t->statevalf[pdf,normald[1,2*4.47]](t);
plot(mu(t),t=0..2);
y:=t->y_a(t)+mu(t);
plot(y(t),t=0..2)
```

type

`ssystem("powershell.exe get-process")`

 > restart;
 > ode:=diff(y(x),x\$2)+ 4*diff(y(x),x) + 4*y(x) = sin(x); ic:=y(0) = 1 , D(y)(0)=0; sol_analytic:=dsolve([ode,ic]); sol_numeric:=dsolve([ode,ic], numeric, method = gear,output=listprocedure): sol_numeric := eval(y(x),sol_numeric):

 > p1:=plot(rhs(sol_analytic),x=0..10,title="analytic",gridlines,color=blue):
 > p2:=plot(sol_numeric(x),x=0..10,title="numerical",gridlines,color=red):
 > [p1,p2]

 >

feel free to make improvements as needed

```restart;
y := x-> a*x^3 + b*x^2 + c*x + d:
pts:=[[-1,-4],[1,0],[2,0],[3,-4]]:
eqs:=[seq(y(pts[i,1])=pts[i,2],i=1..numelems(pts))];
sol:=solve(eqs,{a,b,c,d}):
equation_of_curve:=eval(y(x),sol);
plots:-display(plot(equation_of_curve,x=-4..4,gridlines),plots:-pointplot(pts,color=blue,symbol=solidcircle,symbolsize=20))
```

 2 3 4 5 6 7 8 Last Page 4 of 16
﻿