#!/usr/bin/env python # coding: utf-8 # # Parasitic solutions # In[25]: from sympy import * init_printing() # Find $x$ such that # $$ # \exp(-x) = 99 x # $$ # In[26]: x = symbols('x') eq1 = exp(-x) - 99*x r1 = solve(eq1,x) for r in r1: print(N(r)) # Let us make a Taylor expansion of $\exp(-x)$ around $x=0$ # In[27]: series(exp(-x),x,0) # We truncate this at the quadratic term and consider the equation # $$ # 1 - x + \frac{x^2}{2} = 99 x \qquad \Longrightarrow \qquad x^2 - 200 x + 2 = 0 # $$ # In[28]: eq2 = x**2 - 200*x + 2 r2 = solve(eq2,x) for r in r2: print(N(r)) # The simplied problem has more solutions than the original problem. One of the solutions is the correct one while the other is a spurious or parasitic solution.