## 7260 Reputation

10 years, 205 days

## MaplePrimes Activity

### These are answers submitted by nm

subexp := sin(omega*t + alpha)*sin(omega*t + phi);
subexp2:= M__a*I__a*trigsubs(subexp)[1];

You can't solve the above since there is no equation. An equation must have a `=` in it and your's do not. May be this is why it did not work when you tried it?

If you can post an actuall differential equation, then I am sure Maple will be able to solve it, even if the diff was in the denominator.

For example

restart;
dsolve(y(t)/diff(y(t),t)=1)

gives

y(t) = _C1*exp(t)

in the example I would expect it to return exp(x).

Did you try to enter it in Maple?

sum(x^n/n!,n=0..infinity)

And Maple returns exp(x)

why can't you just write

a:=3;
plot(x, x = 0 .. a)

but if you do not want, you can try

f:=a->plot(x, x = 0 .. a);
f(3)

But if you do not want, you can try

restart;
eval('plot(x, x = 0 .. a)',a=3)

But if you do not want, you can try

restart;
simplify('plot(x, x = 0 .. a)',{a=3})

OP said

I found another solution I like:

use a=3 in plot(x, x=0..a) end use;

If you want to do the above, then you could also do

.....

proc()
local a=3;
plot(x,x=0..a);
end proc
()
.....

The above introduces local block inside you other functions and inside is only local to that block. Same as with use but I think is better.

I learned the above from Carl answer here https://www.mapleprimes.com/questions/201123-Can-One-Declare-Local-Variables-With

there is none. Even this, without the sqrt, has no anti-derivative

restart;
p :=1/(ln(t)^2 + t);
int(p,t)

restart;
f := Statistics:-RandomVariable(Normal(1,1/2)):
plot(Statistics:-PDF(f,t),t=-3..3);

ode:=m*diff(x(t),t\$2)+c*diff(x(t),t)+k*x(t)=F(t);
ic:=x(0)=1,D(x)(0)=0;
m:=1;c:=1/100;k:=10;
F:=t->Statistics:-PDF(f,t);
sol:=dsolve([ode,ic],x(t));

plot(rhs(sol),t=0..20)

where the expression would be M = 2Krst / w

one way could be

restart;
M:= 2*p*q*r*s*t /(u*v*w);
algsubs(p*q/(u*v)=k,M)

Another way

restart;
M:= 2*p*q*r*s*t /(u*v*w);
solve(p*q/(u*v)=k,p);
subs(p=%,M)

you really do not need Maple for this

Check using Maple:

ode:=diff(f(x),x)=f(x)^(-1);
dsolve(ode);

You mean code block?  You can do the following

This will open a window

Now type the code inside it, then click OK

That is all.  To edit the code again, repeate the above process.

Here is one way (need Maple 2020 for the Slice command)

A:=Matrix(3, 5, [[2, -6, 3, 0, 0], [5, -2, 4, 1, 2], [17, -4, 10, 20, 99]]);
ListTools:-Slice(convert(A^+,list),LinearAlgebra:-RowDimension(A))

Here is another way

convert~([seq(A[i],i=1..LinearAlgebra:-RowDimension(A))],list);

split_expr:=proc(expr::anything)
if type(expr,`+`) then
return convert(expr,list);
elif type(expr,`list`) then
return expr;
else
return [expr];
fi;
end proc;

create file data.csv  (ps. you have 6 variables actually not 5, but you can change this)

2,-6,3,0,0
5,-2,4,1,2
17,-4,10,20,99

Then write

restart;
currentdir("C:/tmp"); #where the data.csv file is
data := Import("data.csv"):
data := convert(data,Matrix):
nRows,nCols := LinearAlgebra:-Dimension(data);
for n from 1 to nRows do
unassign('a,h,b,f,g'):
assign~([a,h,b,f,g],convert(data[n],list)):
Conic:=a*x^2+2*h*x*y+b*y^2+2*f*x+2*g*y+c;
od;

I can't belive it! No Fourier Series in Maple!!! What a shame!

sorry, I didn't realize OP wanted solution using only Maple build-in commands and not using external package OrthogonalExpansions. Will try to find if I can find build-in Maple command to do this if possible.

default Digits is 10. As a rule, delay using machine numbers to the very end. So instead of

Iabcx := subs[eval]({a=1.0} , Iabc); replace with Iabcx := subs[eval]({a=1} , Iabc);

And at the very end, instead of doing

simplify(evalf(Ipnz))

You can do

Digits:=16;
simplify(evalf(Ipnz))

or

simplify(evalf[16](Ipnz))

both will give

But why do you want to do this in first place? Why not keep it symbolic:

simplify(Ipnz)

It looks better and more accurate since exact.

rmse_mlr:=proc(Full)
local i, sq, n, predicted;

sq:=0:
for i from 1 to n do
predicted:=subs([a=X[i,1],b=X[i,2],c=X[i,3],d=X[i,4]],Full);
sq:=sq+(Y[i]-predicted)^2;
end do:

return sqrt(sq/n);

end proc;

The call is rmse_mlr(FullEQN,X,Y);

The first thing to notice, is that you are calling it with 3 arguments, but it accepts only the first.

The second is that your loop is from 1 to n but there is no value given for anywhere.

I suggest your run lint on your code, and also use the debugger.  To use the debugger, so stopat(function_name);  and now when you invoke the function, the debugger will start. This way you can see what other problems you might have.

I also noticed you are doing convert(M,matrix) But are using LinearAlgebra. May be you should use Matrix. same for vector, change it to Vector

 5 6 7 8 9 10 11 Page 7 of 13
﻿