I solve some equations numerically with FindRoot[] returning a quadruple {1,2,3,4}. Because the solver sometimes do not find any roots depending on parameterization of these equations I select only those replacement rules "full filling" the equations:

Select[rules, ! MemberQ[eqns /. #1, False] &];

My question is the following:

How can I easily calculate the deviation of an application of a replacement rule quadruples containing a False so i can check how "badly" some of my equations are not met. My problem is that as soon as I apply an rule to an equation the result is of type boolean and not numeric - which is needed for calculating the deviation.

To note: I do back substitution of my previous solution into the solver as I'am variating some parameters. (see here)

Thank you for your suggestions!


Does the following do what you want?

eqns /. Equal -> Subtract /. rules
  • $\begingroup$ this returns Null if I apply my false rules. It also throws me following error message: Set::write $\endgroup$ – Martin Scherer May 20 '12 at 19:37
  • $\begingroup$ Strange. Maybe you should post (in simplified form, but with the essential structure intact) what your equations and rules actually look like (if your equations really are equations, and your rules are of the form var -> value, there should be no way to trigger Set::write – did you happen to use = instead of == somewhere?). $\endgroup$ – celtschk May 20 '12 at 19:42
  • $\begingroup$ i added the semicolon inside my module inside of a Print containing your statement. It works perfectly - thank you $\endgroup$ – Martin Scherer May 20 '12 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.