A bug? input: 1/0 output: -Inf
Afficher commentaires plus anciens

if x=0, expected output of 1/x is Inf, but matlab output -Inf
load('x.mat')
x==0
1/0
1/x
2 commentaires
Matt J
le 13 Fév 2024
Your attached file doesn't contain a variable called x.
Image Analyst
le 13 Fév 2024
x==0 is a comparison, not an assignment. Since you didn't assign x yet, you can't see if it's equal to zero, hence the error. I think you meant x=0, not x==0.
Réponse acceptée
Plus de réponses (1)
Theorem: 1/0 = Inf if and only if 1/0 is also -Inf.
Proof: Assume first that 1/0=Inf and let us deduce the implication that 1/0=-Inf. By multiplying the numerator and denominator by -1, we obtain,
1/0 = (-1)/(-0) = (-1)/0 = -(1/0) = -Inf
proving the implication Now assume that 1/0=-Inf. Proceeding similarly,
1/0 = (-1)/(-0) = (-1)/0 = -(1/0) = -(-Inf) = +Inf
and the reverse implication is also proved. Q.E.D.
Catégories
En savoir plus sur Get Started with MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!