calculate de Jong function

Mathematica

    Next

  • 1. Wolfram free input shortcut is "cntrl =" What do we use for underscript now?
    Hello group. Is there anyway to turn off the free input in version 8? I just noticed that the shortcut for entering free input query is not only "=" but also "cntrl =" I found out because I was trying to input a limit with underscript in text cell. Instead of putting blanks for underscript, mathematica put the wolfram query thing. The same thing happens in an input cell as well. It seems the only way to put underscript is the use the mouse and click on the underscript button in the palette. It will be nice to have keyboard shortcut back. i wonder which other keyboard shortcuts are gone in version 8? Thanks for any insight in advance. Sean

calculate de Jong function

Postby Stefan Schuster » Thu, 12 May 2005 18:49:31 GMT

Hello,

I don't know how I should implement the first de jong function:

f(x)=Sum((x_i)^2)
where x is a Vector with n dimensions and x_i is the value of the i-th 
Dimension.
i.e. all Values of the Vector are squared and added.

My problem is that I don't know how many Dimensions there are, so I 
can't define the borders of the SUM function.

thanks in advance for help

Stefan


Re: calculate de Jong function

Postby Bob Hanlon » Fri, 13 May 2005 15:37:21 GMT

x={x1,x2,x3,x4};

Use Dot

f1[x_?VectorQ] := x.x;

f1[x]

x1^2 + x2^2 + x3^2 + x4^2

or

f2[x_?VectorQ] := Tr[x^2];

f2[x]

x1^2 + x2^2 + x3^2 + x4^2

or

f3[x_?VectorQ] := Plus@@(x^2);

f3[x]

x1^2 + x2^2 + x3^2 + x4^2

or

f4[x_?VectorQ] := Inner[Times,x,x];

f4[x]

x1^2 + x2^2 + x3^2 + x4^2


Bob Hanlon



Re: calculate de Jong function

Postby Jens-Peer Kuska » Fri, 13 May 2005 15:39:37 GMT

Hi,

your vector is a list and the dimension of the 
vector is the
length of the list

f[x_]:=x.x

does what you want.

Regards
  Jens


"Stefan Schuster" 
<bi1169*delete_from_star_to_star*@fh-weihenstephan.de> 
schrieb im Newsbeitrag 





Re: calculate de Jong function

Postby dh » Fri, 13 May 2005 15:43:25 GMT

Hi Stefan,
there is the Length function that gives you the length of e.g. a vector, 
that is the dimension of your x.
In version 5.1 there is the function Norm that can make your life still 
easier.
Sincerely, Daniel





Re: calculate de Jong function

Postby Chris Chiasson » Fri, 13 May 2005 15:48:43 GMT

x=some vector

f[x_]=x.x



On 5/11/05, Stefan Schuster




-- 
Chris Chiasson
 http://www.**--****.com/ 
1 (810) 265-3161


Re: calculate de Jong function

Postby Christoph Lhotka » Fri, 13 May 2005 15:57:04 GMT

Hi!

f[x_List] := Sum[x[[i]]^2, {i, 1, Length[x]}]

or

f[x_List] := Plus@@x^2

since Powers are Listable

with kind regards


On Wed, 11 May 2005 05:24:54 -0400 (EDT)




-- Christoph Lhotka --
University of Vienna
Institute for Astronomy


Re: calculate de Jong function

Postby David Park » Fri, 13 May 2005 16:02:22 GMT

Stefen,

Is this what you want?

deJong[vector_] := Plus @@ (vector^2)

Mapping it onto a list of vectors of varying length...

deJong /@ {{1, 1, 1}, {1, 2, 3, 4}, {a, b}}
{3, 30, a^2 + b^2}

The marvels of Mathematica functional programming!

David Park
 XXXX@XXXXX.COM 
 http://www.**--****.com/ ~djmp/ 

From: Stefan Schuster
[mailto:bi1169*delete_from_star_to_star*@fh-weihenstephan.de]
Subject:  calculate de Jong function


Hello,

I don't know how I should implement the first de jong function:

f(x)=Sum((x_i)^2)
where x is a Vector with n dimensions and x_i is the value of the i-th 
Dimension.
i.e. all Values of the Vector are squared and added.

My problem is that I don't know how many Dimensions there are, so I 
can't define the borders of the SUM function.

thanks in advance for help

Stefan






Return to Mathematica

 

Who is online

Users browsing this forum: No registered users and 55 guest