Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Problem with conditional statement in Mathematica

  1. Feb 24, 2010 #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


    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
  2. jcsd
  3. Feb 24, 2010 #2
    Nevermind, problem resolved.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Threads - Problem conditional statement Date
Does anyone had this plotting problem with MATLAB? Dec 23, 2017
Mathematica Solve Perturbation problem with mathematica Dec 7, 2017
Mathematica For looping problem not getting answer May 24, 2017
Problem with a boundary condition in Comsol Feb 21, 2009
Conditional statement problem in ode Matlab Oct 14, 2008