# How to call a built function in mathematica

• Reem Hashem

#### Reem Hashem

Hello,I need somebody to help me in Mathematica programm
I wrote code that works as a function which I can call when I need in another function, but it did not work ,so I need help how to call my function

#### Attachments

• Untitled-1.nb
35.5 KB · Views: 360
Your code is much too complicated. You need to break it down into simpler steps, and then try it on simpler examples, to find where the error lies.

In:= tmp[a_, z_, w_] := Module[{m, f, d, b},
m = NDSolve[{
y1'[t] == y5[t], y2'[t] == y6[t], y3'[t] == y7[t], y4'[t] == y8[t],
y5'[t] == y9[t], y6'[t] == y10[t], y7'[t] == y11[t], y8'[t] == y12[t],
y9'[t] == y13[t], y10'[t] == y14[t], y11'[t] == y15[t], y12'[t] == y16[t],
y13'[t] == -z^4 y1[t] + 2 z^2 y9[t] + z^2 w (-t + t^2) y17[t] + a y9[t],
y14'[t] == -z^4 y2[t] + 2 z^2 y10[t] + z^2 w (-t + t^2) y18[t] + a y10[t],
y15'[t] == -z^4 y3[t] + 2 z^2 y11[t] + z^2 w (-t + t^2) y19[t] + a y11[t],
y16'[t] == -z^4 y4[t] + 2 z^2 y12[t] + z^2 w (-t + t^2) y20[t] + a y12[t],
y17'[t] == y21[t], y18'[t] == y22[t], y19'[t] == y23[t], y20'[t] == y24[t],
y21'[t] == (-1 + 2 t) y1[t] + z^2 y17[t] - a y29[t],
y22'[t] == (-1 + 2 t) y2[t] + z^2 y18[t] - a y30[t],
y23'[t] == (-1 + 2 t) y3[t] + z^2 y19[t] - a y31[t],
y24'[t] == (-1 + 2 t) y4[t] + z^2 y20[t] - a y32[t],
y25'[t] == y29[t], y26'[t] == y30[t], y27'[t] == y31[t], y28'[t] == y32[t],
y29'[t] == -y21[t] + z^2 y25[t], y30'[t] == -y22[t] + z^2 y26[t],
y31'[t] == -y23[t] + z^2 y27[t], y32'[t] == -y24[t] + z^2 y28[t],
y1 == y2 == y3 == y4 == y5 == y6 == y7 == y8 ==
y10 == y11 == y12 == y13 == y15 == y16 == y17 ==
y18 == y19 == y20 == y21 == y22 == y24 == y25 ==
y26 == y27 == y28 == y29 == y30 == y31 == 0,
y9 == y14 == y23 == y32 == 1}, {y1, y2, y3, y4, y5,
y6, y7, y8, y9, y10, y11, y12, y13, y14, y15, y16, y17, y18,
y19, y20, y21, y22, y23, y24, y25, y26, y27, y28, y29, y30, y31,
y32}, {t, 0, 1}];
f[1, 1] = y1 /. m;
f[1, 2] = y2 /. m;
f[1, 3] = y3 /. m;
f[1, 4] = y4 /. m;
f[2, 1] = y5 /. m;
f[2, 2] = y6 /. m;
f[2, 3] = y7 /. m;
f[2, 4] = y8 /. m;
f[3, 1] = y17 /. m;
f[3, 2] = y18 /. m;
f[3, 3] = y19 /. m;
f[3, 4] = y20 /. m;
f[4, 1] = y25 /. m;
f[4, 2] = y26 /. m;
f[4, 3] = y27 /. m;
f[4, 4] = y28 /. m;
d = Array[f, {4, 4}];
d = Partition[Flatten[d], 4];
b = Det[d]];
tmp[0, 3.7, 1000]

Out= 15.7127

Thank you Mr Bill for your Help ,this what I need,but now I want to know how to call this function in FindRoot function to get the value of w,I tried to do it but it did not work,I wort FindRoot[temp[0,3.7,w_],{w,1000,100000}]

You will have a lot less trouble trying to write Mathematica if you understand how to use and not use the _ in your code.

This might help.
http://reference.wolfram.com/mathematica/tutorial/DefiningFunctions.html

This
Plot[tmp[0, 3.7, w], {w, 1000, 100000}]