Skip to main content
added 43 characters in body
Source Link
Dr. belisarius
  • 116.2k
  • 13
  • 205
  • 456

I'm trying to optimize some kind of process in Mathematica. I did it without any problems in Matlab and now I'm trying to do the same in Mathematica which I don't know at all. I'm trying to find the best value of variable u for my proces, but that's not what I'm going to ask. My code at least should print eleven values of variable 'wynik' but it doesn't. I suppose that I've got some stupid and minor mistake in syntax, but as I've said earlier - I'm new at Mathematica environment. Any thoughts?

> For[u == 1, u <= 1, u == u + 0.1,  
    s = NDSolve[{x1'[t] == u*(10*x2[t]
> - x1[t]),  x1[0] == 1,   
>                x2'[t] == u*(x1[t] - 10*x2[t]) - (1 - u)*x2[t], x2[0] == 0}, {x1, 
>                 {x1, x2}, {t, 0, 1}];  
    wynik == 1 - Evaluate[{x1[1] /. s} + {x2[1] /. s}]; 
    Print[wynik]]

I'm trying to optimize some kind of process in Mathematica. I did it without any problems in Matlab and now I'm trying to do the same in Mathematica which I don't know at all. I'm trying to find the best value of variable u for my proces, but that's not what I'm going to ask. My code at least should print eleven values of variable 'wynik' but it doesn't. I suppose that I've got some stupid and minor mistake in syntax, but as I've said earlier - I'm new at Mathematica environment. Any thoughts?

> For[u == 1, u <= 1, u == u + 0.1,   s = NDSolve[{x1'[t] == u*(10*x2[t]
> - x1[t]), x1[0] == 1, 
>     x2'[t] == u*(x1[t] - 10*x2[t]) - (1 - u)*x2[t], x2[0] == 0}, {x1, 
>     x2}, {t, 0, 1}];   wynik == 1 - Evaluate[{x1[1] /. s} + {x2[1] /. s}]; Print[wynik]]

I'm trying to optimize some kind of process in Mathematica. I did it without any problems in Matlab and now I'm trying to do the same in Mathematica which I don't know at all. I'm trying to find the best value of variable u for my proces, but that's not what I'm going to ask. My code at least should print eleven values of variable 'wynik' but it doesn't. I suppose that I've got some stupid and minor mistake in syntax, but as I've said earlier - I'm new at Mathematica environment. Any thoughts?

For[u == 1, u <= 1, u == u + 0.1,  
    s = NDSolve[{x1'[t] == u*(10*x2[t] - x1[t]),  x1[0] == 1,   
                x2'[t] == u*(x1[t] - 10*x2[t]) - (1 - u)*x2[t], x2[0] == 0}, 
                 {x1, x2}, {t, 0, 1}];  
    wynik == 1 - Evaluate[{x1[1] /. s} + {x2[1] /. s}]; 
    Print[wynik]]
Source Link

Differential equation and For loop in Mathematica

I'm trying to optimize some kind of process in Mathematica. I did it without any problems in Matlab and now I'm trying to do the same in Mathematica which I don't know at all. I'm trying to find the best value of variable u for my proces, but that's not what I'm going to ask. My code at least should print eleven values of variable 'wynik' but it doesn't. I suppose that I've got some stupid and minor mistake in syntax, but as I've said earlier - I'm new at Mathematica environment. Any thoughts?

> For[u == 1, u <= 1, u == u + 0.1,   s = NDSolve[{x1'[t] == u*(10*x2[t]
> - x1[t]), x1[0] == 1, 
>     x2'[t] == u*(x1[t] - 10*x2[t]) - (1 - u)*x2[t], x2[0] == 0}, {x1, 
>     x2}, {t, 0, 1}];   wynik == 1 - Evaluate[{x1[1] /. s} + {x2[1] /. s}]; Print[wynik]]