## 13100 Reputation

18 years, 301 days

## Without actually seeing the...

Without actually seeing the system I don't have any other suggestions than the following.

Introduce g1 and g2 as new unknowns, so that the integration of f1 and f2 are done by dsolve directly.

restart;
sys:=diff(f1(t),t)=piecewise(t<=4,3*exp(-2*t),-1),diff(f2(t),t)=sin(t),diff(g1(t),t)=f1(t),diff(g2(t),t)=f2(t);
init:= f1(0)=1, f2(0)=1,g1(0)=0,g2(0)=0:
F:=dsolve({sys,init}, {f1(t), f2(t),g1(t),g2(t)}, numeric,output=listprocedure);
F1,F2,G1,G2:=op(subs(F,[f1(t),f2(t),g1(t),g2(t)]));
G2(5.5)/G1(5.5);

Preben Alsholm

## Without actually seeing the...

Without actually seeing the system I don't have any other suggestions than the following.

Introduce g1 and g2 as new unknowns, so that the integration of f1 and f2 are done by dsolve directly.

restart;
sys:=diff(f1(t),t)=piecewise(t<=4,3*exp(-2*t),-1),diff(f2(t),t)=sin(t),diff(g1(t),t)=f1(t),diff(g2(t),t)=f2(t);
init:= f1(0)=1, f2(0)=1,g1(0)=0,g2(0)=0:
F:=dsolve({sys,init}, {f1(t), f2(t),g1(t),g2(t)}, numeric,output=listprocedure);
F1,F2,G1,G2:=op(subs(F,[f1(t),f2(t),g1(t),g2(t)]));
G2(5.5)/G1(5.5);

Preben Alsholm

## fnormal followed by simplify...

You may also want to remove terms of the form 0.*I by using simplify:

s^5+3.236067976*s^4+(1.*10^(-10)*I)*s^4+5.236067975*s^3+(7.*10^(-10)*I)*s^3-(3.*10^(-10)*I)*s+5.236067975*s^2+3.236067977*s+1.000000000 :
fnormal(%);
simplify(%);

Preben Alsholm

## fnormal followed by simplify...

You may also want to remove terms of the form 0.*I by using simplify:

s^5+3.236067976*s^4+(1.*10^(-10)*I)*s^4+5.236067975*s^3+(7.*10^(-10)*I)*s^3-(3.*10^(-10)*I)*s+5.236067975*s^2+3.236067977*s+1.000000000 :
fnormal(%);
simplify(%);

Preben Alsholm

## subs...

I never use algsubs, but very often use subs and eval. They are both extremely useful, both in their own way.

I suppose algsubs has disappointed me in the past. I don't know if it has gotten better, since I don't use it.

Preben Alsholm

## subs...

I never use algsubs, but very often use subs and eval. They are both extremely useful, both in their own way.

I suppose algsubs has disappointed me in the past. I don't know if it has gotten better, since I don't use it.

Preben Alsholm

## An index is needed...

Well, since the output has to be a sum you need an index, just like a definite integral needs an integration variable.

That index could have been made local by the procedure that produced the sum. However, then you wouldn't have immediate access to it.

Preben Alsholm

## An index is needed...

Well, since the output has to be a sum you need an index, just like a definite integral needs an integration variable.

That index could have been made local by the procedure that produced the sum. However, then you wouldn't have immediate access to it.

Preben Alsholm

## Need the whole thing...

Are you defining Res as I did?

Did you execute all lines previous to the ones mentioned last?

Preben Alsholm

## Need the whole thing...

Are you defining Res as I did?

Did you execute all lines previous to the ones mentioned last?

Preben Alsholm

## optimalitytolerance can be set...

You may try setting optimalitytolerance:

res:=LSSolve(Res,{x1<=1,x2<=1,x3<=1,x4<=1,x5<=1,x6<=1,x7<=1,x8<=1,x9<=1,x10<=1,T>=Ti},assume=nonnegative,iterationlimit=5000,optimalitytolerance=0.0001);
[0.00517923021408238112, [T = 2782.09143970567812, n = 10.1585637591277820,

x1 = 0.00872658980230692216, x10 = 0.0748602181855385214,

x2 = 0.0766666505398920090, x3 = 0.579521666596851892,

x4 = 0.0000115210794556045040, x5 = 0.0901704459988488805,

x6 = 0.0852556575745576917, x7 = 0.00577381343641316520,

x8 = 0.00427475756541988076, x9 = 0.0642723480725257840]]

See the help page: ?Optimization, Options

Preben Alsholm

## optimalitytolerance can be set...

You may try setting optimalitytolerance:

res:=LSSolve(Res,{x1<=1,x2<=1,x3<=1,x4<=1,x5<=1,x6<=1,x7<=1,x8<=1,x9<=1,x10<=1,T>=Ti},assume=nonnegative,iterationlimit=5000,optimalitytolerance=0.0001);
[0.00517923021408238112, [T = 2782.09143970567812, n = 10.1585637591277820,

x1 = 0.00872658980230692216, x10 = 0.0748602181855385214,

x2 = 0.0766666505398920090, x3 = 0.579521666596851892,

x4 = 0.0000115210794556045040, x5 = 0.0901704459988488805,

x6 = 0.0852556575745576917, x7 = 0.00577381343641316520,

x8 = 0.00427475756541988076, x9 = 0.0642723480725257840]]

See the help page: ?Optimization, Options

Preben Alsholm

## Scaling...

You may also want to scale the equations.

Here I have scaled the last one:

Res:=map(lhs-rhs,[eq1, eq2,eq3,eq4,eq5,eq6,eq7,eq8,eq9,eq10,eq11,eq12*10^(-2)]):
res:=LSSolve(Res,{x1<=1,x2<=1,x3<=1,x4<=1,x5<=1,x6<=1,x7<=1,x8<=1,x9<=1,x10<=1,T>=Ti},assume=nonnegative,iterationlimit=5000);
Warning, limiting number of major iterations has been reached
[0.00517609062184478092, [T = 2782.44660329790214, n = 10.1582899935774478,

x1 = 0.00873618614514319950, x10 = 0.0748388854712784686,

x2 = 0.0767030979399348362, x3 = 0.579548942356043040,

x4 = 0.0000115713864132603826, x5 = 0.0901633563755876583,

x6 = 0.0852311188569541273, x7 = 0.00577787937886131958,

x8 = 0.00427369013816442536, x9 = 0.0642550496232529162]]

Preben Alsholm

## Scaling...

You may also want to scale the equations.

Here I have scaled the last one:

Res:=map(lhs-rhs,[eq1, eq2,eq3,eq4,eq5,eq6,eq7,eq8,eq9,eq10,eq11,eq12*10^(-2)]):
res:=LSSolve(Res,{x1<=1,x2<=1,x3<=1,x4<=1,x5<=1,x6<=1,x7<=1,x8<=1,x9<=1,x10<=1,T>=Ti},assume=nonnegative,iterationlimit=5000);
Warning, limiting number of major iterations has been reached
[0.00517609062184478092, [T = 2782.44660329790214, n = 10.1582899935774478,

x1 = 0.00873618614514319950, x10 = 0.0748388854712784686,

x2 = 0.0767030979399348362, x3 = 0.579548942356043040,

x4 = 0.0000115713864132603826, x5 = 0.0901633563755876583,

x6 = 0.0852311188569541273, x7 = 0.00577787937886131958,

x8 = 0.00427369013816442536, x9 = 0.0642550496232529162]]

Preben Alsholm

## Interesting!...

This is interesting.

I think op(RS1S) should be op([1,1..-1],RS1S).

Preben Alsholm

 First 213 214 215 216 217 218 219 Page 215 of 219
﻿