Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline 009jim  
#1 Posted : 26 May 2021 07:18:59(UTC)
009jim

Rank: Newbie

Groups: Registered
Joined: 25/05/2021(UTC)
Posts: 7
Man
Location: Australia

hi Folks, I am programming some equations and there is a requirement for a summation of terms, each term being a square root of a function of several variables. The method requires ignoring any negative results, i.e. where the square root of a negative number will lead to a complex number.

The terms are all have identical variables and it would be ideal if I can perform some operation on the general case term, so that the imaginary results just vanish.

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline Razonar  
#2 Posted : 26 May 2021 08:31:38(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Hi. You can try to redefine i:=0 and see if get the desired behavior.

Best regards.
Alvaro.
Offline gntech  
#3 Posted : 26 May 2021 08:57:00(UTC)
gntech


Rank: Member

Groups: Registered
Joined: 17/05/2021(UTC)
Posts: 19
Sweden

Was thanked: 5 time(s) in 4 post(s)
There is a function called Re that returns the real part of a complex number. See example below

SMathStudio_Desktop_bIHdwWefi7.png

For reference: The counterpart is the function Im, see below.

SMathStudio_Desktop_oWJ3TA62PH.png

Edited by user 26 May 2021 08:58:45(UTC)  | Reason: Not specified

Offline Jean Giraud  
#4 Posted : 26 May 2021 16:11:26(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
Your description is too general w/o the formula.


Circle Complexn-circles.sm (11kb) downloaded 11 time(s).

Offline 009jim  
#5 Posted : 27 May 2021 01:01:12(UTC)
009jim

Rank: Newbie

Groups: Registered
Joined: 25/05/2021(UTC)
Posts: 7
Man
Location: Australia

hi folks, thanks for your contributions
the way I've solved my dilemma was to multiply each term by (X>0) so that whenever X is less than zero the sqrt(X*(X>0)) becomes zero.
Offline Jean Giraud  
#6 Posted : 27 May 2021 02:09:39(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: 009jim Go to Quoted Post
the way I've solved my dilemma

You have solved nothing yet from nothing to pass QA !
Offline 009jim  
#7 Posted : 27 May 2021 04:02:06(UTC)
009jim

Rank: Newbie

Groups: Registered
Joined: 25/05/2021(UTC)
Posts: 7
Man
Location: Australia

Originally Posted by: Jean Giraud Go to Quoted Post
Your description is too general w/o the formula.


Capture3.JPG
Offline Razonar  
#8 Posted : 27 May 2021 06:25:47(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Hi Jim. Actually your dilemma isn't trivial and the solution that you found it's complete in the sense that you extend over the integers an operation only well defined for the natural numbers. For integers, rationals, reals, complexes, vectors, matrices, tensors ... are only conventions based on definitions by convenience, very very good ones ... but not theorems.

For example Maple have the function surd for deal with roots with integers when the usual convention doesn't work. Because power don't commute have two inverses, one by the left and other by the right, roots and logarithms, complicating the things. This is the help for the surd function from Maple website:

https://www.maplesoft.co...aple/view.aspx?path=surd

Clipboard01.jpg

As you can see, if you ask to Maple for convert surd, it returns just x^(1/n).

So, you can define your own function pow3(x) = x^3 * (x > 0). Or maybe more general some CheckPos(x) for make more readable your expression.

Best regards.
Alvaro.
Offline Jean Giraud  
#9 Posted : 27 May 2021 13:47:21(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: 009jim Go to Quoted Post
Your description is too general w/o the formula.

Attach the *.sm document.
Offline Jean Giraud  
#10 Posted : 27 May 2021 15:25:19(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
Attach the *.sm document.

... do some effort:
split that monster, zap subscript, make minimalist like visiting doctor.

Page10 Split Monster.sm (477kb) downloaded 8 time(s).
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.