1
$\begingroup$

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[] ?

$\endgroup$
9
  • 1
    $\begingroup$ Why not divide by 60, or use UnitConvert[]? $\endgroup$ Jul 6, 2016 at 8:53
  • $\begingroup$ @ 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"]]. $\endgroup$
    – bahram
    Jul 6, 2016 at 9:05
  • $\begingroup$ 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. $\endgroup$
    – Feyre
    Jul 6, 2016 at 9:08
  • $\begingroup$ @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"] $\endgroup$
    – bahram
    Jul 6, 2016 at 9:10
  • $\begingroup$ @Karsten I reviewed that question, but I did not use for my code. $\endgroup$
    – bahram
    Jul 6, 2016 at 9:35

1 Answer 1

2
$\begingroup$

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}

$\endgroup$
4
  • $\begingroup$ Many thanks, but I want to use of UnitConvert. Because I have iteration formula and I do not have output for every frequency. $\endgroup$
    – bahram
    Jul 6, 2016 at 8:59
  • $\begingroup$ Then please amend your question. $\endgroup$
    – Feyre
    Jul 6, 2016 at 9:00
  • 1
    $\begingroup$ I'd have used MapAt[] instead for this: expr // MapAt[Quantity[#/60, "Minutes"] &, 1] $\endgroup$ Jul 6, 2016 at 12:50
  • $\begingroup$ @J.M. Yes, edited to MapAt[] which uses UnitConvert[] though, as he specified its usage. $\endgroup$
    – Feyre
    Jul 6, 2016 at 14:00

Not the answer you're looking for? Browse other questions tagged or ask your own question.