restart: f := x -> cos(x)+1 Zio2I0kieEc2IkYlNiRJKW9wZXJhdG9yR0YlSSZhcnJvd0dGJUYlLCYtSSRjb3NHRiU2IzkkIiIiRi5GLkYlRiVGJQ== sol := fsolve(f(x)=-1); # The return of fsolve can be a single object or a sequence of objects # To handle this second case [sol] converts sol as an object of type list # The expected value of sol is a list of numerical values (type = numeric) # Type~([sol], numeric) checks if the type of each element of [sol] is numeric # The return of Type~([sol], numeric) has the same type of [sol] and thus is a list of true/false # to check if all the elements are numeric a boolean "and" is necessary. # "and" operates on sequences, not lists, op(Type~([sol], numeric)) transforms Type~([sol], numeric) into a sequence if `and`(op(type~([sol], numeric))) then "yes" else "no" end if; LUknZnNvbHZlRzYkJSpwcm90ZWN0ZWRHSShfc3lzbGliRzYiNiQvLCYtSSRjb3NHRiQ2I0kieEdGJyIiIkYvRi8hIiJGLg== USNubzYi sol := fsolve(f(x)=1); if `and`(op(type~([sol], numeric))) then "yes" else "no" end if; JCIrRmp6cTohIio= USR5ZXM2Ig== sol := fsolve(f(x)=1, x=0); if `and`(op(type~([sol], numeric))) then "yes" else "no" end if; JCIrJ0dzJylIJCEiKQ== USR5ZXM2Ig== sol := fsolve(f(x)=1.1, x=0..1); if `and`(op(type~([sol], numeric))) then "yes" else "no" end if; LUknZnNvbHZlRzYkJSpwcm90ZWN0ZWRHSShfc3lzbGliRzYiNiUvLCYtSSRjb3NHRiQ2I0kieEdGJyIiIkYvRi8kIiM2ISIiRi47IiIhRi8= USNubzYi