# Question:How do I solve invalid input in the proc?

## Question:How do I solve invalid input in the proc?

Hey,

i have 2 differential equations and want to solve the first one when x is positive and the second when x ist negativ. For this problem i wrote the follwing procedure. But when i try i have the posted error. Has someone a good idea to help me?

Thanks a lot

> DGL3 := 10*(D(D(x)))(t) = x(t);

> DGL4 := 10*(D(D(x)))(t)+5000 = x(t);

Tsolver:=proc()
global DG1, DG2, func, var, var_min, var_max, x, Dx, N:
global dt, F1, DF1, ti, i:
DG1:=args[1]:
DG2:=args[2]:
func:=args[3]:
var:=op(1, args[4]):
var_min:=op(1, op(2, args[4])):
var_max:=op(2, op(2, args[4])):
x[0]:=args[5]:
Dx[0]:=args[6]:
N:=args[7]:
dt:=(var_max-var_min)/N:
i:=0:

for ti from var_min by dt to var_max
do i:=i+1:
if x[i-1]>0
then
F1:=dsolve({DG1, func = x[i-1], diff(func, var) = Dx[i-1]}, numeric):
x[i]:=F1(ti):
DF1:=diff(F1, var):
Dx[x-i]:=DF1(ti):

else

F1:=dsolve({DG2, func = x[i-1], diff(func, var) = Dx[i-1]}, numeric):
x[i]:=F1(ti):
DF1:=diff(F1, var):
Dx[x-i]:=DF1(ti):
fi:
od:
end;

And this is the problem when i try to use this procedure:

> debug(Tsolver);
print(`output redirected...`); # input placeholder
Tsolver
> A := Tsolver(DGL3, DGL4, x(t), t = 0 .. 4, .2, .196, 60);
%;
{--> enter Tsolver, args = 10*((D@@2)(x))(t) = (table( [( 0 ) = .2 ] ))(t), 10*((D@@2)(x))(t)+5000 = (table( [( 0 ) = .2 ] ))(t), (table( [( 0 ) = .2 ] ))(t), t = 0 .. 4, .2, .196, 60
10 @@(D, 2)(x)(t) = ()(t)
10 @@(D, 2)(x)(t) + 5000 = ()(t)
()(t)
t
0
4
0.2
20.00000000
0
1
<-- ERROR in Tsolver (now at top level) = invalid input: %1 expects its %-2 argument, %3, to be of type %4, but received %5}
Error, (in unknown) invalid input: `dsolve/numeric/lexorder` expects its 2nd argument, b, to be of type {indexed, name, numeric}, but received table( [( 0 ) = .2 ] )

﻿