Skip to main content
added 15 characters in body; edited tags; edited title
Source Link
Domen
  • 33.4k
  • 3
  • 47
  • 66

How tocan I enforce the use of Subtract and Divide?

It has been noted before, here and here, that when you enter a/ba/b or a-b mathematicaa-b, Mathematica does not convert these to Subtract[a,b]Subtract[a,b] or Divide[a,b]Divide[a,b]. It uses the rather long forms Times[a, Power[b,-1] ]Times[a, Power[b,-1]] and Plus[a, Times[bPlus[a, Times[b,-1]],-1] ]. Which which are slower, since you do 2two operations instead of one. My question is if

Has anyone has found a systematic way around that.? I do mcmcMCMC sampling where you calculate a function many times, in which case these effects can accumulate and result in a sizable difference in run time. I could always manually implement SubtractSubtract and DivideDivide when declaring functions, but right now I am also working on a problem where I have to take several gradients of multivariable functions and calculate the resulting object many times. SoTherefore, implementing SubtractSubtract and DivideDivide by hand would be unfeasible, as the gradient calculations themselves are already automatic.

How to enforce the use of Subtract and Divide?

It has been noted before, here and here, that when you enter a/b or a-b mathematica does not convert these to Subtract[a,b] or Divide[a,b]. It uses the rather long forms Times[a, Power[b,-1] ] and Plus[a, Times[b,-1] ]. Which are slower since you do 2 operations instead of one. My question is if anyone has found a systematic way around that. I do mcmc sampling where you calculate a function many times, in which case these effects can accumulate and result in a sizable difference in run time. I could always manually implement Subtract and Divide when declaring functions, but right now I am also working on a problem where I have to take several gradients of multivariable functions and calculate the resulting object many times. So, implementing Subtract and Divide by hand would be unfeasible, as the gradient calculations themselves are already automatic.

How can I enforce the use of Subtract and Divide?

It has been noted before, here and here, that when you enter a/b or a-b, Mathematica does not convert these to Subtract[a,b] or Divide[a,b]. It uses the rather long forms Times[a, Power[b,-1]] and Plus[a, Times[b,-1]], which are slower, since you do two operations instead of one.

Has anyone found a systematic way around that? I do MCMC sampling where you calculate a function many times, in which case these effects can accumulate and result in a sizable difference in run time. I could always manually implement Subtract and Divide when declaring functions, but right now I am also working on a problem where I have to take several gradients of multivariable functions and calculate the resulting object many times. Therefore, implementing Subtract and Divide by hand would be unfeasible, as the gradient calculations themselves are already automatic.

How to enforce the use of Subtract and Divide?

It has been noted before, here and here, that when you enter a/b or a-b mathematica does not convert these to Subtract[a,b] or Divide[a,b]. It uses the rather long forms Times[a, Power[b,-1] ] and Plus[a, Times[b,-1] ]. Which are actually slower since you do 2 operations instead of one. My question is if anyone has found a systematic way around that. I do mcmc sampling where you calculate a function many times, in which case these effects can accumulate and result in a sizable difference in run time. I could always manually implement Subtract and Divide when declaring functions, but right now I am also working inon a problem where I have to take several gradients of multivariable functions and calculate the resulting object many times. So, implementing Subtract and Divide by hand would be unfeasible, as the gradient calculations themselves are already automatic.

How to enforce the use of Subtract and Divide

It has been noted before, here and here, that when you enter a/b or a-b mathematica does not convert these to Subtract[a,b] or Divide[a,b]. It uses the rather long forms Times[a, Power[b,-1] ] and Plus[a, Times[b,-1] ]. Which are actually slower since you do 2 operations instead of one. My question is if anyone has found a systematic way around that. I do mcmc sampling where you calculate a function many times, in which case these effects can accumulate and result in a sizable difference in run time. I could always manually implement Subtract and Divide when declaring functions, but right now I am also working in a problem where I have to take several gradients of multivariable functions and calculate the resulting object many times. So, implementing Subtract and Divide by hand would be unfeasible, the gradient calculations themselves are already automatic.

How to enforce the use of Subtract and Divide?

It has been noted before, here and here, that when you enter a/b or a-b mathematica does not convert these to Subtract[a,b] or Divide[a,b]. It uses the rather long forms Times[a, Power[b,-1] ] and Plus[a, Times[b,-1] ]. Which are slower since you do 2 operations instead of one. My question is if anyone has found a systematic way around that. I do mcmc sampling where you calculate a function many times, in which case these effects can accumulate and result in a sizable difference in run time. I could always manually implement Subtract and Divide when declaring functions, but right now I am also working on a problem where I have to take several gradients of multivariable functions and calculate the resulting object many times. So, implementing Subtract and Divide by hand would be unfeasible, as the gradient calculations themselves are already automatic.

Source Link
Felipe
  • 719
  • 10

How to enforce the use of Subtract and Divide

It has been noted before, here and here, that when you enter a/b or a-b mathematica does not convert these to Subtract[a,b] or Divide[a,b]. It uses the rather long forms Times[a, Power[b,-1] ] and Plus[a, Times[b,-1] ]. Which are actually slower since you do 2 operations instead of one. My question is if anyone has found a systematic way around that. I do mcmc sampling where you calculate a function many times, in which case these effects can accumulate and result in a sizable difference in run time. I could always manually implement Subtract and Divide when declaring functions, but right now I am also working in a problem where I have to take several gradients of multivariable functions and calculate the resulting object many times. So, implementing Subtract and Divide by hand would be unfeasible, the gradient calculations themselves are already automatic.