Jump to content

numerical integration with PHP.


migran

Recommended Posts

Hi,

 

I am looking at numerical integration with PhP.

 

To write an algorithm is not a problem for me,

but as i am new to php i just cant figure the syntax out.

 

 

Can i have function as an argument for another function? i want to have function numerical integrator being able to integrate different functions...

 

something like:

 

 

 

<?php

echo 'look here>>>', myzed(4), integrator(myzed);

 

function integrator(func($a))

{

global func

 

some code bla bla bla

 

 

$aa=func($a)-func($b)

 

bla bla bla

 

echo $aa

}

function myzed($z)

{

global $omega;

echo $omega*$z;

}

 

?>

 

Link to comment
https://forums.phpfreaks.com/topic/117757-numerical-integration-with-php/
Share on other sites

you can't use your syntax but you can do this

 

<?php
function product ($a, $b) {return $a * $b;}

function sum ($a, $b) {return $a + $b;}

function mycall($fn, $v1, $v2) {
     return $fn ($v1,$v2);
}

$a = 3;
$b = 4;

$f = 'sum';
echo mycall($f, $a, $b);            // 7

$f = 'product';
echo mycall($f, $a, $b);            // 12

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.