Mathematica Problem with conditional statement in Mathematica

AI Thread Summary
The discussion centers on an issue with evaluating a conditional statement within a Do loop while iterating a solution to a non-linear differential equation in Mathematica. The user encountered unexpected output, specifically receiving i^2 instead of the expected values for q, which should always be less than or equal to 1. The problem was related to the evaluation of the conditional statement involving q. However, the user later resolved the issue, indicating that the problem was fixed. The context highlights challenges in using Mathematica for numerical solutions and the importance of proper evaluation within loops.
projektMayhem
Messages
4
Reaction score
1
I am trying to iterate a solution to a non-linear differential equation - but I am unable to evaluate a statement within a Do loop

Code:

Do[q = Cos[Evaluate[x'/.up]]; If[ q <= 1, Print[q], Print, Print[i^2]], {i, 0.1, 1, .1}]

x' is a solution to NDSolve

The output is i^2, which is absurd as q is necessarily <= 1.

In other words, it's not properly evaluating the conditional statement. I am lost as what to do with this, any help is greatly appreciated.

edit: I'm using Mathematica 5.0
 
Physics news on Phys.org
Nevermind, problem resolved.
 

Similar threads

Replies
1
Views
2K
Replies
2
Views
2K
Replies
6
Views
4K
Replies
5
Views
3K
Replies
4
Views
3K
Replies
2
Views
2K
Replies
1
Views
3K
Back
Top