best approximation for double numbers
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Francesco Pio
el 21 de Jul. de 2023
Comentada: Walter Roberson
el 21 de Jul. de 2023
I have the following function which has an asymptote for y = 1 :
syms f(x)
syms x
f(x) = 1 / (1 + exp(-((x + 8.4730) / 10 )));
So, so the function should have a value < 1 for all x.
Also using "format long", of course, from a certain value of x onwards, the result of the function is approximated to 1.
format long
double(f(400)) % ans = 1
Is there a way to get an approximation to the exact value for even larger x? Or should I settle for this approximation?
0 comentarios
Respuesta aceptada
VBBV
el 21 de Jul. de 2023
format long
syms f(x)
syms x
f(x) = 1 / (1 + exp(-((x + 8.4730) / 10 )))
vpa(f(400),100)
2 comentarios
Walter Roberson
el 21 de Jul. de 2023
syms f(x)
syms x
f(x) = 1 / (1 + exp(-((x + 8.4730) / 10 )))
f1 = simplify(expand(1-f))
double(f1(400))
fplot(f1,[500 600])
f1n = matlabFunction(f1)
fplot(f1n, [500 600])
f1 gives you an idea of how quickly the value approaches 1, by showing you how quickly the difference between 1 and f falls. f1n shows that a numeric approximation (instead of a symbolic) of 1-f is still not bad at all in this kind of range.
Más respuestas (0)
Ver también
Categorías
Más información sobre Calculus en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!