pl help(adsbygoogle = window.adsbygoogle || []).push({});

Here I have written a mathematica code. It is a small example of my actual problem. In this code, 't' is an arbitrary constant which is being fixed at the top of the programme by assigning a value. All the other variables 'a','b','c' depend upon 't' . and 'h1','h2' are the roots of quadratic equation with coefficients a,b,c.

Further, 'f' is a function in an unknown variable 'p' and involves 'h1' and 'h2'.. We can determine 'p' by solving f(p)=0, giving two roots. Finally I calculated 'v' from the from assigned 't' and calculated second root of equation f(p)=0.

Thus 'v' depends upon 't' both explicitly and implicitly.. With change in 't', "v" will change. I want to draw a graph between 't' and 'v'.. For this I need looping or some other command to assign different values to 't' at the top of the programme.. Me unable to do that.. Pl if possible , help me in this regard

t := 3

a := t^2

b := (t + 1)*I

c := t^2 + 2*t*I + 1

h1 = (-b + Sqrt[b^2 - 4*a*c])/(2*a)

h2 = (-b - Sqrt[b^2 - 4*a*c])/(2*a)

a11 := Sqrt[p]*h1

a12 := h1*2

a21 := 3*h2^2

a22 := 4 + p

f[p_] = a11*a22 - a21*a12

h = sols = NSolve[f[p] == 0, p]

d = p /. sols[[2]]

v = t/Re[d]

Suppose I want to calculate my final answer for ten values of 't' (say 1,2,3.....10) and finally to plot a graph between the final values of 'v' and the ten assigned values for 't'. I have tried a lot in this regard and have defined a function, used array and table commands too.. But unable to pick those ten values by my for loop command and to draw graph...

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Mathematica looping

**Physics Forums | Science Articles, Homework Help, Discussion**