Borrar filtros
Borrar filtros

Why do I get giant values when I plug in very small decimal values in symbolic algebra?

1 visualización (últimos 30 días)
syms v
eqn = ((40-20)/(25-20)) == ((0.0010057-0.0009996)/(v-0.0009996))
eqn = 

Respuesta aceptada

DGM
DGM el 26 de Nov. de 2021
When doing symbolic operations, it's going to always try to give exact representations of numbers. Ratios of integers are exact, whereas floating point representations are not necessarily exact. You can convert to a more familiar numeric form if you want.
Consider:
syms v
eqn = ((40-20)/(25-20)) == ((0.0010057-0.0009996)/(v-0.0009996))
eqn = 
S = solve(eqn,v) % expressed as integer ratios
S = 
format long % just so we can see all the digits
double(S) % decimal representation
ans =
0.001001125000000
The result should satisfy the equation
((40-20)/(25-20)) % LHS
ans =
4
((0.0010057-0.0009996)/(S-0.0009996)) % RHS is exactly equal
ans = 
4
Though note that the floating point representation isn't exactly the same.
((0.0010057-0.0009996)/(double(S)-0.0009996))
ans =
3.999999999999858

Más respuestas (0)

Categorías

Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by