Re: [julia-users] unexpected domain error for ^(float,float)
http://docs.julialang.org/en/latest/manual/faq/#why-does-julia-give-a-domainerror-for-certain-seemingly-sensible-operations On Thursday, September 18, 2014 03:24:00 AM Florian Oswald wrote: # define a variable gamma: gamma = 1.4 mgamma = 1.0-gamma julia mgamma -0.3999 # this works: julia -0.3999^2.5 -0.10119288512475567 # this doesn't: julia mgamma^2.5 ERROR: DomainError in ^ at math.jl:252
Re: [julia-users] unexpected domain error for ^(float,float)
Seems like the literal -0.4^2.5 should throw the same error, though? On Thursday, September 18, 2014 6:42:56 AM UTC-5, Tim Holy wrote: http://docs.julialang.org/en/latest/manual/faq/#why-does-julia-give-a-domainerror-for-certain-seemingly-sensible-operations On Thursday, September 18, 2014 03:24:00 AM Florian Oswald wrote: # define a variable gamma: gamma = 1.4 mgamma = 1.0-gamma julia mgamma -0.3999 # this works: julia -0.3999^2.5 -0.10119288512475567 # this doesn't: julia mgamma^2.5 ERROR: DomainError in ^ at math.jl:252
Re: [julia-users] unexpected domain error for ^(float,float)
because it parses as -(0.4^2.5) Med venlig hilsen Andreas Noack 2014-09-18 8:54 GMT-04:00 Florian Oswald florian.osw...@gmail.com: yes - not sure why -0.4 and (-0.4) are any different. On 18 September 2014 13:52, Patrick O'Leary patrick.ole...@gmail.com wrote: Seems like the literal -0.4^2.5 should throw the same error, though? On Thursday, September 18, 2014 6:42:56 AM UTC-5, Tim Holy wrote: http://docs.julialang.org/en/latest/manual/faq/#why-does- julia-give-a-domainerror-for-certain-seemingly-sensible-operations On Thursday, September 18, 2014 03:24:00 AM Florian Oswald wrote: # define a variable gamma: gamma = 1.4 mgamma = 1.0-gamma julia mgamma -0.3999 # this works: julia -0.3999^2.5 -0.10119288512475567 # this doesn't: julia mgamma^2.5 ERROR: DomainError in ^ at math.jl:252
Re: [julia-users] unexpected domain error for ^(float,float)
Operator precedence makes them parse very different. *julia **:(-0.4^-2.5)* *:(-(0.4^-2.5))* kl. 14:54:26 UTC+2 torsdag 18. september 2014 skrev Florian Oswald følgende: yes - not sure why -0.4 and (-0.4) are any different. On 18 September 2014 13:52, Patrick O'Leary patrick...@gmail.com javascript: wrote: Seems like the literal -0.4^2.5 should throw the same error, though? On Thursday, September 18, 2014 6:42:56 AM UTC-5, Tim Holy wrote: http://docs.julialang.org/en/latest/manual/faq/#why-does- julia-give-a-domainerror-for-certain-seemingly-sensible-operations On Thursday, September 18, 2014 03:24:00 AM Florian Oswald wrote: # define a variable gamma: gamma = 1.4 mgamma = 1.0-gamma julia mgamma -0.3999 # this works: julia -0.3999^2.5 -0.10119288512475567 # this doesn't: julia mgamma^2.5 ERROR: DomainError in ^ at math.jl:252
Re: [julia-users] unexpected domain error for ^(float,float)
because it is not recognized/parsed as literal but as the application of a unary minus, which has lower precedence than ^ I guess it is not possible to give binary minus a lower precedence than ^ and unary minus of higher precedence, since these are just different methods of the same function/operator. Op donderdag 18 september 2014 14:54:26 UTC+2 schreef Florian Oswald: yes - not sure why -0.4 and (-0.4) are any different. On 18 September 2014 13:52, Patrick O'Leary patrick...@gmail.com javascript: wrote: Seems like the literal -0.4^2.5 should throw the same error, though? On Thursday, September 18, 2014 6:42:56 AM UTC-5, Tim Holy wrote: http://docs.julialang.org/en/latest/manual/faq/#why-does- julia-give-a-domainerror-for-certain-seemingly-sensible-operations On Thursday, September 18, 2014 03:24:00 AM Florian Oswald wrote: # define a variable gamma: gamma = 1.4 mgamma = 1.0-gamma julia mgamma -0.3999 # this works: julia -0.3999^2.5 -0.10119288512475567 # this doesn't: julia mgamma^2.5 ERROR: DomainError in ^ at math.jl:252
Re: [julia-users] unexpected domain error for ^(float,float)
Haha, yeah, forgot about that. On Thursday, September 18, 2014 8:00:13 AM UTC-5, Ivar Nesje wrote: Operator precedence makes them parse very different. *julia **:(-0.4^-2.5)* *:(-(0.4^-2.5))* kl. 14:54:26 UTC+2 torsdag 18. september 2014 skrev Florian Oswald følgende: yes - not sure why -0.4 and (-0.4) are any different. On 18 September 2014 13:52, Patrick O'Leary patrick...@gmail.com wrote: Seems like the literal -0.4^2.5 should throw the same error, though? On Thursday, September 18, 2014 6:42:56 AM UTC-5, Tim Holy wrote: http://docs.julialang.org/en/latest/manual/faq/#why-does- julia-give-a-domainerror-for-certain-seemingly-sensible-operations On Thursday, September 18, 2014 03:24:00 AM Florian Oswald wrote: # define a variable gamma: gamma = 1.4 mgamma = 1.0-gamma julia mgamma -0.3999 # this works: julia -0.3999^2.5 -0.10119288512475567 # this doesn't: julia mgamma^2.5 ERROR: DomainError in ^ at math.jl:252
Re: [julia-users] unexpected domain error for ^(float,float)
i see! *julia **:(-0.4^-2.5)* *:(-(0.4^-2.5))* is good to know! didnt' think of this at all so far. On 18 September 2014 14:01, Jutho juthohaege...@gmail.com wrote: because it is not recognized/parsed as literal but as the application of a unary minus, which has lower precedence than ^ I guess it is not possible to give binary minus a lower precedence than ^ and unary minus of higher precedence, since these are just different methods of the same function/operator. Op donderdag 18 september 2014 14:54:26 UTC+2 schreef Florian Oswald: yes - not sure why -0.4 and (-0.4) are any different. On 18 September 2014 13:52, Patrick O'Leary patrick...@gmail.com wrote: Seems like the literal -0.4^2.5 should throw the same error, though? On Thursday, September 18, 2014 6:42:56 AM UTC-5, Tim Holy wrote: http://docs.julialang.org/en/latest/manual/faq/#why-does-jul ia-give-a-domainerror-for-certain-seemingly-sensible-operations On Thursday, September 18, 2014 03:24:00 AM Florian Oswald wrote: # define a variable gamma: gamma = 1.4 mgamma = 1.0-gamma julia mgamma -0.3999 # this works: julia -0.3999^2.5 -0.10119288512475567 # this doesn't: julia mgamma^2.5 ERROR: DomainError in ^ at math.jl:252
Re: [julia-users] unexpected domain error for ^(float,float)
It's not like Julia is doing anything strange or uncommon here. Most people would be really surprised if -10² meant positive 100. Den torsdagen den 18:e september 2014 kl. 15:01:44 UTC+2 skrev Jutho: because it is not recognized/parsed as literal but as the application of a unary minus, which has lower precedence than ^ I guess it is not possible to give binary minus a lower precedence than ^ and unary minus of higher precedence, since these are just different methods of the same function/operator. Op donderdag 18 september 2014 14:54:26 UTC+2 schreef Florian Oswald: yes - not sure why -0.4 and (-0.4) are any different. On 18 September 2014 13:52, Patrick O'Leary patrick...@gmail.com wrote: Seems like the literal -0.4^2.5 should throw the same error, though? On Thursday, September 18, 2014 6:42:56 AM UTC-5, Tim Holy wrote: http://docs.julialang.org/en/latest/manual/faq/#why-does- julia-give-a-domainerror-for-certain-seemingly-sensible-operations On Thursday, September 18, 2014 03:24:00 AM Florian Oswald wrote: # define a variable gamma: gamma = 1.4 mgamma = 1.0-gamma julia mgamma -0.3999 # this works: julia -0.3999^2.5 -0.10119288512475567 # this doesn't: julia mgamma^2.5 ERROR: DomainError in ^ at math.jl:252
Re: [julia-users] unexpected domain error for ^(float,float)
well, I guess most computer scientists would be surprised. writing on a piece of paper -10^2 and -(10^2) I think most people are going to say the first expression is 100 and the second is -100. I take the point that what I did was a bit stupid and Julia is not making any mistake here. On 18 September 2014 16:50, Gunnar Farnebäck gun...@lysator.liu.se wrote: It's not like Julia is doing anything strange or uncommon here. Most people would be really surprised if -10² meant positive 100. Den torsdagen den 18:e september 2014 kl. 15:01:44 UTC+2 skrev Jutho: because it is not recognized/parsed as literal but as the application of a unary minus, which has lower precedence than ^ I guess it is not possible to give binary minus a lower precedence than ^ and unary minus of higher precedence, since these are just different methods of the same function/operator. Op donderdag 18 september 2014 14:54:26 UTC+2 schreef Florian Oswald: yes - not sure why -0.4 and (-0.4) are any different. On 18 September 2014 13:52, Patrick O'Leary patrick...@gmail.com wrote: Seems like the literal -0.4^2.5 should throw the same error, though? On Thursday, September 18, 2014 6:42:56 AM UTC-5, Tim Holy wrote: http://docs.julialang.org/en/latest/manual/faq/#why-does-jul ia-give-a-domainerror-for-certain-seemingly-sensible-operations On Thursday, September 18, 2014 03:24:00 AM Florian Oswald wrote: # define a variable gamma: gamma = 1.4 mgamma = 1.0-gamma julia mgamma -0.3999 # this works: julia -0.3999^2.5 -0.10119288512475567 # this doesn't: julia mgamma^2.5 ERROR: DomainError in ^ at math.jl:252
Re: [julia-users] unexpected domain error for ^(float,float)
On Thursday, September 18, 2014 12:00:32 PM UTC-4, Florian Oswald wrote: well, I guess most computer scientists would be surprised. writing on a piece of paper -10^2 and -(10^2) I think most people are going to say the first expression is 100 and the second is -100. I take the point that what I did was a bit stupid and Julia is not making any mistake here. Note that in Fortran, Python, Matlab, and Mathematica, the exponentiation operator has higher precedence than unary -, similar to Julia. -10^2 in WolframAlpha (http://www.wolframalpha.com/input/?i=-10%5E2) gives 100, and WolframAlpha tries pretty hard to do natural-language interpretation of mathematical expressions. So, I'm not sure why computer scientists would be surprised.
Re: [julia-users] unexpected domain error for ^(float,float)
I think that was a typo for not surprised. -- John On Sep 18, 2014, at 9:59 AM, Steven G. Johnson stevenj@gmail.com wrote: On Thursday, September 18, 2014 12:00:32 PM UTC-4, Florian Oswald wrote: well, I guess most computer scientists would be surprised. writing on a piece of paper -10^2 and -(10^2) I think most people are going to say the first expression is 100 and the second is -100. I take the point that what I did was a bit stupid and Julia is not making any mistake here. Note that in Fortran, Python, Matlab, and Mathematica, the exponentiation operator has higher precedence than unary -, similar to Julia. -10^2 in WolframAlpha (http://www.wolframalpha.com/input/?i=-10%5E2) gives 100, and WolframAlpha tries pretty hard to do natural-language interpretation of mathematical expressions. So, I'm not sure why computer scientists would be surprised.
Re: [julia-users] unexpected domain error for ^(float,float)
On Thursday, September 18, 2014 12:59:10 PM UTC-4, Steven G. Johnson wrote: Note that in Fortran, Python, Matlab, and Mathematica, the exponentiation operator has higher precedence than unary -, similar to Julia. -10^2 in WolframAlpha (http://www.wolframalpha.com/input/?i=-10%5E2) gives 100, and WolframAlpha tries pretty hard to do natural-language interpretation of mathematical expressions. Sorry, I mean that WolframAlpha gives -100. I think the rationale here is that -10^2 should be read as ASCII for –10², and the latter is –100 in usual math notation as I understand it.
Re: [julia-users] unexpected domain error for ^(float,float)
I'm not sure about most people, but given the first expression, I would have handed the paper back and told the author to clarify the ambiguity. On Thursday, September 18, 2014, Florian Oswald florian.osw...@gmail.com wrote: well, I guess most computer scientists would be surprised. writing on a piece of paper -10^2 and -(10^2) I think most people are going to say the first expression is 100 and the second is -100. I take the point that what I did was a bit stupid and Julia is not making any mistake here. On 18 September 2014 16:50, Gunnar Farnebäck gun...@lysator.liu.se javascript:_e(%7B%7D,'cvml','gun...@lysator.liu.se'); wrote: It's not like Julia is doing anything strange or uncommon here. Most people would be really surprised if -10² meant positive 100. Den torsdagen den 18:e september 2014 kl. 15:01:44 UTC+2 skrev Jutho: because it is not recognized/parsed as literal but as the application of a unary minus, which has lower precedence than ^ I guess it is not possible to give binary minus a lower precedence than ^ and unary minus of higher precedence, since these are just different methods of the same function/operator. Op donderdag 18 september 2014 14:54:26 UTC+2 schreef Florian Oswald: yes - not sure why -0.4 and (-0.4) are any different. On 18 September 2014 13:52, Patrick O'Leary patrick...@gmail.com wrote: Seems like the literal -0.4^2.5 should throw the same error, though? On Thursday, September 18, 2014 6:42:56 AM UTC-5, Tim Holy wrote: http://docs.julialang.org/en/latest/manual/faq/#why-does-jul ia-give-a-domainerror-for-certain-seemingly-sensible-operations On Thursday, September 18, 2014 03:24:00 AM Florian Oswald wrote: # define a variable gamma: gamma = 1.4 mgamma = 1.0-gamma julia mgamma -0.3999 # this works: julia -0.3999^2.5 -0.10119288512475567 # this doesn't: julia mgamma^2.5 ERROR: DomainError in ^ at math.jl:252
Re: [julia-users] unexpected domain error for ^(float,float)
ok guys i won't dig myself a deeper hole here - you win. (savored my 3 seconds of fame before steven corrected that typo tough!) On 18 September 2014 18:21, Jameson Nash vtjn...@gmail.com wrote: I'm not sure about most people, but given the first expression, I would have handed the paper back and told the author to clarify the ambiguity. On Thursday, September 18, 2014, Florian Oswald florian.osw...@gmail.com wrote: well, I guess most computer scientists would be surprised. writing on a piece of paper -10^2 and -(10^2) I think most people are going to say the first expression is 100 and the second is -100. I take the point that what I did was a bit stupid and Julia is not making any mistake here. On 18 September 2014 16:50, Gunnar Farnebäck gun...@lysator.liu.se wrote: It's not like Julia is doing anything strange or uncommon here. Most people would be really surprised if -10² meant positive 100. Den torsdagen den 18:e september 2014 kl. 15:01:44 UTC+2 skrev Jutho: because it is not recognized/parsed as literal but as the application of a unary minus, which has lower precedence than ^ I guess it is not possible to give binary minus a lower precedence than ^ and unary minus of higher precedence, since these are just different methods of the same function/operator. Op donderdag 18 september 2014 14:54:26 UTC+2 schreef Florian Oswald: yes - not sure why -0.4 and (-0.4) are any different. On 18 September 2014 13:52, Patrick O'Leary patrick...@gmail.com wrote: Seems like the literal -0.4^2.5 should throw the same error, though? On Thursday, September 18, 2014 6:42:56 AM UTC-5, Tim Holy wrote: http://docs.julialang.org/en/latest/manual/faq/#why-does-jul ia-give-a-domainerror-for-certain-seemingly-sensible-operations On Thursday, September 18, 2014 03:24:00 AM Florian Oswald wrote: # define a variable gamma: gamma = 1.4 mgamma = 1.0-gamma julia mgamma -0.3999 # this works: julia -0.3999^2.5 -0.10119288512475567 # this doesn't: julia mgamma^2.5 ERROR: DomainError in ^ at math.jl:252