Use the Euler relation to split a function into complex and imaginary parts
    9 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Sergio Manzetti
 el 2 de En. de 2018
  
    
    
    
    
    Comentada: Sergio Manzetti
 el 2 de En. de 2018
            Hi, I found a thread considering to split a function into Re and Im, and used it's command:
if true
  % code
end
y = C*exp(-(x*(g*i + (- 2*g^2 + E)^(1/2)))/h) + exp((g*i - (- 2*g^2 + E)^(1/2))/h)*exp(-(x*(g*1i - (- 2*g^2 + E)^(1/2)))/h)*(pi - C*exp(-(g*1i + (- 2*g^2 + E)^(1/2))/h))
y = rewrite(y, 'sincos')
Ref = simplify(collect(real(y)))        % Real part
Imf = simplify(collect(imag(y)))        % Imaginary part
however, the result does not split Im and Re parts:
Ref =
real((cos((524288*x*(67108864*15769878386734594^(1/2) - 5959077882784213))/616503364953199) + sin((524288*x*(67108864*15769878386734594^(1/2) - 5959077882784213))/616503364953199)* 1i)*(cos((35184372088832*15769878386734594^(1/2))/616503364953199 - 3124273025009169465344/616503364953199) - sin((35184372088832*15769878386734594^(1/2))/616503364953199 - 3124273025009169465344/616503364953199)* 1i)*(pi - C*cos((35184372088832*15769878386734594^(1/2))/616503364953199 + 3124273025009169465344/616503364953199) + C*sin((35184372088832*15769878386734594^(1/2))/616503364953199 + 3124273025009169465344/616503364953199)*1i)) + real(C*(cos((524288*x*(67108864*15769878386734594^(1/2) + 5959077882784213))/616503364953199) - sin((524288*x*(67108864*15769878386734594^(1/2) + 5959077882784213))/616503364953199)*1i))
Imf =
imag((cos((524288*x*(67108864*15769878386734594^(1/2) - 5959077882784213))/616503364953199) + sin((524288*x*(67108864*15769878386734594^(1/2) - 5959077882784213))/616503364953199)*1i)*(cos((35184372088832*15769878386734594^(1/2))/616503364953199 - 3124273025009169465344/616503364953199) - sin((35184372088832*15769878386734594^(1/2))/616503364953199 - 3124273025009169465344/616503364953199)*1i)*(pi - C*cos((35184372088832*15769878386734594^(1/2))/616503364953199 + 3124273025009169465344/616503364953199) + C*sin((35184372088832*15769878386734594^(1/2))/616503364953199 + 3124273025009169465344/616503364953199)*1i)) + imag(C*(cos((524288*x*(67108864*15769878386734594^(1/2) + 5959077882784213))/616503364953199) - sin((524288*x*(67108864*15769878386734594^(1/2) + 5959077882784213))/616503364953199)*1i))
Is this a technicallyimpossible case?
Thanks
0 comentarios
Respuesta aceptada
  John D'Errico
      
      
 el 2 de En. de 2018
        
      Editada: John D'Errico
      
      
 el 2 de En. de 2018
  
      You CANNOT use real and imag as you have done. At least, it will be a waste of time.
A quick glance shows that at least C and x are still symbolic variables. What values do they take on? Who knows? So segregating a long expression that includes those variables into real and imaginary parts is impossible.
Depending on the values of C and x (and maybe some other variables that I missed) all it can say is that the real part is real(*stuff*) and the imaginary part is imag(*stuff*). That is exactly what the symbolic toolbox returned.
Addendum: you can use vpa to simplify the expression, resolving some of the nasty looking numbers. But until explicit numeric values for C and x are supplied, you cannot reduce the result into real and imaginary parts.
Más respuestas (1)
  Walter Roberson
      
      
 el 2 de En. de 2018
        If you add assumptions to the symbolic variables then MATLAB can potentially do the appropriate separation. In particular you can use
syms x real
to add an assumption of real value to x
Ver también
Categorías
				Más información sobre Formula Manipulation and Simplification 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!


