Message Boards Message Boards

0
|
6806 Views
|
7 Replies
|
1 Total Likes
View groups...
Share
Share this post:

How do I define this function with the WL? b[a_ , t_] := a'[t] Sin[a[t]];

Posted 10 years ago

Hi dears does anyone know what is the problem when i define this function in mathematica?

b[a_ ,  t_] := a'[t] Sin[a[t]];

it gives : SetDelayed::write: Tag Times in (sin'[a[t]] a'[t])[a_ ,t_] is Protected. >>

i want to define a function containing variables and their derivatives ! help me please :)

POSTED BY: Amir Arshia
7 Replies
Posted 10 years ago

Dears most recently i encountered with another problem in mathematica NDSolve i had defined some equations "lagrangeo1" ,"lagrangei1", and "lagrangei2" that are differential equations. but when started to solve:

lagrangesolve = NDSolve[{lagrangei1 == 0, lagrangei2 == 0, lagrangeo1 == 0,o1[0] == -36,i1[0] ==18,i2[0] == 18, o1'[0] == 0.5, i1'[0] == 0,i2'[0] == -0.75}, {o1, i1, i2}, {t, 0, 100}]

(o1,i1,i2 are my variables) it said :

NDSolve::ndsdtc: The time constraint of 1.` seconds was exceeded trying to solve for derivatives, so the system will be treated as a system of differential-algebraic equations. You can use Method->{"EquationSimplification"->"Solve"} to have the system solved as ordinary differential equations. >> NDSolve::njnum: The Jacobian is not a matrix of numbers at ... ... General::stop: Further output of NDSolve::njnum will be suppressed during this calculation. >> NDSolve::icfail: Unable to find initial conditions that satisfy the residual function within specified tolerances. Try giving initial conditions for both values and derivatives of the functions. >>

will be glad if anyone could help me. regards

POSTED BY: Amir Arshia

It looks to me like you have previously defined b to be something else. Try clearing the variables a, b, t before defining the function.

The main clue that this is happening is they the error message uses sin (with lower case 's') so it looks like b was defined as (sin'[a[t]] a'[t]) and that is substituted into your function definition. Since this is right next to [a, t], Mathematica is trying to do an implicit multiplication.

I can enter your function without error on my system (MMa 10.1, OS X) in a fresh notebook.

Posted 10 years ago

Thank you George now it works correctly

POSTED BY: Amir Arshia
Posted 10 years ago

Dear George most recently i encountered with another problem in mathematica NDSolve i had defined some equations "lagrangeo1" ,"lagrangei1", and "lagrangei2" that are differential equations. but when started to solve:

lagrangesolve = NDSolve[{lagrangei1 == 0, lagrangei2 == 0, lagrangeo1 == 0,o1[0] == -36,i1[0] ==18,i2[0] == 18, o1'[0] == 0.5, i1'[0] == 0,i2'[0] == -0.75}, {o1, i1, i2}, {t, 0, 100}]

(o1,i1,i2 are my variables) it said :

NDSolve::ndsdtc: The time constraint of 1.` seconds was exceeded trying to solve for derivatives, so the system will be treated as a system of differential-algebraic equations. You can use Method->{"EquationSimplification"->"Solve"} to have the system solved as ordinary differential equations. >> NDSolve::njnum: The Jacobian is not a matrix of numbers at ... ... General::stop: Further output of NDSolve::njnum will be suppressed during this calculation. >> NDSolve::icfail: Unable to find initial conditions that satisfy the residual function within specified tolerances. Try giving initial conditions for both values and derivatives of the functions. >>

will be glad if you could help me again. regards

POSTED BY: Amir Arshia

Hi Amir,

most likely you first executed

b := a'[t] Sin[a[t]]

and then the correct definition

b[a_, t_] := a'[t] Sin[a[t]]

Do a clean start or at least execute

ClearAll[b]

then it will work.

Regards Henrik

POSTED BY: Henrik Schachner
Posted 10 years ago

Thank you Henrik now it works correctly

POSTED BY: Amir Arshia
Posted 10 years ago

Dear Henrik most recently i encountered with another problem in mathematica NDSolve i had defined some equations "lagrangeo1" ,"lagrangei1", and "lagrangei2" that are differential equations. but when started to solve:

lagrangesolve = NDSolve[{lagrangei1 == 0, lagrangei2 == 0, lagrangeo1 == 0,o1[0] == -36,i1[0] ==18,i2[0] == 18, o1'[0] == 0.5, i1'[0] == 0,i2'[0] == -0.75}, {o1, i1, i2}, {t, 0, 100}]

(o1,i1,i2 are my variables) it said :

NDSolve::ndsdtc: The time constraint of 1.` seconds was exceeded trying to solve for derivatives, so the system will be treated as a system of differential-algebraic equations. You can use Method->{"EquationSimplification"->"Solve"} to have the system solved as ordinary differential equations. >> NDSolve::njnum: The Jacobian is not a matrix of numbers at ... ... General::stop: Further output of NDSolve::njnum will be suppressed during this calculation. >> NDSolve::icfail: Unable to find initial conditions that satisfy the residual function within specified tolerances. Try giving initial conditions for both values and derivatives of the functions. >>

will be glad if you could help me again. regards

POSTED BY: Amir Arshia
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract