3
$\begingroup$

I have a list(?) of rules (geometrically points) like;

pts={{a->3,b->6},...}

and I want to apply the logarithm to each and change the name, e.g.,

ptsNew = {{u -> log(3), v->log(6)},...}

I tried Log@@, and also Log//@ but neither even converted the number, much less the name (from x->u and y->v).

Thanks!

PS

Surprisingly, this didn't even work as expected. I was trying it for just the 2nd coordinate but the Log is on the outside of the rule...

Table[{u = 4, v = N[Log[s1a[[i]][[2]]]]}, {i, 1, 7}]

PPS

Sorry to come back but I just noticed that for my list of points (that came from an NSolve[]),

{{a -> -4.38426 - 3.57467 I, b -> 0.92847 - 0.0993489 I}, 
{a -> -4.38426 + 3.57467 I, b -> 0.92847 + 0.0993489 I}, 
{a -> 5.65685 - 2.42731*10^-7 I, b -> -0.707107 - 8.46156*10^-9 I}, 
{a -> -4.38426 + 3.57467 I, b -> 0.532424 + 0.056971 I}, 
{a -> -4.38426 + 3.57467 I, b -> -0.294228 + 0.642985 I}, 
{a -> -4.38426 - 3.57467 I, b -> -0.294228 - 0.642985 I}, 
{a -> -4.38426 - 3.57467 I, b -> 0.532424 - 0.056971 I}, 
{a -> -5.65685 + 2.43458*10^-6 I, b -> 0.707107 + 4.7445*10^-8 I}, 
{a -> 5.65685 + 4.92316*10^-7 I, b -> -0.707107 + 1.71621*10^-8 I}}

when I use @J.M. suggestion, I get nine results again, but each result is `doubled';

{{{u -> 1.73287 - 2.45757 I,  v -> 1.73287 - 2.45757 I}, 
{u -> -0.0685253 - 0.106597 I, v -> -0.0685253 - 0.106597 I}}, 
{{u -> 1.73287 + 2.45757 I, v -> 1.73287 + 2.45757 I}, 
{u -> -0.0685253 + 0.106597 I, v -> -0.0685253 + 0.106597 I}}, 
{{u -> 1.73287 - 4.29092*10^-8 I, v -> 1.73287 - 4.29092*10^-8 I}, 
{u -> -0.346574 - 3.14159 I, v -> -0.346574 - 3.14159 I}}, 
{{u -> 1.73287 + 2.45757 I, v -> 1.73287 + 2.45757 I}, 
{u -> -0.624622 + 0.106597 I, v -> -0.624622 + 0.106597 I}}, 
{{u -> 1.73287 + 2.45757 I, v -> 1.73287 + 2.45757 I}, 
{u -> -0.346574 + 1.99995 I, v -> -0.346574 + 1.99995 I}}, 
{{u -> 1.73287 - 2.45757 I, v -> 1.73287 - 2.45757 I}, 
{u -> -0.346574 - 1.99995 I, v -> -0.346574 - 1.99995 I}}, 
{{u -> 1.73287 - 2.45757 I, v -> 1.73287 - 2.45757 I}, 
{u -> -0.624622 - 0.106597 I, v -> -0.624622 - 0.106597 I}}, 
{{u -> 1.73287 + 3.14159 I, v -> 1.73287 + 3.14159 I}, 
{u -> -0.346574 + 6.70973*10^-8 I,v -> -0.346574 + 6.70973*10^-8 I}},
{{u -> 1.73287 + 8.703*10^-8 I,v -> 1.73287 + 8.703*10^-8 I}, 
{u -> -0.346574 + 3.14159 I, v -> -0.346574 + 3.14159 I}}}

Not sure if it was `permuting' instead of 'combinating' the 2 arguments or what, but the only answer worked well.

Just in case someone came across this.

$\endgroup$
  • 3
    $\begingroup$ Thread[{u, v} -> #] & /@ Log[{a, b} /. pts] ought to work. $\endgroup$ – J. M. will be back soon Jan 24 '17 at 4:18
5
$\begingroup$

How about

{u -> Log@a, v -> Log@b} /. pts
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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