Bestimmen von Nullstellen
interface(displayprecision = 3):
opts:= 'font = [Courier, 10], size = [350, 350]':
Erstes Beispiel
Mit solve erhält man hier offensichtlich (zunächst) nicht alle Lösungswerte:
> plot(f(x), x = -2*Pi..2*Pi, opts,
numpoints = 5000,
tickmarks = [5, 5]);
Aber:
Eigenschaften der Konstante _Z1:
Originally _Z1, renamed _Z1~:
is assumed to be: integer
Dies ergibt:
> lgn:= 0, Pi*(k + 1/2);
Numerische Berechnung einiger Nullstellen von f(x):
zeros:= zeros union {subs(k = i, evalf(lgn[2]))}:
od:
op(sort(convert(zeros, list)));
Zweites Beispiel
interface(displayprecision = 3):
opts:= 'font = [Courier, 10], size = [350, 350]':
> f:= x -> 2^x -
0.95*x^2;
plot(f(x), x = -2..5, y = -4..4,
opts);
Mit fsolve erhält man im Allgemeinen jeweils nur einen Lösungswert:
fsolve(f(x) = 0, x = 2);
fsolve(f(x) = 0, x = 4);
2.197
-0.7823
2.197
3.705
Aber:
> solve(f(x) = 0, x);
2.197, 3.705, -0.7823
Drittes Beispiel
interface(displayprecision = 4):
opts:= 'font = [Courier, 10], size = [350, 350]':
opts,
thickness = 0);
Berechnung einiger Nullstellen von f:
zeros:= {}:
for i from -18 to 10 do
zero:= fsolve(f(x) = 0, x = i):
if not evalb(zero in zeros) then
zeros:= zeros union {zero}:
fi:
od:
liste:= sort(convert(evalf(zeros), list)):
for i from 1 to nops(liste) do
print(liste[i]);
od;
Die Situation in einer kleinen Umgebung von −4,7125, bzw. von −7,854:
> plot(f(x), x = -4.713..-4.712,
tickmarks = [3,3],
opts,
thickness = 0);
> plot(f(x), x = -7.855..-7.853,
tickmarks = [3,4],
opts);
Viertes Beispiel
interface(displayprecision = 10):
opts:= 'font = [Courier, 10], size = [350, 350]':
f:= x -> (sin(x^4))/(sqrt(x^2+1))-1;
Die Anwendung von solve liefert hier ein falsches Ergebnis:
f(x[0]);
plot(f(x), x = -1..2, y = -2..1,
tickmarks = [4,3],
opts,
adaptive = true);