Message Boards Message Boards

0
|
4451 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Roots in the intervals

POSTED BY: Julia Ilkiv
2 Replies

Why don't you use the else of your If?

For[i = 1, i < Length@spfn, i++,
 If[((0 < spfn[[i]]) && (0 < spfn[[i + 1]])) || ((spfw[[i]] < 
       0) && (spfw[[i + 1]] < 0)), 
  Print["1) exist no roots on: {", spx[[i]], ";", spx[[i + 1]], 
   "}"], (* else *)
   Print["2) exists a root on: {", spx[[i]], ";", spx[[i + 1]], "}"]
  ]
 ]

1) exist no roots on: {-2;-1.90577}
1) exist no roots on: {-1.90577;-1.81153}
1) exist no roots on: {-1.81153;-1.59327}
1) exist no roots on: {-1.59327;-1.375}
1) exist no roots on: {-1.375;-1.35785}
1) exist no roots on: {-1.35785;-1.3407}
1) exist no roots on: {-1.3407;-1.24655}
1) exist no roots on: {-1.24655;-1.22941}
1) exist no roots on: {-1.22941;-1.11811}
1) exist no roots on: {-1.11811;-0.934054}
1) exist no roots on: {-0.934054;-0.80167}
1) exist no roots on: {-0.80167;-0.75}
1) exist no roots on: {-0.75;-0.625}
1) exist no roots on: {-0.625;-0.5}
1) exist no roots on: {-0.5;-0.25}
1) exist no roots on: {-0.25;-0.0981238}
1) exist no roots on: {-0.0981238;0.303752}
1) exist no roots on: {0.303752;0.651876}
1) exist no roots on: {0.651876;0.94833}
1) exist no roots on: {0.94833;1}
1) exist no roots on: {1;1.5}
1) exist no roots on: {1.5;1.75}
1) exist no roots on: {1.75;2.11731}
2) exists a root on: {2.11731;2.5}
2) exists a root on: {2.5;2.5625}
2) exists a root on: {2.5625;2.625}
2) exists a root on: {2.625;3.3125}
1) exist no roots on: {3.3125;3.75}
1) exist no roots on: {3.75;4}
1) exist no roots on: {4;4.00964}
1) exist no roots on: {4.00964;4.01928}
1) exist no roots on: {4.01928;4.25964}
1) exist no roots on: {4.25964;4.36731}
1) exist no roots on: {4.36731;4.5}
1) exist no roots on: {4.5;4.75}
1) exist no roots on: {4.75;5}
1) exist no roots on: {5;5.25}
1) exist no roots on: {5.25;5.5}
2) exists a root on: {5.5;5.75}
1) exist no roots on: {5.75;6}

Counter of "2)" Events is 5, not 2. So still you have to fix something with the conditions.

POSTED BY: Udo Krause

Many Thanks!

POSTED BY: Julia Ilkiv
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract