7/5/2013 1:38 PM  
Joined: 11/16/2012 Last visit: 10/3/2018 Posts: 40 Rating: (0) 
Hello, I have been writing a function in SCL where higher polynomials of my input x (real) is calculated (i.e x^3 and higher). It works good for x >= 0 but it can't calculate x < 0. How does the power operation work and is there a way to solve this without using several multiplication operations (x*x*x...)? /Isak 
7/5/2013 1:44 PM  
Joined: 1/28/2009 Last visit: 10/16/2018 Posts: 6407 Rating: (1164) 
Hello, Can you try use :X^N:= {EXP( N*(LNX))} exponentiel with the prog listBest regards Hamid Hosseini 
Last edited by: hdhosseini at: 7/5/2013 1:47 PMLast edited by: hdhosseini at: 7/5/2013 1:44 PM 

7/5/2013 2:04 PM  
Joined: 11/16/2012 Last visit: 10/3/2018 Posts: 40 Rating: (0) 
This will not handle x<0 since ln(x) is not defined for x<0. Can this be the reason why the built in power operator is not working? 
7/5/2013 2:16 PM  
Joined: 1/28/2009 Last visit: 10/16/2018 Posts: 6407 Rating: (1164) 
Hello, For that we should seek a solution in Mathematics such as Taylor Series.If you can wait, I can test and update! Best regards Hamid Hosseini 
7/5/2013 4:12 PM  
Joined: 1/28/2009 Last visit: 10/16/2018 Posts: 6407 Rating: (1164) 
Hello again, as I contacted my friends Master graduated in Mathematics and Physics,They refer me to the Complex Numbers Analysis.We have course in electrical engineering dealing with that in details.You can search for references online.As far as I checked in old my notes, it should be like this; EXP{ N {LN (r)+j(teta) }} LN can not accept the negative number same as square root as we have {square root(1)= j),That is the start for complex numbers. Please consult an expert in math for a better explanation. Best regards Hamid Hosseini 
Last edited by: hdhosseini at: 7/5/2013 4:59 PM 

7/5/2013 5:07 PM  
Joined: 9/27/2006 Last visit: 10/16/2018 Posts: 7780 Rating: (1577) 
Hello iad; I can suggest you look at the OpenSource functions for S7 provided by OSCAT.de. They have a range of functions for complex numbers (and a COMPLEX datatype for such operations)available, such as 7.24. CSQRT Type Function: REAL Input X: COMPLEX (Input) Output REAL (result) CSQRT calculates the square root of a complex number This is from version 3.3 of the OSCAT library basic documentation, you can look it up on the web, and also download the oscat_basic_s7 functions, v. 3.32. http://www.oscat.de/downloadmanager/viewcategory/3.html Hope this helps, Daniel Chartier 
Last edited by: dchartier at: 7/5/2013 10:13 PMLast edited by: dchartier at: 7/5/2013 10:12 PMLast edited by: dchartier at: 7/5/2013 5:09 PM 

This contribution was helpful to2 thankful Users 
7/5/2013 10:41 PM  
Joined: 1/28/2009 Last visit: 10/16/2018 Posts: 6407 Rating: (1164) 
Hello, and finally result come out of the forum [code] L "base" L 0.0 >=R JC end L "base" ABS LN L "power" *R EXP T #temp1 L 3.14 L "power" *R T #temp2 COS L #temp1 *R T "real_part" ////////////////////// L #temp2 SIN L #temp1 *R T "im" end: NOP 0 [/code] later I will come with math in details: UPDATE: General solution for (X^N) in SCL(Complex Variables)Best regards Hamid Hosseini 
Last edited by: hdhosseini at: 7/6/2013 9:05 AM 

This contribution was helpful to2 thankful Users 
7/8/2013 8:34 AM  
Joined: 11/16/2012 Last visit: 10/3/2018 Posts: 40 Rating: (0) 
Thanks for the suggestions! Good thing that it's always possible to solve even though the best would be to use the builtin operator. But I have to say it is weak that the builtin power operator can't handle negative numbers and I don't think I'm the first one to encounter this. Is Siemens updating these kind of things continuously and is there any way to contact them about it? /Isak 
7/8/2013 8:43 AM  
Joined: 1/28/2009 Last visit: 10/16/2018 Posts: 6407 Rating: (1164) 
Hello, This is not "Developer"'s fault. They just implement normal calculation as the other processors support.Even my calculator can not do that.I think in this case they relied on our knowledge of Mathematics. Best regards Hamid Hosseini 
7/8/2013 9:02 AM  
Joined: 11/16/2012 Last visit: 10/3/2018 Posts: 40 Rating: (0) 
It's actually not so difficult math and even windows calculator can calculate (3)^3 Right now I'm calculating this by x*x*x but it would look much better with x^3 and I don't think it is so difficult to implement the negative numbers in the power operator. 
Follow us on