Preben Alsholm

MaplePrimes Activity


These are replies submitted by Preben Alsholm

@nic_rf Well, then f(t) = 1-exp(-t) is the solution. The laplace transform method using f(0) = 0 gave two possible solutions, but with f ' (0) > 0 one is singled out, i.e. f(t) = 1-exp(-t).

@nic_rf Well, then f(t) = 1-exp(-t) is the solution. The laplace transform method using f(0) = 0 gave two possible solutions, but with f ' (0) > 0 one is singled out, i.e. f(t) = 1-exp(-t).

@PatrickT You can make use of 'satisfies' as in

RNN(M,1,'satisfies'(s->s::realcons and s>0 and s<30));

if you change RNN to accept as the third argument either a regular type or the special function 'satisfies'.

(This is still not perfect, since combining those two with And, Or, or Not won't work).

RNN:= proc(M::{Array,Matrix},k::posint, t::{type,specfunc(procedure,satisfies)}:=numeric,$)
  local U,d,i,dk;
  d:= [rtable_dims(M)];
  U:= remove(r -> hastype(M[op(subsop(k=r,d))],Not(t),'exclude_container'),[seq(i,i=d[k])]);
  M[op(subsop(k=U,d))]
end proc;

@PatrickT You can make use of 'satisfies' as in

RNN(M,1,'satisfies'(s->s::realcons and s>0 and s<30));

if you change RNN to accept as the third argument either a regular type or the special function 'satisfies'.

(This is still not perfect, since combining those two with And, Or, or Not won't work).

RNN:= proc(M::{Array,Matrix},k::posint, t::{type,specfunc(procedure,satisfies)}:=numeric,$)
  local U,d,i,dk;
  d:= [rtable_dims(M)];
  U:= remove(r -> hastype(M[op(subsop(k=r,d))],Not(t),'exclude_container'),[seq(i,i=d[k])]);
  M[op(subsop(k=U,d))]
end proc;

@PatrickT Type real doesn't exist, so in the call

RNN(M,1,real);

RNN will use the default type, i.e. numeric.   RNN(M,1,xxx); has the same effect.

In order to catch such user errors you could place a dollar sign at the end of the sequence of formal parameters, indicating thereby that no other arguments are allowed. Alternatively the third argument t::type could be made required.

RNN:= proc(M::{Array,Matrix},k::posint, t::type:=numeric,$)
  local U,d,i,dk;
  d:= [rtable_dims(M)];
  U:= remove(r -> hastype(M[op(subsop(k=r,d))],Not(t),'exclude_container'),[seq(i,i=d[k])]);
  M[op(subsop(k=U,d))]
end proc;

@PatrickT Type real doesn't exist, so in the call

RNN(M,1,real);

RNN will use the default type, i.e. numeric.   RNN(M,1,xxx); has the same effect.

In order to catch such user errors you could place a dollar sign at the end of the sequence of formal parameters, indicating thereby that no other arguments are allowed. Alternatively the third argument t::type could be made required.

RNN:= proc(M::{Array,Matrix},k::posint, t::type:=numeric,$)
  local U,d,i,dk;
  d:= [rtable_dims(M)];
  U:= remove(r -> hastype(M[op(subsop(k=r,d))],Not(t),'exclude_container'),[seq(i,i=d[k])]);
  M[op(subsop(k=U,d))]
end proc;

@PatrickT Here is a way.

M:=Matrix([[HFloat(undefined),HFloat(undefined),HFloat(undefined)],[1,2,3],[HFloat(undefined),HFloat(undefined),HFloat(undefined)],[4,5,6]]);
m:=LinearAlgebra:-RowDimension(M):
U:=NULL:
for i to m do
   if has(LinearAlgebra:-Row(M,i),HFloat(undefined)) then U:=U,i end if
end do;
U;
LinearAlgebra:-DeleteRow(M,[U]);

@PatrickT Here is a way.

M:=Matrix([[HFloat(undefined),HFloat(undefined),HFloat(undefined)],[1,2,3],[HFloat(undefined),HFloat(undefined),HFloat(undefined)],[4,5,6]]);
m:=LinearAlgebra:-RowDimension(M):
U:=NULL:
for i to m do
   if has(LinearAlgebra:-Row(M,i),HFloat(undefined)) then U:=U,i end if
end do;
U;
LinearAlgebra:-DeleteRow(M,[U]);

It seems to me that a lot of the people reporting this problem are Danes (so am I). Is that a coincidence or what?

I haven't had that kind of problem for a very long time, maybe because I (almost) always remove all output before saving.

It seems to me that a lot of the people reporting this problem are Danes (so am I). Is that a coincidence or what?

I haven't had that kind of problem for a very long time, maybe because I (almost) always remove all output before saving.

LeastSquares work if B is converted to rational.

Bex:=convert(B,rational);
GaussianElimination(<A|Bex>);
Yp:=LeastSquares(A, Bex,free=t);
Norm(A.Yp-Bex,2);
Y:=LeastSquares(A, Bex,optimize);
Norm(A.Y-Bex,2);
evalf(%);

#Compare with your result from DirectSearch:

Yds:=<.899555775576182, .897427164193849, .896594849107632, .899558830317534>;
Norm(A.Yds-B,2);

LeastSquares work if B is converted to rational.

Bex:=convert(B,rational);
GaussianElimination(<A|Bex>);
Yp:=LeastSquares(A, Bex,free=t);
Norm(A.Yp-Bex,2);
Y:=LeastSquares(A, Bex,optimize);
Norm(A.Y-Bex,2);
evalf(%);

#Compare with your result from DirectSearch:

Yds:=<.899555775576182, .897427164193849, .896594849107632, .899558830317534>;
Norm(A.Yds-B,2);

@k4walker You are right. However, I did get 0 when I tried, but that must have been due to the fact that the order of the solutions is not guaranteed to be the same each time. So now I tried:

myDeterminant := (1/2)*l[4]*l[1]*(l[4]*cos(x[2]-2*x[3])+l[4]*cos(x[2])-l[1]*sin(2*x[2]-x[3])-l[1]*sin(x[3]));
solutions := solve(myDeterminant = 0);
eval~(myDeterminant,[solutions]);
simplify(%);
expand(%);
simplify(%);

From this we see that 5 of the 6 solutions found are correct.

@k4walker You are right. However, I did get 0 when I tried, but that must have been due to the fact that the order of the solutions is not guaranteed to be the same each time. So now I tried:

myDeterminant := (1/2)*l[4]*l[1]*(l[4]*cos(x[2]-2*x[3])+l[4]*cos(x[2])-l[1]*sin(2*x[2]-x[3])-l[1]*sin(x[3]));
solutions := solve(myDeterminant = 0);
eval~(myDeterminant,[solutions]);
simplify(%);
expand(%);
simplify(%);

From this we see that 5 of the 6 solutions found are correct.

First 203 204 205 206 207 208 209 Last Page 205 of 231