1

I have this code:

AbsoluteTiming[g[x_, t_] := Sin[x]^90*(1 + t^2); 
 Integrate[g[x, \[Tau]], {\[Tau], 0, t}]]

with this output: Convert to Minute

I want to have convert unit to minute. This is a part of code, I have a formula in iteration. Any suggestion with UnitConvert[] ?

bahram
  • 185
  • 6
  • 1
    Why not divide by 60, or use UnitConvert[]? – J. M.'s missing motivation Jul 06 '16 at 08:53
  • @ J.M. When I use of UnitConvert[] I do not have output for Integral. I have just minute. For example I have problem with this code : UnitConvert[ AbsoluteTiming[g[x_, t_] := Sin[x]^90*(1 + t^2); Integrate[g[x, \[Tau]], {\[Tau], 0, t}]], MixedRadix["Minutes", "Seconds"]]. – bahram Jul 06 '16 at 09:05
  • Your use of MixedRadix[] confuses me, this is only useful when the duration is more than 1 minute, and you want to convert the output to minutes+seconds. – Feyre Jul 06 '16 at 09:08
  • @J.M. "Minutes" or "Minutes, Seconds" . If possible for you please consider this code: UnitConvert[ AbsoluteTiming[g[x_, t_] := Sin[x]^90*(1 + t^2); Integrate[g[x, \[Tau]], {\[Tau], 0, t}]], "Minutes"] – bahram Jul 06 '16 at 09:10
  • @Karsten I reviewed that question, but I did not use for my code. – bahram Jul 06 '16 at 09:35
  • My question is not similar with http://mathematica.stackexchange.com/questions/81268/unitconvert-works-despite-wrong-dimension-bug-or-feature?rq=1 . – bahram Jul 06 '16 at 09:59
  • ...then, couldn't you have just used MapAt[]? – J. M.'s missing motivation Jul 06 '16 at 12:46
  • Doesn't hmsAbsTiming2[g[x_, t_] := Sin[x]^90*(1 + t^2); Integrate[g[x, \[Tau]], {\[Tau], 0, t}]] with hmsAbsTiming2 from my answer to the linked question return the desired output? – Karsten7 Jul 06 '16 at 17:28
  • @Karsten 7. Dear Karsten I don't have output with hmsAbsTiming2[g[x_, t_] := Sin[x]^90*(1 + t^2); Integrate[g[x, \[Tau]], {\[Tau], 0, t}]]. – bahram Jul 07 '16 at 20:28

1 Answers1

2

As far as I am aware, AbsoluteTiming[] gives only answers in seconds, so you need to do this manually

MapAt[UnitConvert[# Quantity["Seconds"], "Minutes"] &, 
AbsoluteTiming[g[x_, t_] := Sin[x]^90*(1 + t^2); 
Integrate[g[x, \[Tau]], {\[Tau], 0, t}]], 1]

{Quantity[0.000146967, "Minutes"], t Sin[x]^90 + 1/3 t^3 Sin[x]^90}

Feyre
  • 8,597
  • 2
  • 27
  • 46