Sponsored links: Algebra eBooks
 

Related

errormsg

Run Example
(%i1)intervals(items):=block([result],  result: if (emptyp(items)) then [] else           if(listp(items)) then          if(emptyp(rest(items))) then [] else          cons(cons(first(items),  [second(items)]),          intervals(rest(items))));
(%o1) intervals(items) := block([result], 
result : if emptyp(items) then [] else (if listp(items)
 then (if emptyp(rest(items)) then [] else cons(cons(first(items), 
[second(items)]), intervals(rest(items))))))
(%i2) intervals(makelist(n, n, 1, 10));
(%o2) [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]
(%i3) intervals(makelist(n, n, 1, 11));
(%o3) [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], 
                                                             [9, 10], [10, 11]]
(%i4) ans:errcatch(find_root(sin(x), x, 2, 3));

find_root: function has same sign at endpoints: f(2.0) = 0.90929742682568, 
                                                      f(3.0) = 0.14112000805987
(%o4)                                 []
(%i5) ans;
(%o5)                                 []
(%i6) seq(start,stop,stepping,[shift]) := block([                                            n, y:[],                                             shift: (if (not(emptyp(shift)))                                                         then float(first(shift))                                                            else (0.0))                                            ],            (n:floor((float(stop-start)/float(stepping)))),            (if (start <
 stop)            then            (y:flatten(append([y],                                         makelist(float(start+shift+(stepping*(i-start))),                                         i, start, n+start))))            else            (y:flatten(append([y],                                         makelist(-(float(stop-shift-(stepping*(i-stop)))),                                         i, -(n+stop), stop)))))            (if (n>
1.0)                then return(y)                else return([])));
(%o6) seq(start, stop, stepping, [shift]) := 
block([n, y : [], shift : if not emptyp(shift) then float(first(shift))
                      float(stop - start)
 else 0.0], n : floor(-------------------), 
                        float(stepping)
if start < stop then y : flatten(append([y], 
makelist(float(start + shift + stepping (i - start)), i, start, n + start)))
 else y : flatten(append([y], makelist(- float(stop - shift
 - stepping (i - stop)), i, - (n + stop), stop)))(if n > 1.0 then return(y)
 else return([])))
(%i7) intervals(seq(0,7,1));
(%o7) [[0.0, 1.0], [1.0, 2.0], [2.0, 3.0], [3.0, 4.0], [4.0, 5.0], [5.0, 6.0], 
                                                                    [6.0, 7.0]]
(%i8) ans:[];
(%o8)                                 []
(%i9) %pi;
(%o9)                                 %pi
(%i10) %pi, numer;
(%o10)                         3.141592653589793
(%i11) 2*3.14159/%pi;
                                    6.28318
(%o11)                              -------
                                      %pi
(%i12) block([ans:[]], errormsg:false, for i in intervals(seq(0, 7, 1)) do ans:(append(ans, errcatch(find_root(sin(x), x, first(i), second(i))))), errormsg:true, return(ans));
(%o12)            [0.0, 3.141592653589793, 6.283185307179586]
(%i13) 
Run Example
solvetrigwarn:false;
(%o1)                                false
(%i2) ratprint:false;
(%o2)                                false
(%i3) errormsg:false;
(%o3)                                false
(%i4) plot2d(cot(x),[x, 0, 2*%pi], [y, -100, 100]);
plotplot2d(cot(x),[x, 0, 2*%pi], [y, -100, 100]);limit(cot(x), x, %pi, plus);
(%o5)                                 inf
(%i6) limit(cot(x), x, %pi, minus);
(%o6)                                minf
(%i7) is(equal(limit(cot(x), x, %pi, plus), limit(cot(x), x, %pi, minus)));
(%o7)                                false
(%i8) continuous_at(expr, var, at):=block(if(is(equal(limit(expr, var, at, plus),limit(expr, var, at, minus))))then yes else no);
(%o8) continuous_at(expr, var, at) := block(if is(equal(limit(expr, var, at, 
                         plus), limit(expr, var, at, minus))) then yes else no)
(%i9) continuous_at(cot(x), x, %pi/2);
(%o9)                                 yes
(%i10) for i:0 thru 2*%pi step 0.1 do print(continuous_at(cot(x), x, i));
no 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
yes 
(%o10)                               done
(%i11) 
Run Example
find_roots(expr, min, max, [stepping]):=block([ans:[], stepping:if(not(emptyp(stepping))) then float(stepping+1) else 1.1],intervals(items):=block([result],  result: if (emptyp(items)) then [] else          if(listp(items)) then           if(emptyp(rest(items))) then [] else               cons(cons(first(items),  [second(items)]),                       intervals(rest(items)))),seq(start,stop,stepping,[shift]) := block([                                            n, y:[],                                             shift: (if (not(emptyp(shift)))                                                         then float(first(shift))                                                            else (0.0))                                            ],            (n:floor((float(stop-start)/float(stepping)))),            (if (start <
 stop)            then            (y:flatten(append([y],                                         makelist(float(start+shift+(stepping*(i-start))),                                         i, start, n+start))))            else            (y:flatten(append([y],                                         makelist(-(float(stop-shift-(stepping*(i-stop)))),                                         i, -(n+stop), stop)))))            (if (n>
1.0)                then return(y)                else return([]))),errormsg:false,     for i in intervals(seq(min, max, stepping+1)) do         ans:(append(ans, errcatch(find_root(expr, x, first(i), second(i))))),             errormsg:true, return(ans));
(%o1) find_roots(expr, min, max, [stepping]) := 
block([ans : [], stepping : if not emptyp(stepping) then float(stepping + 1)
 else 1.1], intervals(items) := block([result], 
result : if emptyp(items) then [] else (if listp(items)
 then (if emptyp(rest(items)) then [] else cons(cons(first(items), 
[second(items)]), intervals(rest(items)))))), 
seq(start, stop, stepping, [shift]) := 
block([n, y : [], shift : if not emptyp(shift) then float(first(shift))
                      float(stop - start)
 else 0.0], n : floor(-------------------), 
                        float(stepping)
if start < stop then y : flatten(append([y], 
makelist(float(start + shift + stepping (i - start)), i, start, n + start)))
 else y : flatten(append([y], makelist(- float(stop - shift
 - stepping (i - stop)), i, - (n + stop), stop)))(if n > 1.0 then return(y)
 else return([]))), errormsg : false, for i in intervals(seq(min, max, 
stepping + 1)) do ans : append(ans, errcatch(find_root(expr, x, first(i), 
second(i)))), errormsg : true, return(ans))
(%i2) find_roots(sin(x), 0, 2*%pi);
(%o2)                      [0.0, 3.141592653589793]
(%i3) 

Related Help

Help for Errormsg